Skip to content

Commit fe8cbcf

Browse files
lmeyerovclaude
andcommitted
perf(gfql): fused lane collects left_counts only on the empty-match boundary
collect_all of both plans cost +2.5ms/query on 20k graphbench q5-q7 (CSE does not absorb the left-arm recompute); the hot path is back to one collect, the boundary pays a second collect only when the join is empty. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6dQEcjdazEnzuvuwf73ZL
1 parent 862089b commit fe8cbcf

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

graphistry/compute/gfql_fast_paths.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,15 +865,17 @@ def _alias_nodes_lf(fds: List[Optional[dict]], r_alias: str) -> "pl.LazyFrame":
865865
[pl.col(src_col).alias(shared_alias)] + [pl.col(key) for key in output_group_keys]
866866
)
867867
joined_lf = right_rows_lf.join(left_counts_lf, on=shared_alias, how="inner")
868-
# left_counts rides the same collect (shared subplan via CSE): the empty-match
869-
# boundary below needs it to reproduce the eager lane's shortcut semantics.
870-
joined, left_counts_df = pl.collect_all([joined_lf, left_counts_lf])
868+
# HOT PATH: one collect. left_counts is collected ONLY on the empty-match
869+
# boundary below (collect_all of both plans measured +2.5ms/query on the
870+
# 20k graphbench q5-q7 -- CSE does not absorb the left-arm recompute).
871+
joined = joined_lf.collect()
871872
if len(joined) == 0:
872873
# Eager-lane parity on the empty match: the eager all-left-counts==1
873874
# shortcut counts matched rows with pl.len(), emitting a single n=0 row
874875
# when the first arm is live but nothing joins (the openCypher-correct
875876
# count over zero rows). Every other empty shape returns the 0x0 frame,
876877
# exactly like the eager generic branch.
878+
left_counts_df = left_counts_lf.collect()
877879
if (
878880
not output_group_keys
879881
and len(left_counts_df) > 0

0 commit comments

Comments
 (0)