Skip to content

bench: add a generated shape suite as the third benchmark - #226

Merged
prrao87 merged 3 commits into
mainfrom
bench/shape-suite
Nov 28, 2026
Merged

prrao87 merged 3 commits into
mainfrom
bench/shape-suite

Conversation

@prrao87

@prrao87 prrao87 commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Closes #224.

Why

The two SF1 suites write each question one way, over one graph, so every gap listed in #223 was invisible to them and found only with one-off scripts. A planner change can't be judged on general multi-hop shapes (anchored paths, cycles through hubs, filtered optional hops, wide columns) without a suite that contains them. This adds that suite to the repository, generated on demand, and makes it the third suite a performance claim reports.

What changed

  • A seeded graph generator writes two graphs to Lance in seconds:

    • an Account graph with shuffled ids, a unique name, a half/half column, 500-byte notes, a heavy-tailed out-degree with a few out-hubs, 20% of edges aimed at ten in-hubs, and a relationship property;
    • a Ring graph of triangles beside a hub whose degree is the only thing that changes between levels.

    tiny is for the test, small (20,000 accounts, hub degrees up to 100,000) runs in under a minute per pass, and large (200,000 accounts) is for final numbers.

  • Seven query groups, including the two added to Add a generated shape benchmark as the third regression suite #224: phrasing, selectivity and hop order, count against rows, hubs (cycle, cycle with a hub at both ends, pattern predicate, each with and without the CSR), filtered OPTIONAL MATCH, wide columns, and early exit (LIMIT without ORDER BY). Add a generated shape benchmark as the third regression suite #224's per-row CALL group is left out: CALL { … } subqueries are a Neo4j extension, not openCypher, so their planning cost isn't something this suite tracks.

  • Checks on every run. Queries that ask the same question must return the same answer, and each query must reach the operator it measures (for example, PathExistsExec for the pattern predicate, or a real CsrExpandExec for early exit). A run fails on a mismatch or a query error; a timeout is reported as a slow result.

  • Memory. Each query runs in its own process, so the runner reports its peak memory growth, and it reports the resident size of the CSR and node indexes for each graph.

  • A report prints Markdown for each mode: group headlines against their ideal, every query's time and peak memory for two labelled builds, index sizes, and the gap between repeated main runs.

  • A performance claim now needs all three suites. CONTRIBUTING.md lists them as a numbered requirement (graph-benchmark-ldbc, graph-benchmark-ldbc-complex, the shape suite), each in both modes, and adds a harness that runs the shape suite against the main and branch wheels the same way as the other two. The docs contributing page, the README and AGENTS.md say the same, and the docs' micro-benchmark table marks shapes.py as a suite rather than a micro-benchmark.

Validation

  • A new Python test generates the tiny graph and runs every query once in memory and lazy mode. It checks that answers agree, that every query reaches its operator, and that the phrasing groups have non-empty answers. It runs in about 7 seconds on a debug build. Ruff, the strict docs build and typos pass. CI has not run yet.
  • Writing the suite turned up two mistakes in my own script, both fixed before this commit: a query name used in two groups, so one query silently ran the other's Cypher, and query errors that were skipped rather than failed. Query names are now asserted unique.
  • large generates and runs end to end (one memory pass, about 45 seconds).

Baseline on main (cd386ef, which includes #225). Release wheel, small graph, two runs per mode; the run-to-run geomean was 0.998 in memory and 1.002 in lazy, with no query moving more than 15%.004 in memory and 0.998 in lazy, with no query moving more than 15%. Headlines, with the per-query tables below:

Group Headline Ideal memory lazy
phrasing slowest / fastest of 8 phrasings 1 2.87x 7.26x
selectivity two filters: slowest / fastest end 1 15.45x 11.93x
selectivity hop order: slowest / fastest 1 1.53x 1.42x
count_rows slowest count / fastest rows <= 1 7.48x 6.69x
hubs cycle: degree 100000 / degree 10 1 18.87x 10.48x
hubs cycle, hub at both ends: degree 100000 / 10 1 24.18x 16.15x
hubs pattern predicate: degree 100000 / 10 1 71.96x 29.89x
hubs cycle at degree 100000: CSR / join <= 1 6.31x 3.74x
hubs predicate at degree 100000: CSR / join <= 1 3.52x 2.95x
optional filtered / unfiltered OPTIONAL MATCH <= 1 3.51x 26.63x
optional filtered OPTIONAL MATCH / filtered MATCH about 1 2.95x 16.50x
wide_columns cross_filter: notes / ids about 1 4.13x 16.54x
wide_columns top_k: notes / ids about 1 3.00x 14.71x
wide_columns far_filter: notes / ids about 1 1.40x 6.40x
wide_columns all: notes / ids > 1 4.42x 16.98x
early_exit LIMIT 10 / all rows, ids << 1 0.35x 0.41x
early_exit LIMIT 10 / all rows, notes << 1 0.65x 0.87x

Index resident size: 19 MiB for the Account graph (built in 20 ms) and 31 MiB for the Ring graph (25 ms).

These match the gaps #223 describes, with one addition #223 doesn't list: the 2.9× (memory) and 7.3× (lazy) phrasing spread left after #225 is entirely named against unnamed paths. A named path's PathMatch builds a node inventory from the whole Account table even for count(*), a peak of 92 MiB against 2 MiB for the unnamed form in lazy mode.

Machine: Apple M5 MacBook Pro, 24 GB, macOS 26.6.2.

Every query on the baseline

memory: small graph (20,000 accounts, 229,517 T edges, hub degrees [10, 1000, 10000, 100000])

Runs: main x2.

Group Headline Ideal main
phrasing slowest / fastest of 8 phrasings 1 2.87x
selectivity two filters: slowest / fastest end 1 15.45x
selectivity hop order: slowest / fastest 1 1.53x
count_rows slowest count / fastest rows <= 1 7.48x
hubs cycle: degree 100000 / degree 10 1 18.87x
hubs cycle, hub at both ends: degree 100000 / 10 1 24.18x
hubs pattern predicate: degree 100000 / 10 1 71.96x
hubs cycle at degree 100000: CSR / join <= 1 6.31x
hubs predicate at degree 100000: CSR / join <= 1 3.52x
optional filtered / unfiltered OPTIONAL MATCH <= 1 3.51x
optional filtered OPTIONAL MATCH / filtered MATCH about 1 2.95x
wide_columns cross_filter: notes / ids about 1 4.13x
wide_columns top_k: notes / ids about 1 3.00x
wide_columns far_filter: notes / ids about 1 1.40x
wide_columns all: notes / ids > 1 4.42x
early_exit LIMIT 10 / all rows, ids << 1 0.35x
early_exit LIMIT 10 / all rows, notes << 1 0.65x
Query main ms main peak MiB
phrasing/unnamed_start_inline 0.48 1.7
phrasing/unnamed_start_where 0.49 1.6
phrasing/unnamed_end_inline 0.48 1.7
phrasing/unnamed_end_where 0.49 1.6
phrasing/named_start_inline 1.36 10.4
phrasing/named_start_where 1.35 10.7
phrasing/named_end_inline 1.34 10.5
phrasing/named_end_where 1.38 10.3
selectivity/rows_fwd 11.13 2.7
selectivity/rows_rev 0.72 2.1
selectivity/hop_cheap_first 0.91 2.2
selectivity/hop_hub_first 1.39 2.3
count_rows/count_fwd 5.39 3.2
count_rows/count_rev 5.33 3.4
hubs/cycle_10 1.06 2.2
hubs/cycle_join_10 1.43 2.5
hubs/both_hubs_10 1.02 2.1
hubs/predicate_10 0.56 1.7
hubs/predicate_join_10 2.79 4.3
hubs/cycle_1000 1.21 2.1
hubs/cycle_join_1000 1.46 2.5
hubs/both_hubs_1000 1.19 2.0
hubs/predicate_1000 0.89 1.7
hubs/predicate_join_1000 2.91 4.6
hubs/cycle_10000 3.37 2.0
hubs/cycle_join_10000 1.75 3.1
hubs/both_hubs_10000 3.35 2.0
hubs/predicate_10000 5.12 1.8
hubs/predicate_join_10000 3.88 8.8
hubs/cycle_100000 19.94 2.1
hubs/cycle_join_100000 3.16 11.8
hubs/both_hubs_100000 24.64 2.0
hubs/predicate_100000 40.35 1.8
hubs/predicate_join_100000 11.47 51.2
optional/match 0.59 2.6
optional/optional 0.63 2.4
optional/optional_where 2.23 5.5
optional/match_where 0.75 2.5
wide_columns/far_filter_ids 2.13 3.3
wide_columns/far_filter_notes 2.98 27.3
wide_columns/cross_filter_ids 1.13 2.9
wide_columns/cross_filter_notes 4.66 123.5
wide_columns/top_k_ids 1.31 3.2
wide_columns/top_k_notes 3.92 72.8
wide_columns/all_ids 1.11 4.1
wide_columns/all_notes 4.91 190.2
early_exit/hop_limit_ids 0.38 2.0
early_exit/hop_all_ids 1.09 3.3
early_exit/hop_limit_notes 0.55 3.5
early_exit/hop_all_notes 0.85 20.6
Index main MiB main build ms
account 18.8 20
ring 30.8 25

main run-to-run geomean: 0.998; largest single-query gap 15%.

lazy: small graph (20,000 accounts, 229,517 T edges, hub degrees [10, 1000, 10000, 100000])

Runs: main x2.

Group Headline Ideal main
phrasing slowest / fastest of 8 phrasings 1 7.26x
selectivity two filters: slowest / fastest end 1 11.93x
selectivity hop order: slowest / fastest 1 1.42x
count_rows slowest count / fastest rows <= 1 6.69x
hubs cycle: degree 100000 / degree 10 1 10.48x
hubs cycle, hub at both ends: degree 100000 / 10 1 16.15x
hubs pattern predicate: degree 100000 / 10 1 29.89x
hubs cycle at degree 100000: CSR / join <= 1 3.74x
hubs predicate at degree 100000: CSR / join <= 1 2.95x
optional filtered / unfiltered OPTIONAL MATCH <= 1 26.63x
optional filtered OPTIONAL MATCH / filtered MATCH about 1 16.50x
wide_columns cross_filter: notes / ids about 1 16.54x
wide_columns top_k: notes / ids about 1 14.71x
wide_columns far_filter: notes / ids about 1 6.40x
wide_columns all: notes / ids > 1 16.98x
early_exit LIMIT 10 / all rows, ids << 1 0.41x
early_exit LIMIT 10 / all rows, notes << 1 0.87x
Query main ms main peak MiB
phrasing/unnamed_start_inline 0.64 2.1
phrasing/unnamed_start_where 0.66 2.1
phrasing/unnamed_end_inline 0.64 2.1
phrasing/unnamed_end_where 0.65 2.1
phrasing/named_start_inline 4.57 92.2
phrasing/named_start_where 4.61 92.2
phrasing/named_end_inline 4.58 92.9
phrasing/named_end_where 4.62 92.3
selectivity/rows_fwd 13.04 6.3
selectivity/rows_rev 1.09 3.5
selectivity/hop_cheap_first 1.27 2.8
selectivity/hop_hub_first 1.81 2.8
count_rows/count_fwd 7.31 7.2
count_rows/count_rev 7.28 7.6
hubs/cycle_10 2.02 4.0
hubs/cycle_join_10 3.37 5.9
hubs/both_hubs_10 1.57 2.4
hubs/predicate_10 1.39 3.5
hubs/predicate_join_10 5.71 16.3
hubs/cycle_1000 2.26 3.8
hubs/cycle_join_1000 3.40 6.2
hubs/both_hubs_1000 1.82 3.1
hubs/predicate_1000 1.82 3.6
hubs/predicate_join_1000 5.85 16.7
hubs/cycle_10000 4.36 3.4
hubs/cycle_join_10000 3.71 7.5
hubs/both_hubs_10000 3.97 2.5
hubs/predicate_10000 6.06 3.5
hubs/predicate_join_10000 6.53 20.6
hubs/cycle_100000 21.17 3.5
hubs/cycle_join_100000 5.66 24.0
hubs/both_hubs_100000 25.37 2.4
hubs/predicate_100000 41.64 3.5
hubs/predicate_join_100000 14.11 58.3
optional/match 0.76 3.0
optional/optional 0.82 3.2
optional/optional_where 21.82 27.2
optional/match_where 1.32 3.9
wide_columns/far_filter_ids 3.07 5.4
wide_columns/far_filter_notes 19.64 107.7
wide_columns/cross_filter_ids 1.44 4.2
wide_columns/cross_filter_notes 23.82 248.3
wide_columns/top_k_ids 1.69 4.1
wide_columns/top_k_notes 24.90 229.6
wide_columns/all_ids 1.43 5.7
wide_columns/all_notes 24.25 295.1
early_exit/hop_limit_ids 0.48 2.2
early_exit/hop_all_ids 1.18 5.8
early_exit/hop_limit_notes 5.75 108.4
early_exit/hop_all_notes 6.62 117.2
Index main MiB main build ms
account 19.0 18
ring 30.3 27

main run-to-run geomean: 1.002; largest single-query gap 7%.

🤖 Generated with Claude Code

The two SF1 suites write each question one way, over one graph, so they
missed every gap listed in #223. This suite generates a seeded graph
with hubs, wide text columns and shuffled ids, and runs groups of
general multi-hop shapes: one question phrased several ways, cycles and
pattern predicates through a hub of growing degree, CALL per row,
filtered OPTIONAL MATCH, wide columns, counts against rows, and LIMIT
without ORDER BY.

Each group reports a headline ratio against its ideal. Queries that ask
the same question must agree, each must reach the operator it measures,
and each runs in its own process so its peak memory is reported. The
report compares two wheels. CONTRIBUTING names it as the third suite.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Deploying lance-csr with  Cloudflare Pages  Cloudflare Pages

Latest commit: eb3430f
Status: ✅  Deploy successful!
Preview URL: https://69c8f710.lance-csr.pages.dev
Branch Preview URL: https://bench-shape-suite.lance-csr.pages.dev

View logs

@prrao87
prrao87 marked this pull request as ready for review November 27, 2026 23:59
CONTRIBUTING.md, the docs contributing page, the README and AGENTS.md now name graph-benchmark-ldbc, graph-benchmark-ldbc-complex and the shape suite as a numbered requirement, so a claim backed by only one or two of them is plainly incomplete.
CALL { ... } subqueries are a Neo4j extension, not openCypher, so the suite no longer tracks their planning cost.
@prrao87
prrao87 merged commit d751a58 into main Nov 28, 2026
5 checks passed
@prrao87
prrao87 deleted the bench/shape-suite branch November 28, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a generated shape benchmark as the third regression suite

1 participant