Commit 46d4821
perf(gfql): shrink the right side of a left-merge when the left is empty
`_lean_prefilter_right` shrinks `right` to the keys present in `left` before a
how='left' merge. It declined to do so when `left` was EMPTY -- the one case where
shrinking is both maximally profitable and trivially correct: no left key can match
anything, and a left merge keeps only the right rows that DO match, so the result is
empty whatever `right` holds.
The cost of declining is graph-sized. Instrumenting a single-node named query on a
3.18M-node / 14M-edge graph showed the dominant work was:
safe_merge(left=0x1, right=14000000x4, how='left')
i.e. a zero-row intermediate joined against every edge in the graph. Returning a
zero-row slice of `right` keeps the identical columns and dtypes -- so the merge still
produces the same schema -- without materializing the frame.
Measured on that graph: a named seed-only query goes 112.64 -> 17.29 ms (6.5x), same
result shape. Patterns whose intermediates are non-empty are unaffected.
Parity: 650 differential comparisons (pandas + polars x 13 shapes x 25 seeds, dense
graph, null-carrying columns) -- 0 divergences. Index + lean-combine suites: no new
failures (38 pre-existing GPU-image failures unchanged, 184 passed).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VARwnAqmvczhz5EmP7TYyZ1 parent b5b18e2 commit 46d4821
1 file changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
106 | 116 | | |
107 | 117 | | |
0 commit comments