Skip to content

fix(cypher): enforce relationship uniqueness in variable-length paths - #198

Merged
prrao87 merged 9 commits into
hyperdimensionalcomputingai:mainfrom
MuddyBootsCode:codex/195-variable-length-trails
Nov 26, 2026
Merged

prrao87 merged 9 commits into
hyperdimensionalcomputingai:mainfrom
MuddyBootsCode:codex/195-variable-length-trails

Conversation

@MuddyBootsCode

@MuddyBootsCode MuddyBootsCode commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #195.

Cypher paths may revisit a node. Each stored relationship can appear only once in a trail, even when the query traverses it in reverse or crosses from a variable-length segment into another segment. Parallel relationships remain separate choices.

This affects queries such as friends-of-friends on LDBC SF1. The Cypher planner knows which hops belong to the same path and which table owns each relationship. The traversal keeps one edge identifier per active hop. For index-free joins an Arrow table builds an 8-byte ordinal per edge on first use and shares it for the snapshot. Lance scans can use the stored row address. A previous revision built the full path inventory for residual patterns. The current design follows the maintainer’s request to keep ordinary expansions for those cases.

Changes after maintainer review

With one edge between nodes 1 and 2, adding two unrelated rows with ID 9 used to make an out-and-back query return node 1. The regression now expects zero rows with CSR on and off. A second regression uses the same numeric ID under two different node labels. Both cases returned a spurious row on 3a2d3a9. Maintainer’s review

  • Determine trail eligibility from the pattern, mappings and available indexes. Remove the ID-uniqueness scan, cached inventory probe and SQL replanning. Arrow and Lance use stored edge occurrences. Custom catalogs without row IDs number parallel edges before filtering or reversing them.
  • Use one resumable CSR cursor for single segments and chains, with last-hop batching. Use one join builder and one sequence enumerator. Single segments still work with relationship mappings that omit endpoint labels.
  • Select indexes only for alternative types that can occur between the segment's boundary labels. An unindexed, disconnected type can appear first in the query without disabling the indexed walk. A path that ends at its starting variable must keep that node's label, including at zero hops.
  • Enable DataFusion's recursion protection and protect the local CSR column-pruning pass. Planning and executing a 10-by-10 index-free residual pattern now passes on the default Rust test stack.
  • Keep ordinary expansions for the residual shapes requested in review, including relationship bindings, unresolved boundaries, and an index-free chain above 64 join branches. For those shapes an edge can still be reused across segments. Full path-value queries retain their existing planner.

The single-segment cursor batches endpoints from different depths in a shallow hierarchy and reuses its frame buffers for successive input rows. Multi-segment output groups preserve their preceding boundary nodes. The work budget carries over between groups so a long scan still yields.

Verification

Candidate 53155bc5d5 passed 765 local Rust tests and doctests (11 ignored) and 1844 Python tests and doctests (2 skipped). An independent edge-by-edge oracle checked all 216 endpoint multisets across directions, zero hops, alternating types, parallel edges and CSR settings. All 9 GitHub checks passed on this commit. GitHub checks

The regression suite also exercises Arrow, Lance, namespace reads, cached SQL GRAPH_TABLE, snapshot refresh, mixed key types, comma-separated patterns and a custom catalog without row IDs. The local checks included Rust formatting, Clippy with warnings denied, Ruff, Pyright, spelling and the strict documentation build.

The documentation runner executed 68 examples. The optional 100K-person EXPLAIN fixture was skipped. The SF1 datasets were available and used for the measurements below.

Claude reviewed the code against the maintainer’s notes, recommended approval after re-reviewing the disconnected-index and cyclic-label fixes, and checked the final performance evidence. Both issues have regression tests. The seeded query’s additional cost is reported below alongside the counts each build returned. Earlier revisions and discussion are available in the PR commits and seeded-query review.

Five SF1 queries requested by the maintainer

Each original benchmark function ran on two warm, release-built engines with matching result digests on every pair. After two warm-ups we alternated execution order for 14 timed pairs per query and storage mode. Each baseline used its own paired run. The percentages are medians of individual candidate/baseline differences. Negative is faster. Both the previous PR head (3a2d3a9) and upstream main (32f55dc) were compared against this candidate.

Storage Query Previous PR → candidate (ms) Paired change Main → candidate (ms) Paired change
memory IC3 22.22 → 23.46 +5.2% 23.27 → 24.04 +2.6%
memory IC5 44.08 → 43.91 -0.4% 46.83 → 47.21 +2.9%
memory IC6 24.61 → 24.86 +0.1% 27.63 → 28.17 +2.1%
memory IC9 41.09 → 41.03 -0.7% 45.04 → 42.98 -4.1%
memory IC11 3.85 → 3.93 +3.4% 4.25 → 4.19 -2.7%
lazy IC3 159.75 → 168.21 +5.1% 164.95 → 173.99 +5.9%
lazy IC5 72.63 → 72.27 +0.9% 76.57 → 75.35 -1.1%
lazy IC6 28.55 → 28.15 -0.4% 29.25 → 30.83 +4.0%
lazy IC9 220.18 → 222.03 +1.1% 218.31 → 225.26 +3.9%
lazy IC11 6.71 → 7.05 +3.5% 7.05 → 7.46 +0.2%

Cross-segment query

For person 1131 the SF1 query below returns 438,679 valid paths. Main returns 444,109. The comparison on the synthetic graph (two million nodes and four million edges, NumPy seed 195) yields 74 valid trails and 92 on main. Both candidate counts were checked against an independent traversal. Each timing is from 20 alternating pairs after three warm-ups.

MATCH (p:Person {id:1131})-[:knows*1..2]-(f:Person)-[:knows]-(g:Person)
RETURN count(*)
Graph Storage CSR Main median ms Revised median ms Median paired change
LDBC SF1 memory on 3.61 4.82 +32.1%
LDBC SF1 memory off 6.66 7.81 +17.2%
LDBC SF1 lazy on 3.78 5.00 +32.5%
LDBC SF1 lazy off 9.91 11.58 +16.5%
2M nodes / 4M edges memory on 0.71 0.61 -17.8%
2M nodes / 4M edges memory off 9.12 11.61 +27.4%

The indexed SF1 lazy-Lance workload took 5.00 ms versus 3.78 ms on main, a 32.5% median paired increase while removing 5,430 invalid paths. The synthetic workload with CSR disabled also cost more, with a 27.4% median paired increase. These are visible single-query costs even when the standard suite averages stay close.

Full SF1 suites

Both upstream suites passed all 352 cases across two releases, two storage modes and two repetitions. The geometric mean gives equal weight to each query’s latency ratio. Negative is faster.

Suite Memory vs main Lazy Lance vs main
30-query LDBC +0.4% -0.1%
14-query interactive +1.0% -0.1%
All per-query timings, runner revisions and machine configuration

Both release wheels were built on Apple M5 Max with 128 GiB, macOS 27.0.1, Rust 1.96.0 and the macOS 26.2 Command Line Tools SDK.

Each workload ran twice per wheel in each storage mode. Lower latency is faster. Machine load can affect small differences on this shared Mac.

graph-benchmark-ldbc

Runner commit 199852076ba8dceb345e18eeb2f8ac04c73f3ea1.

memory

Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
test_benchmark_query1 0.857 0.683 0.711 0.700 -8.4% -20.2%
test_benchmark_query2 0.597 0.684 0.594 0.694 +0.5% +14.6%
test_benchmark_query3 0.688 0.695 0.681 0.701 -0.1% +1.0%
test_benchmark_query4 0.535 0.556 0.559 0.582 +4.6% +4.0%
test_benchmark_query5 1.025 1.035 1.031 1.036 +0.3% +1.0%
test_benchmark_query6 0.467 0.472 0.480 0.486 +2.9% +1.2%
test_benchmark_query7 1.216 1.249 1.245 1.256 +1.5% +2.7%
test_benchmark_query8 0.884 0.797 0.803 0.811 -3.9% -9.8%
test_benchmark_query9 1.082 0.919 1.039 0.934 -1.4% -15.1%
test_benchmark_query10 0.894 1.048 0.898 1.126 +4.2% +17.2%
test_benchmark_query11 1.624 1.624 1.629 1.710 +2.8% +0.0%
test_benchmark_query12 0.775 0.785 0.782 0.791 +0.8% +1.3%
test_benchmark_query13 0.825 0.832 0.827 0.856 +1.6% +0.9%
test_benchmark_query14 0.588 0.606 0.587 0.603 -0.3% +3.0%
test_benchmark_query15 0.627 0.626 0.617 0.631 -0.3% -0.2%
test_benchmark_query16 0.714 0.724 0.725 0.745 +2.3% +1.4%
test_benchmark_query17 1.203 1.053 1.150 1.076 -1.3% -12.5%
test_benchmark_query18 0.812 0.838 0.844 0.865 +3.6% +3.2%
test_benchmark_query19 1.120 1.144 1.096 1.154 -0.6% +2.1%
test_benchmark_query20 1.444 1.472 1.397 1.405 -3.9% +2.0%
test_benchmark_query21 0.798 0.793 0.801 0.805 +1.0% -0.7%
test_benchmark_query22 0.762 0.768 0.760 0.785 +1.0% +0.8%
test_benchmark_query23 0.804 0.819 0.804 0.837 +1.1% +1.8%
test_benchmark_query24 0.741 0.752 0.759 0.785 +3.4% +1.4%
test_benchmark_query25 0.853 0.875 0.883 0.905 +3.5% +2.6%
test_benchmark_query26 0.850 0.955 0.993 0.935 +6.8% +12.4%
test_benchmark_query27 1.068 0.921 0.913 0.974 -5.1% -13.7%
test_benchmark_query28 1.422 1.442 1.479 1.434 +1.7% +1.4%
test_benchmark_query29 0.762 0.770 0.768 0.772 +0.5% +1.1%
test_benchmark_query30 10.251 9.473 9.248 9.474 -5.1% -7.6%

Geometric mean of per-query branch/main ratios: 1.0040.

lazy

Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
test_benchmark_query1 1.249 1.220 1.213 1.200 -2.3% -2.3%
test_benchmark_query2 1.654 1.412 1.390 1.376 -9.8% -14.6%
test_benchmark_query3 0.879 1.037 0.984 0.981 +2.5% +18.0%
test_benchmark_query4 0.942 0.950 1.101 1.013 +11.7% +0.9%
test_benchmark_query5 1.948 1.988 1.990 1.958 +0.3% +2.0%
test_benchmark_query6 0.732 0.732 0.786 0.741 +4.3% -0.0%
test_benchmark_query7 1.266 1.266 1.294 1.308 +2.8% -0.0%
test_benchmark_query8 1.545 1.550 1.561 1.575 +1.3% +0.3%
test_benchmark_query9 1.286 1.287 1.294 1.283 +0.1% +0.1%
test_benchmark_query10 1.121 1.145 1.129 1.121 -0.7% +2.1%
test_benchmark_query11 2.323 2.369 2.218 2.267 -4.4% +1.9%
test_benchmark_query12 4.558 4.418 4.801 4.552 +4.2% -3.1%
test_benchmark_query13 1.200 1.220 1.213 1.216 +0.4% +1.7%
test_benchmark_query14 0.703 0.707 0.709 0.705 +0.3% +0.6%
test_benchmark_query15 0.855 0.918 0.873 0.872 -1.6% +7.4%
test_benchmark_query16 1.033 1.070 1.014 1.014 -3.6% +3.6%
test_benchmark_query17 1.731 1.713 1.749 1.741 +1.3% -1.1%
test_benchmark_query18 1.380 1.373 1.399 1.377 +0.8% -0.6%
test_benchmark_query19 1.788 1.860 1.814 1.820 -0.4% +4.0%
test_benchmark_query20 40.166 39.833 40.455 39.859 +0.4% -0.8%
test_benchmark_query21 0.856 0.837 0.841 0.856 +0.2% -2.2%
test_benchmark_query22 1.178 1.040 1.044 1.044 -5.8% -11.7%
test_benchmark_query23 1.221 1.226 1.205 1.205 -1.5% +0.4%
test_benchmark_query24 1.023 1.035 1.023 1.026 -0.4% +1.1%
test_benchmark_query25 1.304 1.270 1.305 1.289 +0.8% -2.6%
test_benchmark_query26 1.061 1.070 1.098 1.081 +2.2% +0.8%
test_benchmark_query27 1.645 1.740 1.755 1.741 +3.3% +5.7%
test_benchmark_query28 2.133 2.028 1.989 2.041 -3.1% -4.9%
test_benchmark_query29 1.218 1.139 1.130 1.129 -4.1% -6.5%
test_benchmark_query30 10.941 10.919 10.861 10.845 -0.7% -0.2%

Geometric mean of per-query branch/main ratios: 0.9988.

graph-benchmark-ldbc-complex

Runner commit a332324f2d4660b03d1d429d8ef99767af3981e5.

memory

Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
test_benchmark_query1 23.938 23.104 23.381 23.590 -0.2% -3.5%
test_benchmark_query2 2.727 2.526 2.593 2.973 +6.0% -7.4%
test_benchmark_query3 21.088 21.361 21.570 21.900 +2.4% +1.3%
test_benchmark_query4 6.184 6.074 6.119 6.175 +0.3% -1.8%
test_benchmark_query5 40.460 42.338 44.721 42.125 +4.9% +4.6%
test_benchmark_query6 20.472 22.080 20.829 20.772 -2.2% +7.9%
test_benchmark_query7 9.297 9.248 9.516 9.364 +1.8% -0.5%
test_benchmark_query8 2.591 2.348 2.432 2.565 +1.2% -9.4%
test_benchmark_query9 35.342 35.015 35.730 36.877 +3.2% -0.9%
test_benchmark_query10 14.182 14.335 14.362 14.479 +1.1% +1.1%
test_benchmark_query11 3.019 3.049 3.197 3.080 +3.5% +1.0%
test_benchmark_query12 14.464 17.856 16.345 14.991 -3.0% +23.5%
test_benchmark_query13 1.136 1.305 1.188 1.176 -3.2% +14.8%
test_benchmark_query14 251.573 250.996 247.309 248.847 -1.3% -0.2%

Geometric mean of per-query branch/main ratios: 1.0099.

lazy

Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
test_benchmark_query1 33.665 36.103 35.023 34.771 +0.0% +7.2%
test_benchmark_query2 25.030 24.433 24.377 24.914 -0.3% -2.4%
test_benchmark_query3 158.674 154.250 159.156 156.804 +1.0% -2.8%
test_benchmark_query4 13.652 13.374 14.401 13.490 +3.2% -2.0%
test_benchmark_query5 71.868 73.575 72.582 74.356 +1.0% +2.4%
test_benchmark_query6 22.189 22.566 22.523 23.119 +2.0% +1.7%
test_benchmark_query7 13.563 14.473 13.705 13.765 -2.0% +6.7%
test_benchmark_query8 3.877 3.320 3.486 3.383 -4.6% -14.4%
test_benchmark_query9 204.573 210.521 206.900 205.616 -0.6% +2.9%
test_benchmark_query10 22.721 22.715 24.406 22.967 +4.3% -0.0%
test_benchmark_query11 5.598 5.672 5.657 6.190 +5.1% +1.3%
test_benchmark_query12 17.160 17.686 17.871 18.543 +4.5% +3.1%
test_benchmark_query13 1.564 1.730 1.447 1.440 -12.3% +10.6%
test_benchmark_query14 267.677 262.069 263.042 259.907 -1.3% -2.1%

Geometric mean of per-query branch/main ratios: 0.9990.

To reproduce the correctness checks, run cargo test --locked --workspace and run uv run --no-sync pytest python/tests/test_engine_alternation.py from the Python package after building its native extension. The repository benchmark cargo bench -p lance-csr-benches --bench graph_execution -- seeded_trail exercises indexed and join trails at two graph sizes.

IC12 follow-up

The first revision in this pass, f810b55, slowed the memory expert-search query by 28.4% versus main in the two full suite runs and 35.4% on repeat. EXPLAIN ANALYZE localized the change to the tag hierarchy, which emits about 65,380 rows. Most endpoints appear before the 20-hop bound. That revision returned those endpoints to the caller one at a time. The follow-up batches them and keeps the cursor buffers for the next source row.

Each number below is a median across 21 warm memory trials per workload, rotating the order of four independently verified release wheels. The full result comparison sorts the unordered tag-name collections within each returned row.

Workload Main ms Previously reviewed PR ms First revision in this pass ms Final ms Final vs first revision, paired
Full IC12 17.56 21.30 21.21 17.89 -14.4%
Filtered hierarchy count 2.65 6.04 6.13 2.98 -50.8%
All tag hierarchy endpoints 1.99 5.61 5.62 2.28 -59.4%

Follow-up on timing outliers

No standard query exceeded a 20% increase in mean latency across the two runs per build.

Historical measurements and discussion through 3a2d3a9

Review follow-up — seeded multi-segment trails

The traversal fix is in 14803ca. The tests, benchmarks and nine passing CI checks below cover 3a2d3a95, which includes the merge of upstream main. Maintainer’s performance finding

With CSR, the traversal starts at the bound person, carries stored edge identities across segments and batches the final hop. Without CSR, the joins compare the stored occurrence IDs across segment boundaries. The earlier compatibility cases retain their existing results.

Patterns that need to return a relationship value and index-free plans that would require more than 64 join branches still use the path inventory. Incompatible ID schemas or duplicate node IDs retain the existing expansion behavior.

MATCH (p:Person {ID: 1131})-[:knows*1..2]-(f:Person)-[:knows]-(g:Person) RETURN count(*)

Release wheels for current main (32f55dcd), the previously reviewed PR (fe601405), and this revision were verified against their loaded native binaries. The table shows median execution time in milliseconds over seven warm repetitions after engine construction, with four requested DataFusion partitions. The benchmark checks the count against an independent edge-by-edge traversal on each graph.

Graph Storage CSR Main ms Prior PR ms Revised PR ms Main count Correct count on both PR builds
LDBC SF1 memory on 3.74 156.25 7.59 444,109 438,679
LDBC SF1 memory off 7.21 155.54 13.03 444,109 438,679
LDBC SF1 lazy on 4.11 158.97 7.60 444,109 438,679
LDBC SF1 lazy off 13.28 156.91 20.72 444,109 438,679
2M nodes / 4M edges memory on 0.75 1505.96 1.39 92 74
2M nodes / 4M edges memory off 9.38 1527.62 20.12 92 74

On indexed in-memory SF1, the revised median was 20.6× faster than the previously reviewed PR. It differs from current main by +3.84 ms and eliminates 5,430 invalid paths. Cold planning and execution on a newly constructed candidate engine took 17.08 ms for this query. Only the warm medians are compared in the table.

The synthetic graph uses NumPy generator seed 195, uniform endpoints in a two-million-node ID space, and start ID 1131. Different random graphs can have different counts. To reproduce the scaling check in the repo, run cargo bench -p lance-csr-benches --bench graph_execution -- seeded_trail. It checks for 48 results at both 10,000 and 100,000 nodes, with CSR on and off.

Validation. Rust workspace and doctests: 761 passed, 11 ignored. Python suite and doctests: 1835 passed, 2 skipped. The two original regression cases failed on the published commit because the physical plan used the inventory. Independent checks covered 216 cross-segment endpoint multisets, 20 binding/filter/scope comparisons, and 120 existing traversal comparisons. Rust formatting, Clippy with warnings denied, Ruff, Pyright, strict docs build, spelling and 68 runnable documentation blocks passed. The optional 100K-person docs-plan fixture was skipped. CI checks for this PR

Adjacent comparison of the reviewer’s query

The first table records independent per-build runs. To check timing drift on the shared Mac, both release engines were also kept warm with identical inputs. Only one query ran at a time. Build order alternated for 20 timed pairs per graph, storage mode and CSR setting after three warm-up pairs. Each query checked its count.

Graph Storage CSR Main median ms Revised median ms Median paired change
LDBC SF1 memory on 4.38 5.18 +19.1%
LDBC SF1 memory off 7.40 8.50 +14.6%
LDBC SF1 lazy on 4.65 5.31 +14.6%
LDBC SF1 lazy off 11.15 12.78 +12.8%
2M nodes / 4M edges memory on 0.75 0.62 -18.3%
2M nodes / 4M edges memory off 9.78 12.37 +26.4%

For comparison against current main, we give the adjacent measurements more weight because the builds alternate on the shared machine. On indexed in-memory SF1, the median difference narrowed from 3.84 ms in separate runs to 0.80 ms in adjacent runs. On the synthetic graph with CSR enabled, the comparison changed direction between runs (1.39 ms and 0.62 ms respectively, against 0.75 ms on main in both). The improvement over the prior PR is clear in both runs. The smaller difference versus main on the synthetic graph is timing-sensitive. With CSR disabled on that graph, the adjacent median was 2.59 ms higher than main. Both paired tables report the median percentage change across individual pairs.

Upstream SF1 suites

All 352 benchmark cases passed across the 30-query and 14-query suites, both storage modes, two builds and two trials. Geometric mean change in latency vs. current main (lower is faster):

Suite Memory Lazy Lance
Standard -12.6% -6.1%
Interactive complex -4.0% +2.0%

The five queries named in #195 also ran in 140 adjacent timed pairs, alternating build order; all paired result digests matched.

Mode Query Main median ms Candidate median ms Paired change
memory IC3 23.31 24.26 +1.3%
memory IC5 46.89 47.32 -1.0%
memory IC6 27.57 27.91 -0.4%
memory IC9 44.00 43.44 -0.5%
memory IC11 4.22 4.14 -2.4%
lazy IC3 174.36 178.46 +2.3%
lazy IC5 76.59 78.30 +0.7%
lazy IC6 30.75 30.20 -1.1%
lazy IC9 226.50 231.40 +1.2%
lazy IC11 7.61 7.69 -0.8%
All 88 query/storage comparisons and timing outlier rechecks

graph-benchmark-ldbc

Runner commit 199852076ba8dceb345e18eeb2f8ac04c73f3ea1.

memory

Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
test_benchmark_query1 1.299 0.767 1.379 0.664 -1.1% -40.9%
test_benchmark_query2 1.051 0.636 1.093 0.650 +3.3% -39.5%
test_benchmark_query3 1.121 0.747 1.126 0.700 -2.2% -33.4%
test_benchmark_query4 0.928 0.721 1.023 0.551 -4.6% -22.4%
test_benchmark_query5 1.735 1.119 1.778 1.030 -1.6% -35.5%
test_benchmark_query6 0.835 0.499 0.951 0.471 +6.6% -40.2%
test_benchmark_query7 2.350 1.293 2.384 1.209 -1.4% -45.0%
test_benchmark_query8 1.693 0.865 1.497 0.858 -7.9% -48.9%
test_benchmark_query9 1.989 0.969 1.546 1.278 -4.5% -51.3%
test_benchmark_query10 1.900 0.965 1.650 1.350 +4.7% -49.2%
test_benchmark_query11 3.432 1.885 2.929 2.334 -1.0% -45.1%
test_benchmark_query12 1.793 1.218 1.527 1.121 -12.0% -32.1%
test_benchmark_query13 1.993 1.143 1.522 0.985 -20.1% -42.6%
test_benchmark_query14 1.288 0.655 0.728 0.766 -23.1% -49.2%
test_benchmark_query15 1.328 0.669 0.724 0.876 -19.9% -49.7%
test_benchmark_query16 1.375 0.755 0.815 0.940 -17.6% -45.1%
test_benchmark_query17 2.051 1.128 1.168 1.484 -16.6% -45.0%
test_benchmark_query18 1.277 0.779 0.976 0.857 -10.8% -39.0%
test_benchmark_query19 2.107 1.172 1.228 1.525 -16.0% -44.4%
test_benchmark_query20 2.879 1.651 1.442 2.322 -16.9% -42.7%
test_benchmark_query21 1.785 1.036 0.778 1.110 -33.1% -42.0%
test_benchmark_query22 1.615 0.915 0.771 1.036 -28.6% -43.3%
test_benchmark_query23 1.582 0.886 0.848 0.991 -25.5% -44.0%
test_benchmark_query24 1.434 0.798 0.901 0.993 -15.2% -44.4%
test_benchmark_query25 1.323 0.996 0.853 1.237 -9.8% -24.7%
test_benchmark_query26 1.363 0.891 0.989 1.227 -1.7% -34.7%
test_benchmark_query27 1.655 0.977 0.915 1.301 -15.8% -41.0%
test_benchmark_query28 2.811 1.560 1.405 2.339 -14.4% -44.5%
test_benchmark_query29 1.582 0.991 0.769 1.021 -30.5% -37.4%
test_benchmark_query30 15.820 12.163 9.780 12.136 -21.7% -23.1%

Geometric mean of per-query branch/main ratios: 0.8738.

lazy

Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
test_benchmark_query1 1.394 1.273 1.230 1.267 -6.4% -8.7%
test_benchmark_query2 1.516 1.609 1.458 1.427 -7.7% +6.1%
test_benchmark_query3 0.940 0.848 0.837 0.809 -8.0% -9.8%
test_benchmark_query4 1.058 0.966 1.010 0.967 -2.4% -8.7%
test_benchmark_query5 2.461 2.372 2.148 2.151 -11.1% -3.6%
test_benchmark_query6 1.168 1.017 0.999 0.991 -8.9% -13.0%
test_benchmark_query7 1.725 1.321 1.480 1.968 +13.2% -23.5%
test_benchmark_query8 2.289 1.631 1.629 2.325 +0.9% -28.8%
test_benchmark_query9 1.813 1.471 1.343 1.450 -15.0% -18.9%
test_benchmark_query10 1.309 1.389 1.178 1.199 -11.9% +6.1%
test_benchmark_query11 2.407 2.331 2.233 2.670 +3.5% -3.2%
test_benchmark_query12 4.701 4.890 4.617 4.764 -2.2% +4.0%
test_benchmark_query13 1.573 1.602 1.305 1.233 -20.0% +1.8%
test_benchmark_query14 0.875 0.828 0.922 0.706 -4.4% -5.4%
test_benchmark_query15 0.979 0.979 1.034 1.265 +17.4% +0.0%
test_benchmark_query16 1.070 1.138 1.111 1.056 -1.9% +6.3%
test_benchmark_query17 1.919 2.454 2.037 2.062 -6.3% +27.9%
test_benchmark_query18 1.458 2.267 1.766 1.795 -4.4% +55.5%
test_benchmark_query19 1.671 2.435 1.760 1.854 -12.0% +45.7%
test_benchmark_query20 40.699 44.632 48.187 41.427 +5.0% +9.7%
test_benchmark_query21 1.251 1.464 0.911 1.355 -16.6% +17.0%
test_benchmark_query22 1.395 1.448 1.395 1.374 -2.6% +3.8%
test_benchmark_query23 1.302 1.692 1.506 1.558 +2.4% +30.0%
test_benchmark_query24 1.082 1.721 1.162 1.424 -7.7% +59.1%
test_benchmark_query25 1.371 1.921 1.351 1.510 -13.1% +40.1%
test_benchmark_query26 1.153 1.552 1.181 1.428 -3.5% +34.6%
test_benchmark_query27 1.535 2.297 1.542 1.902 -10.1% +49.7%
test_benchmark_query28 2.001 3.453 2.086 2.128 -22.7% +72.5%
test_benchmark_query29 1.332 1.648 1.187 1.412 -12.8% +23.7%
test_benchmark_query30 13.684 14.651 13.719 13.955 -2.3% +7.1%

Geometric mean of per-query branch/main ratios: 0.9390.

graph-benchmark-ldbc-complex

Runner commit a332324f2d4660b03d1d429d8ef99767af3981e5.

memory

Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
test_benchmark_query1 26.574 26.994 26.604 28.082 +2.1% +1.6%
test_benchmark_query2 4.063 3.673 3.452 3.252 -13.3% -9.6%
test_benchmark_query3 23.799 23.774 23.464 23.768 -0.7% -0.1%
test_benchmark_query4 7.087 7.771 7.041 7.477 -2.3% +9.7%
test_benchmark_query5 49.477 54.959 47.470 47.308 -9.2% +11.1%
test_benchmark_query6 26.000 30.373 26.256 25.636 -7.9% +16.8%
test_benchmark_query7 10.679 11.880 10.461 11.437 -2.9% +11.2%
test_benchmark_query8 3.201 3.089 3.092 3.002 -3.1% -3.5%
test_benchmark_query9 45.973 46.268 41.698 42.141 -9.1% +0.6%
test_benchmark_query10 18.219 18.084 17.169 16.865 -6.2% -0.7%
test_benchmark_query11 3.962 4.372 3.861 3.845 -7.5% +10.4%
test_benchmark_query12 21.302 21.370 22.292 21.917 +3.6% +0.3%
test_benchmark_query13 1.484 1.364 1.302 1.511 -1.2% -8.1%
test_benchmark_query14 303.360 311.348 317.853 320.674 +3.9% +2.6%

Geometric mean of per-query branch/main ratios: 0.9600.

lazy

Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
test_benchmark_query1 38.285 40.229 43.528 41.560 +8.4% +5.1%
test_benchmark_query2 28.207 28.895 29.019 28.181 +0.2% +2.4%
test_benchmark_query3 175.852 169.906 172.894 174.284 +0.4% -3.4%
test_benchmark_query4 16.022 15.831 16.473 16.510 +3.5% -1.2%
test_benchmark_query5 80.065 82.239 80.086 78.664 -2.2% +2.7%
test_benchmark_query6 31.949 29.157 33.342 27.362 -0.7% -8.7%
test_benchmark_query7 15.979 16.250 16.724 17.712 +6.8% +1.7%
test_benchmark_query8 4.317 4.297 4.226 4.293 -1.1% -0.5%
test_benchmark_query9 228.785 230.536 225.174 227.795 -1.4% +0.8%
test_benchmark_query10 26.289 29.239 27.875 29.093 +2.6% +11.2%
test_benchmark_query11 7.576 7.125 6.964 6.811 -6.3% -6.0%
test_benchmark_query12 24.790 22.327 27.059 26.619 +13.9% -9.9%
test_benchmark_query13 1.935 2.064 1.880 2.229 +2.8% +6.6%
test_benchmark_query14 314.796 295.518 309.034 314.403 +2.2% -6.1%

Geometric mean of per-query branch/main ratios: 1.0197.

Follow-up on timing outliers

No standard query exceeded a 20% increase in mean latency across the two runs per build.


Evidence from earlier PR revisions

Maintainer review follow-up

fe60140 addresses the three cases in the change request.

Reproduction Expected and observed result
Arrow chain 1 → 2 → 3 with two identical user _rowaddr values The two-hop query returns [3] with CSR on. Arrow uses input row positions to distinguish edges.
Overlapping path with X.id Int32 and Y.id Int64 Returns [1, 2] with CSR on and off.
Overlapping path with an unrelated duplicate node ID Returns [3] with CSR on and off.

The last two cases retain the existing join behavior. A relationship may be reused across two separate segments on that fallback. For eligible graphs the shared path inventory prevents reuse across the whole pattern. CSR-on takes the uniqueness answer from the existing node index. CSR-off verifies the relevant ID column on first use, shares the result with concurrent queries, and reuses it across edge-only refreshes.

All five original regression cases failed at 7f070b2. At fe60140, 741 Rust tests passed (11 ignored), 1,800 Python tests passed (one skipped), and 120 independent endpoint-multiset comparisons passed. Added coverage includes one-shot Arrow and Lance, directory namespaces, SQL GRAPH_TABLE plan reuse, snapshot refresh, and unrelated endpoint labels. Rustfmt, Clippy with warnings denied, Ruff, Pyright, spelling, the strict docs build and 62 runnable example blocks passed. The optional 100K-person docs fixture was skipped. Regression tests

All nine upstream CI checks passed on this commit. GitHub checks

Release measurements on the reviewed commit

Both upstream SF1 suites ran against ba369ff and fe60140 with CSR enabled. All 352 benchmark cases passed (44 queries × two storage modes × two builds × two runs). The harness compared the loaded native binary against the SHA-256 of each release wheel before timing. Lower latency is faster.

Geometric mean latency change vs. main In memory Lazy Lance
Standard, 30 queries -1.2% -0.8%
Interactive complex, 14 queries +2.8% +4.0%

The five maintainer queries also ran on warm engines, alternating builds for 14 timed pairs per query and mode. All 140 paired result digests matched.

Mode Query Main median ms Candidate median ms Paired change
memory IC3 24.02 23.38 -1.9%
memory IC5 43.72 45.10 +2.4%
memory IC6 28.15 28.65 +0.4%
memory IC9 45.28 44.84 -1.3%
memory IC11 4.15 4.14 -1.6%
lazy IC3 163.83 161.54 -2.4%
lazy IC5 76.71 76.56 +0.8%
lazy IC6 30.07 29.88 +0.0%
lazy IC9 223.40 218.16 -1.0%
lazy IC11 7.00 6.96 -1.5%

The unnamed Tag/Tagclass query was 2.15–3.09× faster across the tested seeds, bounds and modes. The undirected three-hop knows walk matched all 438,709 expected rows in both modes. Median times over 12 runs were 8.43 ms vs. 9.49 ms on main in memory and 8.45 ms vs. 10.18 ms on main with lazy Lance.

Both runs for every query, plus follow-up measurements for outliers

graph-benchmark-ldbc

Runner commit 199852076ba8dceb345e18eeb2f8ac04c73f3ea1.

memory

Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
test_benchmark_query1 0.742 0.692 0.712 0.711 -0.8% -6.7%
test_benchmark_query2 0.593 0.590 0.599 0.732 +12.4% -0.5%
test_benchmark_query3 0.688 0.813 0.678 0.701 -8.1% +18.2%
test_benchmark_query4 0.569 0.571 0.546 0.554 -3.6% +0.4%
test_benchmark_query5 1.030 1.064 1.033 1.014 -2.3% +3.3%
test_benchmark_query6 0.465 0.483 0.469 0.467 -1.4% +4.0%
test_benchmark_query7 1.260 1.260 1.249 1.249 -0.9% -0.0%
test_benchmark_query8 0.980 0.818 0.795 0.880 -6.8% -16.5%
test_benchmark_query9 0.923 0.915 1.034 0.940 +7.4% -0.9%
test_benchmark_query10 0.898 0.899 0.898 0.985 +4.8% +0.2%
test_benchmark_query11 1.671 2.026 1.633 1.862 -5.5% +21.2%
test_benchmark_query12 0.777 0.839 0.763 0.773 -4.9% +8.0%
test_benchmark_query13 0.834 0.849 0.843 0.822 -1.0% +1.7%
test_benchmark_query14 0.579 0.603 0.581 0.591 -0.8% +4.2%
test_benchmark_query15 0.619 0.633 0.614 0.625 -1.1% +2.3%
test_benchmark_query16 0.773 0.731 0.747 0.717 -2.6% -5.3%
test_benchmark_query17 1.253 1.075 1.197 1.066 -2.8% -14.2%
test_benchmark_query18 0.738 0.753 0.809 0.730 +3.2% +2.1%
test_benchmark_query19 1.113 1.256 1.105 1.374 +4.6% +12.9%
test_benchmark_query20 1.448 1.697 1.427 1.490 -7.2% +17.1%
test_benchmark_query21 0.883 0.798 0.789 0.784 -6.4% -9.7%
test_benchmark_query22 0.787 0.783 0.772 0.867 +4.4% -0.5%
test_benchmark_query23 0.875 0.834 0.804 0.839 -3.9% -4.7%
test_benchmark_query24 0.784 0.769 0.750 0.753 -3.2% -1.9%
test_benchmark_query25 0.892 0.882 0.906 0.912 +2.4% -1.2%
test_benchmark_query26 0.956 0.839 0.998 0.811 +0.8% -12.2%
test_benchmark_query27 1.050 0.952 0.936 1.123 +2.8% -9.3%
test_benchmark_query28 1.475 1.708 1.413 1.466 -9.6% +15.8%
test_benchmark_query29 0.767 0.793 0.761 0.760 -2.6% +3.4%
test_benchmark_query30 9.562 9.488 9.527 9.621 +0.5% -0.8%

Geometric mean of per-query branch/main ratios: 0.9882.

lazy

Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
test_benchmark_query1 1.220 1.206 1.233 1.241 +2.0% -1.1%
test_benchmark_query2 1.437 1.428 1.412 1.432 -0.7% -0.7%
test_benchmark_query3 0.841 0.802 0.829 0.830 +0.9% -4.6%
test_benchmark_query4 1.004 0.946 0.955 0.969 -1.3% -5.7%
test_benchmark_query5 2.573 2.095 2.081 2.045 -11.6% -18.6%
test_benchmark_query6 0.767 0.753 0.901 0.734 +7.5% -1.8%
test_benchmark_query7 1.286 1.389 1.378 1.479 +6.8% +8.1%
test_benchmark_query8 1.568 1.798 1.576 1.631 -4.7% +14.7%
test_benchmark_query9 1.321 1.333 1.284 1.311 -2.2% +0.9%
test_benchmark_query10 1.144 1.228 1.140 1.158 -3.1% +7.4%
test_benchmark_query11 2.080 2.194 2.127 2.104 -1.0% +5.5%
test_benchmark_query12 4.641 4.646 4.551 4.586 -1.6% +0.1%
test_benchmark_query13 1.426 1.233 1.262 1.228 -6.4% -13.5%
test_benchmark_query14 0.809 0.724 0.789 0.701 -2.9% -10.5%
test_benchmark_query15 0.922 1.051 1.021 1.138 +9.4% +14.0%
test_benchmark_query16 1.061 1.150 1.230 1.067 +3.9% +8.4%
test_benchmark_query17 1.787 1.764 1.804 1.763 +0.5% -1.3%
test_benchmark_query18 1.436 1.576 1.391 1.386 -7.8% +9.7%
test_benchmark_query19 1.624 1.609 1.684 1.563 +0.4% -1.0%
test_benchmark_query20 40.365 40.639 41.158 40.462 +0.8% +0.7%
test_benchmark_query21 0.884 0.864 0.858 0.861 -1.6% -2.4%
test_benchmark_query22 1.325 1.059 1.109 1.043 -9.7% -20.1%
test_benchmark_query23 1.271 1.573 1.572 1.648 +13.2% +23.8%
test_benchmark_query24 1.076 1.133 1.053 1.052 -4.7% +5.3%
test_benchmark_query25 1.341 1.328 1.355 1.333 +0.7% -1.0%
test_benchmark_query26 1.133 1.139 1.142 1.115 -0.6% +0.5%
test_benchmark_query27 1.451 1.472 1.502 1.453 +1.1% +1.4%
test_benchmark_query28 2.021 2.030 2.063 2.011 +0.6% +0.5%
test_benchmark_query29 1.295 1.168 1.171 1.153 -5.6% -9.8%
test_benchmark_query30 12.421 11.917 12.441 11.529 -1.5% -4.1%

Geometric mean of per-query branch/main ratios: 0.9922.

graph-benchmark-ldbc-complex

Runner commit a332324f2d4660b03d1d429d8ef99767af3981e5.

memory

Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
test_benchmark_query1 23.465 24.908 23.572 24.431 -0.8% +6.1%
test_benchmark_query2 2.949 2.855 2.745 2.730 -5.6% -3.2%
test_benchmark_query3 21.323 21.215 21.125 23.440 +4.8% -0.5%
test_benchmark_query4 6.467 6.447 6.549 6.285 -0.6% -0.3%
test_benchmark_query5 44.776 42.726 43.428 44.229 +0.2% -4.6%
test_benchmark_query6 26.716 29.281 24.128 23.544 -14.9% +9.6%
test_benchmark_query7 9.637 9.935 10.902 10.200 +7.8% +3.1%
test_benchmark_query8 2.402 2.417 2.974 2.382 +11.1% +0.6%
test_benchmark_query9 41.099 39.728 45.479 44.561 +11.4% -3.3%
test_benchmark_query10 15.601 14.890 16.453 15.492 +4.8% -4.6%
test_benchmark_query11 3.247 3.213 3.554 3.097 +3.0% -1.0%
test_benchmark_query12 17.920 17.764 21.868 19.215 +15.1% -0.9%
test_benchmark_query13 1.275 1.482 1.716 1.189 +5.4% +16.2%
test_benchmark_query14 262.169 273.057 270.598 272.735 +1.5% +4.2%

Geometric mean of per-query branch/main ratios: 1.0281.

lazy

Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
test_benchmark_query1 35.644 38.765 34.774 43.321 +5.0% +8.8%
test_benchmark_query2 26.810 26.000 25.492 25.973 -2.5% -3.0%
test_benchmark_query3 162.452 159.133 173.831 159.540 +3.7% -2.0%
test_benchmark_query4 13.961 14.333 15.633 15.972 +11.7% +2.7%
test_benchmark_query5 74.873 80.449 75.697 77.423 -1.4% +7.4%
test_benchmark_query6 27.994 26.511 26.646 25.843 -3.7% -5.3%
test_benchmark_query7 13.854 14.015 14.975 13.875 +3.5% +1.2%
test_benchmark_query8 3.871 3.491 3.489 3.402 -6.4% -9.8%
test_benchmark_query9 209.466 210.216 243.747 216.378 +9.6% +0.4%
test_benchmark_query10 24.786 25.639 25.868 26.731 +4.3% +3.4%
test_benchmark_query11 6.405 6.773 7.153 6.064 +0.3% +5.7%
test_benchmark_query12 19.690 21.468 25.994 22.611 +18.1% +9.0%
test_benchmark_query13 1.540 1.424 1.860 1.480 +12.7% -7.5%
test_benchmark_query14 298.930 292.928 324.296 293.520 +4.4% -2.0%

Geometric mean of per-query branch/main ratios: 1.0402.

Follow-up on timing outliers

No standard query exceeded a 20% increase in mean latency across the two runs per build.

Original submission at 7f070b2

Summary

Variable-length Cypher traversals now allow a node to be revisited through a different stored relationship and reject a second use of the same relationship in either direction. The four examples in #195 return the same rows for named and unnamed paths with CSR enabled or disabled.

On SF1, the unnamed Tag/Tagclass query from #186 ran 2.73–3.65× faster across the seeds, depths and storage modes tested. The three-hop undirected knows walk returned all 438,709 expected rows in 7.77 ms versus 13.34 ms on main in memory, and 10.52 ms versus 14.37 ms on disk.

Closes #195.

Problem and why it matters

With two stored edges from node 1 to node 2, a two-hop undirected traversal from 1 should return to 1 twice. Each trail takes one edge out and the other back. On main the unnamed walk drops both valid returns. A directed self-loop has the opposite failure and can be counted a second time. Naming the path or adding an empty relationship type could therefore change the answer.

Change

  • The CSR walk tracks the relationship type and stored edge row along the current trail. At the final hop it reads up to 64 adjacency entries at a time. Bounded undirected type alternation can use this traversal when its indexes are present.
  • The DataFusion join fallback also compares edge identities. Arrow supplies an ordinal allocated on first use (8 bytes per edge for that relationship type). Lance supplies a physical row address from the pinned snapshot. Catalogs without a stable ID can number parallel edges with a window. Using that window for all inputs was correct but took 134 ms in memory and 114 ms on disk for the two-hop undirected SF1 probe. The final join took 4.59 and 7.81 ms respectively.
  • The planner preserves typed endpoints on heterogeneous graphs. Named paths retain the inventory implementation. The Cypher guide and operator docs describe the rule and its scope.

Validation

  • Rust workspace and doctests, cargo test --locked --workspace — 740 passed, 11 ignored. Formatting and Clippy with warnings denied passed.
  • Python suite and doctests — 1,789 passed, 1 skipped. Ruff and Pyright passed. The 12 initial parameterized reproductions failed on upstream main.
  • 120 independent comparisons checked endpoint multiplicities, including filters, four partitions and multiple Arrow record batches. Committed regressions exercise parallel edges, cycles, self-loops, mixed types, missing endpoints, Lance deletes/appends, CSR deltas and reopening persisted indexes. Trail tests
  • Strict docs build, spelling and 62 runnable example blocks passed. The optional 100,000-person documentation fixture was unavailable, so its EXPLAIN examples were skipped.
  • Both unchanged SF1 benchmark suites checked every query against its expected results on release wheels in memory and lazy mode. 352 checks passed across 16 full runs. The loaded native binaries matched the SHA-256 hashes inside the wheels.

SF1 timings

Apple M5 Max, 128 GiB, macOS 27.0.1, Rust 1.96.0, macOS 26.2 Command Line Tools SDK. Baseline ba369ff4308acf3a93d69e45b10d147c5bb1ab65. Candidate 7f070b261c57198710bb1bf993eda72dd15cbcbc. Each suite and mode ran in main, candidate, candidate, main order using the upstream runner settings. Lower latency is faster.

Suite Queries Memory geometric mean change Lazy geometric mean change
graph-benchmark-ldbc 30 -13.1% +7.7%
graph-benchmark-ldbc-complex 14 +3.8% +3.6%

The shared Mac showed substantial drift between baseline runs. These geometric means describe the measurements. Fourteen query/mode combinations initially exceeded +20%. The largest increase among those fourteen on repeat was +3.3%.

All 88 query/mode comparisons, both baseline trials and benchmark repository commits

graph-benchmark-ldbc

Runner commit 199852076ba8dceb345e18eeb2f8ac04c73f3ea1.

memory
Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
Q1 2.012 1.349 1.692 1.211 -13.6% -33.0%
Q2 1.998 1.123 1.277 1.115 -23.4% -43.8%
Q3 1.811 1.154 1.414 1.559 +0.3% -36.3%
Q4 1.573 0.963 1.191 1.349 +0.2% -38.8%
Q5 2.450 2.122 2.252 2.439 +2.6% -13.4%
Q6 1.249 0.919 1.065 1.157 +2.5% -26.4%
Q7 2.892 2.264 2.171 2.666 -6.2% -21.7%
Q8 1.905 1.472 1.623 1.896 +4.2% -22.7%
Q9 2.234 1.629 1.728 1.810 -8.4% -27.1%
Q10 2.253 1.444 1.435 2.169 -2.5% -35.9%
Q11 3.946 2.819 2.810 4.317 +5.4% -28.6%
Q12 1.810 1.785 1.473 1.997 -3.5% -1.4%
Q13 1.786 2.569 1.778 2.292 -6.6% +43.8%
Q14 1.965 1.445 1.068 1.464 -25.7% -26.4%
Q15 2.654 1.481 1.224 1.587 -32.0% -44.2%
Q16 2.176 1.775 1.948 1.472 -13.4% -18.4%
Q17 3.769 2.574 2.591 2.507 -19.6% -31.7%
Q18 2.572 1.990 1.385 1.674 -32.9% -22.7%
Q19 2.972 2.827 2.089 2.724 -17.0% -4.9%
Q20 3.129 3.582 2.595 3.050 -15.9% +14.5%
Q21 1.721 1.973 1.479 1.601 -16.6% +14.6%
Q22 1.917 2.165 1.500 1.807 -19.0% +13.0%
Q23 1.777 1.846 1.450 1.584 -16.2% +3.9%
Q24 1.684 1.714 1.454 1.574 -10.9% +1.8%
Q25 2.045 1.882 1.646 1.767 -13.1% -8.0%
Q26 1.918 1.866 1.502 1.599 -18.0% -2.7%
Q27 2.388 2.416 1.810 1.753 -25.8% +1.2%
Q28 3.269 3.292 2.942 2.302 -20.1% +0.7%
Q29 1.843 1.662 1.503 1.359 -18.3% -9.8%
Q30 21.761 18.892 17.823 19.106 -9.2% -13.2%

Geometric mean of per-query branch/main ratios: 0.8694.

lazy
Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
Q1 2.486 1.165 1.960 1.241 -12.3% -53.1%
Q2 3.202 1.360 2.209 1.465 -19.5% -57.5%
Q3 2.208 0.786 1.384 0.872 -24.7% -64.4%
Q4 1.794 0.918 1.201 1.035 -17.6% -48.8%
Q5 3.750 1.950 2.882 2.044 -13.6% -48.0%
Q6 1.722 0.739 1.317 0.876 -10.9% -57.1%
Q7 1.778 1.266 1.701 1.256 -2.9% -28.8%
Q8 1.875 1.758 2.225 1.553 +4.0% -6.2%
Q9 1.393 1.383 1.953 1.620 +28.7% -0.8%
Q10 1.503 1.119 2.428 1.185 +37.8% -25.5%
Q11 2.933 2.052 3.376 2.184 +11.5% -30.1%
Q12 4.895 4.446 6.752 4.478 +20.2% -9.2%
Q13 1.540 1.238 2.151 1.232 +21.8% -19.6%
Q14 0.919 0.701 1.390 0.706 +29.3% -23.8%
Q15 1.023 0.867 1.737 0.868 +37.8% -15.2%
Q16 1.138 1.226 2.233 1.074 +39.9% +7.8%
Q17 1.780 1.698 3.415 2.045 +56.9% -4.6%
Q18 1.799 1.456 2.853 1.415 +31.1% -19.1%
Q19 1.736 1.543 2.770 1.714 +36.7% -11.1%
Q20 40.015 39.966 49.412 39.860 +11.6% -0.1%
Q21 0.822 0.856 0.834 0.827 -1.0% +4.2%
Q22 1.034 1.044 1.044 1.034 +0.0% +0.9%
Q23 1.379 1.315 1.196 1.266 -8.6% -4.7%
Q24 1.097 1.203 1.083 1.208 -0.4% +9.7%
Q25 1.407 1.326 1.637 1.380 +10.4% -5.8%
Q26 1.346 1.205 1.099 1.091 -14.1% -10.4%
Q27 1.460 1.658 1.522 1.463 -4.3% +13.6%
Q28 1.973 2.218 2.164 2.733 +16.8% +12.4%
Q29 1.139 1.129 1.216 1.557 +22.3% -0.9%
Q30 12.082 11.490 11.389 12.475 +1.2% -4.9%

Geometric mean of per-query branch/main ratios: 1.0766.

graph-benchmark-ldbc-complex

Runner commit a332324f2d4660b03d1d429d8ef99767af3981e5.

memory
Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
Q1 24.210 35.430 25.046 31.491 -5.2% +46.3%
Q2 2.728 4.539 2.802 4.558 +1.3% +66.4%
Q3 20.947 32.742 21.938 32.913 +2.2% +56.3%
Q4 6.239 10.650 6.528 9.149 -7.2% +70.7%
Q5 41.571 63.727 44.048 61.153 -0.1% +53.3%
Q6 27.089 43.130 26.111 37.867 -8.9% +59.2%
Q7 12.476 15.278 12.031 14.936 -2.8% +22.5%
Q8 2.488 3.464 2.972 3.791 +13.6% +39.2%
Q9 36.974 55.061 41.999 59.079 +9.8% +48.9%
Q10 15.962 20.035 17.319 22.287 +10.0% +25.5%
Q11 3.058 5.684 3.812 4.138 -9.1% +85.9%
Q12 18.818 25.905 24.014 27.200 +14.5% +37.7%
Q13 1.714 1.784 2.286 2.229 +29.1% +4.1%
Q14 274.994 362.874 336.855 388.286 +13.7% +32.0%

Geometric mean of per-query branch/main ratios: 1.0382.

lazy
Query Main 1 ms Main 2 ms Branch 1 ms Branch 2 ms Mean change Baseline repeat change
Q1 48.578 51.061 52.009 51.533 +3.9% +5.1%
Q2 34.086 34.785 32.201 35.965 -1.0% +2.1%
Q3 224.172 225.842 203.084 199.782 -10.5% +0.7%
Q4 18.621 20.328 22.659 19.818 +9.1% +9.2%
Q5 108.773 110.322 113.776 102.407 -1.3% +1.4%
Q6 38.998 39.357 37.457 45.141 +5.4% +0.9%
Q7 21.106 22.379 20.055 19.517 -9.0% +6.0%
Q8 5.731 6.111 5.261 5.035 -13.1% +6.6%
Q9 268.783 301.360 305.117 290.530 +4.5% +12.1%
Q10 36.062 34.349 38.368 36.910 +6.9% -4.8%
Q11 10.283 9.587 9.021 9.619 -6.2% -6.8%
Q12 31.639 22.058 30.839 28.020 +9.6% -30.3%
Q13 2.855 1.472 2.688 3.053 +32.7% -48.4%
Q14 370.490 294.728 441.146 424.976 +30.2% -20.4%

Geometric mean of per-query branch/main ratios: 1.0359.

All 14 outlier rechecks

Every query initially more than 20% slower was repeated twice per build, alternating builds with the same runner settings. Times are means in milliseconds.

Suite Mode Query Initial change Main 1 Main 2 Branch 1 Branch 2 Repeat change
graph-benchmark-ldbc lazy 9 +28.7% 2.855 2.398 2.472 1.910 -16.6%
graph-benchmark-ldbc lazy 10 +37.8% 2.371 2.208 1.874 1.582 -24.5%
graph-benchmark-ldbc lazy 12 +20.2% 6.638 6.149 6.587 4.869 -10.4%
graph-benchmark-ldbc lazy 13 +21.8% 2.434 2.567 2.582 1.518 -18.0%
graph-benchmark-ldbc lazy 14 +29.3% 1.231 1.668 1.705 0.831 -12.5%
graph-benchmark-ldbc lazy 15 +37.8% 1.678 2.142 2.053 0.944 -21.5%
graph-benchmark-ldbc lazy 16 +39.9% 1.995 2.257 2.041 1.101 -26.1%
graph-benchmark-ldbc lazy 17 +56.9% 3.215 3.923 3.377 1.957 -25.3%
graph-benchmark-ldbc lazy 18 +31.1% 2.382 2.775 2.575 1.644 -18.2%
graph-benchmark-ldbc lazy 19 +36.7% 3.099 3.474 3.344 2.321 -13.8%
graph-benchmark-ldbc lazy 29 +22.3% 2.244 1.969 2.172 1.396 -15.3%
graph-benchmark-ldbc-complex memory 13 +29.1% 1.413 1.347 1.485 1.365 +3.3%
graph-benchmark-ldbc-complex lazy 13 +32.7% 2.238 3.042 2.776 2.336 -3.2%
graph-benchmark-ldbc-complex lazy 14 +30.2% 325.645 410.022 369.690 383.258 +2.3%

The five queries named in #195

Back-to-back measurements used two warm engines and alternated execution order. The table reports the median of the individual candidate/main ratios across 14 pairs per query and mode. Every paired result matched. Lazy IC3 and IC9 initially measured +6.2% and +5.3%. Their physical plans matched main. Across 32 additional pairs with startup and initial execution order reversed, they measured −2.0% and −1.8%. The initial slowdowns did not reproduce.

Paired results for IC3, IC5, IC6, IC9 and IC11
Mode Query Main median ms Candidate median ms Paired change
memory IC3 32.26 32.53 -1.1%
memory IC5 58.11 54.34 -4.0%
memory IC6 34.99 35.39 +2.1%
memory IC9 55.50 57.18 +1.3%
memory IC11 5.67 5.62 -2.3%
lazy IC3 228.85 243.02 +6.2%
lazy IC5 103.21 101.11 -1.4%
lazy IC6 40.57 39.29 -2.8%
lazy IC9 287.69 317.81 +5.3%
lazy IC11 10.32 10.48 -0.3%

32-pair follow-up

Mode Query Main median ms Candidate median ms Paired change
lazy IC3 165.94 162.01 -2.0%
lazy IC9 218.71 212.36 -1.8%
Named and unnamed Tag/Tagclass, raw endpoint counts, and CSR-disabled timings

The Tag/Tagclass check compares sorted distinct Tag IDs to an independent traversal of stored SF1 relationship rows, including the nullable OPTIONAL MATCH row. The two wheels ran named and unnamed queries for the lowest- and highest-degree connected Tagclass. Each number is a median of eight executions after warmup.

Mode Seed Degree Depth Output rows Unnamed main ms Unnamed candidate ms Speedup
memory 46 2 2 9 6.27 1.80 3.48x
memory 46 2 3 88 6.13 1.69 3.62x
memory 182 5062 2 5061 8.54 2.64 3.23x
memory 182 5062 3 9901 9.55 3.50 2.73x
lazy 46 2 2 9 7.29 2.28 3.20x
lazy 46 2 3 88 8.06 2.37 3.40x
lazy 182 5062 2 5061 10.10 2.76 3.65x
lazy 182 5062 3 9901 11.61 3.28 3.54x

The raw knows traversal starts at Person 1131. It returns one endpoint row per path. Candidate counts and exact endpoint multiplicities matched the independent SF1 edge walk. Times are medians of 12 executions.

Mode Direction Depth Main rows Correct rows Main ms Candidate ms Change
memory out 2 3083 3083 0.78 0.60 -23.6%
memory out 3 86096 86096 3.13 1.71 -45.4%
memory both 2 5430 5430 0.89 0.54 -39.0%
memory both 3 438709 438709 13.34 7.77 -41.8%
lazy out 2 3083 3083 0.94 0.96 +1.6%
lazy out 3 86096 86096 2.72 2.31 -14.9%
lazy both 2 5430 5430 1.19 0.84 -29.6%
lazy both 3 438709 438709 14.37 10.52 -26.8%

Named-path results on SF1

The named paths construct the relationship inventory. The checks compared all returned Tag IDs against the same independent calculation as the unnamed paths. The table reports the measured inventory cost.

Mode Seed Depth Rows Main ms Candidate ms
memory 46 2 9 6.29 4.91
memory 46 3 88 6.18 4.54
memory 182 2 5061 9.30 6.91
memory 182 3 9901 12.11 10.09
lazy 46 2 9 7.10 6.49
lazy 46 3 88 7.87 6.81
lazy 182 2 5061 10.49 8.63
lazy 182 3 9901 13.49 10.54

CSR disabled

Mode Direction Plan Rows Main ms Candidate ms Change
memory both join 5430 4.63 4.59 -0.8%
memory both inventory 5430 39.03 36.38 -6.8%
memory out join 3083 3.50 3.27 -6.7%
memory out inventory 3083 36.51 35.37 -3.1%
lazy both join 5430 9.12 7.81 -14.4%
lazy both inventory 5430 43.62 39.16 -10.2%
lazy out join 3083 5.73 6.13 +7.0%
lazy out inventory 3083 33.45 38.23 +14.3%

With CSR disabled, the lazy directed join measured 6.13 ms versus 5.73 ms (+7.0%). The named inventory in that mode measured 38.23 ms versus 33.45 ms (+14.3%). The cause of those two differences remains unresolved. Both are medians of seven local calls.

Release wheel and native extension hashes
Wheel SHA-256 Native extension SHA-256
main 5e5647c498568fdaeeba10f6fe298f2cf2e4b45beed4ae4c37e6970268ef9c1c 0d32a59151ad00597989e601997cf22b93b94e46b048288b965dabe8e2032720
branch b2aa9ee2298c7d19b4cbf866c56e4abbcac2b481bf4f8ff8d2d35fe8db0020c4 d94da4b0b7f1ecd0a6d0c4f4b4365397b71ffae87fd0ff4993148c427a3866d3

Claude reviewed the implementation and the measurements against the maintainer’s criteria. That review prompted the additional paired measurements for lazy IC3 and IC9.

User impact

Counts can decrease when earlier versions reused an edge on a cycle, or increase when parallel edges give distinct valid trails. With string node IDs or comma-separated patterns, the variable-length uniqueness guarantee applies within each segment. Whole-path uniqueness across overlapping segments requires resolved endpoint labels and integer IDs.

Preserve edge identity across Arrow and pinned Lance scans, including namespace queries. Keep rows from the final CSR hop in small bounded batches. Add regressions for hidden-column collisions, cooperative work, and catalogs without stored IDs. Refs hyperdimensionalcomputingai#195.
Verify the terminal batch on the CSR execution plan and compare trails after edge appends, tombstones, and reopening stored indexes. Refs hyperdimensionalcomputingai#195.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T14:50:50.371521Z 7f070b2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f070b261c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/lance-csr/src/csr_traversal.rs Resolved
Comment thread crates/lance-csr/src/logical_plan.rs Resolved
Comment thread crates/lance-csr/src/logical_plan.rs Resolved

@prrao87 prrao87 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @MuddyBootsCode! The trail fix is the right behaviour. I reran both benchmark suites on my machine, plus our custom graph-benchmark suite, on release builds of main and this branch. My runs agreed within 1–2%, no query plans changed, and nothing regressed. The Tag/Tagclass and knows*3 speedups reproduce too, so we should be good despite your runs showing considerably more noise.

The three Codex findings from below are real regressions, and should be addressed before we merge.

Each one of the below works on main but breaks on this branch:

Case main This branch
Arrow relationship table with a user _rowaddr column (both values 0), chain 1→2→3, [:R*2..2] [3] [] with CSR on
X.id: Int32, Y.id: Int64, MATCH (:X {id: 1})-[:R*1..1]->(:Y)<-[:R]-(q:X) RETURN q.id [1, 2] planning error: path entities have conflicting Arrow types (CSR on and off)
Node IDs [1, 2, 3, 4, 4], MATCH (a:N {id:1})-[:R*1..1]->(b:N)-[:R]->(c:N) RETURN c.id [3] execution error: path values require unique node IDs (CSR on and off)

The first one comes from the CSR build reading any _rowaddr column as the edge identity. Numbering Arrow rows by position, ignoring that column, should fix it. The other two come from routing overlapping multi-segment patterns through the path-value inventory, which needs unique node IDs and property types that agree across labels. Please fall back to joins when the inventory can't take the input, and add a regression test for each case.

Suggested fixes:

  1. For Arrow tables, number CSR edges by row position and ignore any user _rowaddr column.
  2. Take the path-inventory route for overlapping segments only when the inventory can handle the input (unique node IDs, compatible property types). Otherwise fall back to the existing join plan, as main does.

With those fixed and a regression test for each case, this is good to merge.

Use physical row addresses only for Lance CSR input. For overlapping unnamed paths, check inventory schema compatibility and exact node key uniqueness before selecting the inventory. Verify keys on demand against the pinned snapshot and preserve ordinary expansion for incompatible inputs.
@prrao87

prrao87 commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

@MuddyBootsCode The three cases from the last review are fixed. Thanks for the tests.

However, there is another issue on a common graph pattern that came up as while reviewing this, that needs further investigation and a separate fix.

Problem

When a MATCH has a variable-length segment followed by another hop of the same relationship type, this PR now plans the whole pattern through the path inventory. The answers are correct (see below), but the inventory is built over the whole graph on every execution, so these queries are much slower than on main:

Query main This branch
Custom query on the SF1 dataset (not in either suite): MATCH (p:Person {ID: 1131})-[:knows*1..2]-(f:Person)-[:knows]-(g:Person) RETURN count(*) 3.6 ms 167 ms
Same shape on a random 2M-node, 4M-edge graph, CSR on 0.9 ms 1.2 s
Same shape on a random 2M-node, 4M-edge graph, CSR off 14 ms 1.4 s

The cost grows with the size of the graph, not with the number of paths the query explores: a query that starts from a single person still pays for the whole graph.

Why this pattern matters

This is the "friends of friends, then one more hop" shape: knows*1..2 (or any variable-length hop) followed by a hop of the same type. It's a natural way to write a social or lineage traversal, so users will hit it, even though none of the benchmark queries use it. We should have caught it in the first review; we found it this round by timing each shape the new planner rules reroute.

The routing itself fixes a real bug. On main, with a single edge between nodes 1 and 2, MATCH (a {id: 1})-[:R*1..1]-(b)-[:R]-(c) RETURN c.id returns [1], walking the same edge out and back, while the equivalent two fixed hops correctly return []. This branch returns [] for both, and the SF1 count drops from 444,109 to 438,679 for the same reason. We want to keep that result; it's only the cost that's the problem.

What to do

Enforce the same uniqueness rule without building the inventory: carry the edges each variable-length path used, and check the following hop's edge against them, so the cost scales with the paths explored rather than with the graph. The CSR walk and the join fallback already track edge identity within a segment after this PR, so that may be the place to extend it.

If that turns out to be a larger change than you'd like to take on here, please let me know and tag me on a follow-up issue and we can merge the PR without the cross-segment route and track the rest in that separate issue. Cheers!

Keep relationship occurrences across segment boundaries in indexed walks and bounded join branches. Batch terminal CSR candidates, seed from a bound or selective endpoint, and preserve compatibility fallbacks. Add planner, execution and scaling regressions for hyperdimensionalcomputingai#195.

@prrao87 prrao87 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MuddyBootsCode, thanks for the fixes! Sorry about the repeated back and forth, but this chained multi-hop path pattern with repeated relationships is quite a common we'd expect to see in some real use cases, so it's important that we get the intent aligned with the desired outcome. Hence the nitpicking below, but I believe they need to be fixed, and the code simplified a little bit to not exceed the scope of what we need to do at this point.

On reviewing the latest head (3a2d3a9), there's definitely one correctness bug, and I think the planning logic could be simplified before we merge.

Must fix: an unrelated duplicate node ID returns the wrong answer

Before planning an overlapping pattern as one trail, can_plan_shared_trail (logical_plan.rs) checks that the graph suits the path inventory: every node ID unique and shared property types compatible. Only the inventory needs those conditions; the seeded walk and the join chain don't. When the check fails, the planner skips the walk and the chain too, and the query falls back to separate expansions, which can walk the same edge twice.

Repro, on a graph with a single edge 1–2:

cfg = GraphConfigBuilder().node_table("N", "id").rel_table("R", "N", "N", "src", "dst").build()
data = {"N": pa.table({"id": [1, 2, 9, 9]}), "R": pa.table({"src": [1], "dst": [2]})}
CypherEngine(cfg, data, use_csr=True).execute(
    "MATCH (a:N {id: 1})-[:R*1..1]-(b:N)-[:R]-(c:N) RETURN c.id"
).to_pylist()
# [{'c.id': 1}] with CSR on and off; correct is [] (the result without the duplicate 9)

Please fix it together with the first item in the "should fix" section below:

  • In can_plan_shared_trail, delete the two path_inventory::property_fields(...) checks and the has_unique_node_ids check. The route should depend only on the pattern's shape, never on the data.
  • Add the repro above as a Python test expecting [], with CSR on and off. Keep it even after the refactor: it makes sure the result never depends on unrelated rows in the graph.

Should fix: simplify the planning logic

  1. Remove the inventory fallback for overlapping patterns, and the ID-uniqueness probe with it. The walk and the chain now cover the common shapes. The inventory is left with rare ones: a relationship variable on a segment, an unresolved boundary label, or more than 64 join branches without the CSR. Supporting them takes about 220 lines of async, cached, replanning code (InventoryProbe and NodeKey in source_catalog.rs, unique_inventory_ids and the graph_table replan in engine.rs, verify_inventory_keys in query.rs). Please plan those shapes as separate expansions, as main does, and delete the probe. If users run into these shapes, we can handle them in a follow-up.

  2. Merge the two CSR walkers. TrailWalk/TrailCursor (trail_walk.rs) does everything Traversal/TraversalCursor (csr_traversal.rs) does, with the same frames, edge-reuse check and last-hop batching. A single-segment trail is a Traversal. Please build the single-segment case as a one-segment TrailWalk and remove TraversalCursor, so a future fix only lands once. Please re-time the knows*1..2 IC queries afterwards, since one cursor streams single endpoints and the other returns groups.

  3. Merge the join builders. build_trail_paths is build_trail_chain with one segment, and trail_sequences repeats chain_sequences (alongside pattern_alternatives::alternation_sequences). Please route the single-segment case through build_trail_chain and remove the duplicates. One thing to carry over: trail_sequences handles relationship mappings without endpoint labels, which chain_sequences currently declines.

Together these should remove roughly 550 lines and leave one way to plan each shape. For rare patterns like the first one above, we can always revisit depending on user need in the future, so there's no need to address all of them right up front in this PR.

Thanks!

MuddyBootsCode and others added 3 commits November 25, 2026 10:23
Keep edge history across eligible anonymous segments independently of node ID uniqueness. Share one CSR cursor, one typed hop enumerator and one relational chain builder. Route residual shapes through ordinary expansion and cover label cycles, disconnected alternatives and custom occurrence IDs.
Reuse cursor buffers between input rows. Flush a single segment’s pending endpoints before yielding while preserving intermediate boundaries for multi-segment trails.
Resolve conflicts with named-path CSR walks (hyperdimensionalcomputingai#211) and all()/none()
pruning (hyperdimensionalcomputingai#215):

- path_ops.rs: keep both the trail builders and main's csr_route.
- logical_plan.rs: pass no relationship condition at the two shared-trail
  calls of plan_inventory_path, since only named paths have one.
- operators.md: describe main's two PathMatch routes, then trails across
  segments of an unnamed path in their own subsection.
- test_path_csr_walk.py: an unnamed multi-type segment now takes iterative
  CsrExpand. Rows still match the edge inventory, and on LDBC SF1 it runs
  in 0.5 ms instead of 2.8 ms (knows|studyAt*1..2) and 6 ms instead of
  140 ms (knows|workAt*1..3).

@prrao87 prrao87 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for sticking with this through several rounds! Everything we needed is in here now: the trail route now depends only on the pattern, the inventory fallback and ID probe are gone, and there's one CSR walker and one join chain. The result is much easier to follow.

I merged the latest main into your branch (cf2bdd2), so you don't need to do anything further. It conflicted with #211 and #215 in path_ops.rs and operators.md. Two other changes came with the merge:

Main's new CSR-walk test expected an unnamed multi-type pattern like knows|workAt*1..3 to use the named-path walk. Your iterative CsrExpand returns the same rows and is much faster on SF1 (140 ms → 6 ms), so the test now expects your route.
The two shared-trail calls to plan_inventory_path pass None for #215's new relationship-condition argument, since only named paths have one.

I checked the merge against a brute-force trail enumerator on 300 random graphs and patterns. Every case matches, apart from the documented relationship-variable shapes.

Approving and merging now. 🚀

@prrao87
prrao87 merged commit 05d17f3 into hyperdimensionalcomputingai:main Nov 26, 2026
9 checks passed
prrao87 added a commit that referenced this pull request Nov 26, 2026
Minor bump: #200 adds a weights argument to the Rust
CypherEngine::export_graph, and #198 changes the rows some
variable-length queries return.
@MuddyBootsCode

Copy link
Copy Markdown
Contributor Author

Zero worries about the back and forth lots to learn.

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.

Variable-length paths can use the same relationship twice

2 participants