Commit bf1e30f
perf(gfql): translate the one-sided toLower residual natively (literal as written)
`_residual_polars_expr` recognized only the two-sided `toLower(a.col) =
toLower('lit')` shape. The Cypher renderer emits `toLower(a.col) = 'lit'`
verbatim -- there is no constant folding of `toLower('lit')` -- so the equally
idiomatic one-sided spelling failed to translate. A SINGLE untranslatable
residual declines the whole fused single-collect two-star plan, so one such
predicate dropped the query onto the eager per-op-collect path AND onto the
where_rows chain evaluator for every alias.
Semantics are the evaluator's, established by measurement before writing code:
`toLower(x)` folds the COLUMN, and a bare literal is compared AS WRITTEN, so
`toLower(x) = 'MALE'` matches zero rows on both the pandas and the polars
evaluators. The two-sided arm keeps folding the literal; the one-sided arm folds
nothing in Python. Lowercasing the one-sided RHS would be a silent wrong answer
that passes every lowercase-literal benchmark query, so mixed-case parity is
pinned directly against the general path.
Every existing decline guard applies unchanged to the new shape: escaped
literals (\uXXXX), non-string and Categorical columns, alias mismatch, absent
column. Newly qualifying is exactly one residual string shape,
`(tolower(<alias>.<col>) = '<literal>')`; reversed operand order, a column RHS,
toUpper/lower/upper, other operators, NOT-wrapping and compound predicates all
still decline.
Measured on the real graph-benchmark dataset (dgx-spark GB10, polars, perf lock
held, ABBA/BAAB, 9 runs/slot, values identical in every slot). One-sided form,
20k: q5 8.15/8.31 -> 4.17/4.61 ms, q6 12.55/13.06 -> 6.29/4.92, q7 9.40/10.39 ->
5.87/5.91. 100k: q5 18.06/17.38 -> 15.30/12.30, q6 25.54/21.35 -> 20.93/13.88,
q7 19.47/16.87 -> 11.47/11.16. Non-overlapping slot ranges in all twelve cells.
The two-sided form was measured as a control in the same session and TIES at
both scales (overlapping ranges), so no published benchmark cell moves.
Locked in by a structural probe -- the fused lane must serve exactly once for a
one-sided residual query -- not by a scaling ladder: the removed cost is a
per-op constant, so a growth-ratio gate would police the wrong direction.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015YsqAZQLbqjSDrYSFz2GoB1 parent 233b64c commit bf1e30f
3 files changed
Lines changed: 209 additions & 18 deletions
File tree
- graphistry
- compute
- tests/compute/gfql
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
615 | 615 | | |
616 | 616 | | |
617 | 617 | | |
618 | | - | |
| 618 | + | |
| 619 | + | |
619 | 620 | | |
620 | 621 | | |
621 | 622 | | |
| |||
624 | 625 | | |
625 | 626 | | |
626 | 627 | | |
627 | | - | |
| 628 | + | |
628 | 629 | | |
629 | 630 | | |
630 | 631 | | |
| |||
633 | 634 | | |
634 | 635 | | |
635 | 636 | | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
642 | | - | |
643 | | - | |
644 | | - | |
645 | | - | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
646 | 651 | | |
647 | 652 | | |
648 | 653 | | |
| |||
661 | 666 | | |
662 | 667 | | |
663 | 668 | | |
664 | | - | |
665 | | - | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
666 | 674 | | |
667 | | - | |
| 675 | + | |
668 | 676 | | |
669 | 677 | | |
670 | 678 | | |
671 | | - | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
672 | 686 | | |
673 | 687 | | |
674 | 688 | | |
| |||
712 | 726 | | |
713 | 727 | | |
714 | 728 | | |
715 | | - | |
| 729 | + | |
| 730 | + | |
716 | 731 | | |
717 | 732 | | |
718 | 733 | | |
| |||
0 commit comments