Skip to content

bench(shapes): measure type(r) on an untyped relationship - #249

Merged
prrao87 merged 1 commit into
hyperdimensionalcomputingai:mainfrom
MuddyBootsCode:codex/236-untyped-type-benchmark
Nov 29, 2026
Merged

prrao87 merged 1 commit into
hyperdimensionalcomputingai:mainfrom
MuddyBootsCode:codex/236-untyped-type-benchmark

Conversation

@MuddyBootsCode

Copy link
Copy Markdown
Contributor

Summary

Add the untyped type(r) benchmark requested in #236 after #235. It measures the same 200 starting accounts and returns the same endpoints as the existing one-hop pair, with the relationship type added to each row. On v0.16.0 the untyped form took 6.83× as long in memory and 16.16× as long with lazy Lance reads as the explicit type list. Both returned the same 2,885 rows.

Problem and why it matters

Our chain-of-title query asks which kind of relationship connects two known entities. The existing benchmark returns the endpoints alone. On the large fixture, both endpoint-only forms use CSR expansion. Adding type(r) changes the untyped plan even though the engine knows both endpoint labels.

Change

MATCH (a:Account)-[r]->(b:Account)
WHERE a.rank < 200
RETURN a.id, b.id, type(r) AS kind

The comparison query changes only [r] to [r:T|S]. Both use the existing full-row answer check, including duplicates. The tiny-graph test also obtains expected labels independently with two single-type matches, a literal label for each table, and CSR disabled.

On v0.16.0, the typed plan shows two CsrExpandExec branches. The untyped plan shows two PathMatchExec: endpoints csr walk branches. The typed case asserts CSR expansion. The untyped case leaves the operator open so the same benchmark can measure a future planner improvement.

Validation

The native engine for all measurements was the released v0.16.0 wheel, tagged at upstream 5160582. This patch changes the benchmark and its test only. Apple M5 Max, 128 GiB, macOS 27.0.1, Python 3.13, pylance 14.0.3, NumPy 2.5.4. The seed-0 large fixture has 200,000 accounts, 2,338,886 T edges and 200,000 S edges.

Storage Explicit [r:T|S] Untyped [r] Untyped / explicit
Memory 1.43 ms 9.77 ms 6.83×
Lazy Lance 2.31 ms 37.32 ms 16.16×

Each value is the mean of two run medians. Each new query ran 50 timed executions after warmup per run. The untyped lazy medians were 38.30 and 36.34 ms. These are two query forms on the same engine.

  • Ran python/benchmarks/shapes.py run --group untyped twice per storage mode. All 44 query executions across the four suite runs passed the harness checks. Reading the source Lance tables directly confirmed 2,685 T rows and 200 S rows, with the same full-row fingerprint in all eight new-case results (fbfaadcbe0c50829).
  • All three tests in python/python/tests/test_shape_benchmark.py passed. The tiny suite exercised every benchmark query in both modes. A local negative control forced both new queries to return the constant 'T' and confirmed that the independent check fails.
  • Compared all 49 pre-existing query definitions against upstream. All were identical. Ruff lint and formatting passed on both touched files.
All 11 queries in the measured group

Mean of the two run medians, in milliseconds.

Query Memory Lazy Lance
hop_typed 1.11 1.95
hop_untyped 1.17 1.88
hop_anonymous 1.07 2.41
two_hop_typed 3.28 5.07
two_hop_untyped 3.54 5.22
three_hop_typed 11.68 14.26
three_hop_untyped 11.85 14.27
mixed_typed 1.59 2.39
mixed_untyped 1.62 2.52
hop_type_typed 1.43 2.31
hop_type_untyped 9.77 37.32
Reproduce the measurements
shapes() {
  uv run --no-project --python 3.13 --with lance-csr==0.16.0 \
    --with pylance==14.0.3 --with numpy==2.5.4 \
    python python/benchmarks/shapes.py "$@"
}
shapes generate --size large --seed 0 --out ./shape-data
for mode in memory lazy lazy memory; do
  shapes run --data ./shape-data --mode "$mode" --group untyped \
    --label v0.16.0 --results ./shape-results
done
shapes report --results ./shape-results --base v0.16.0

User impact

The shape report gains a one-hop untyped/typed ratio for queries that return the relationship type. The separate unknown-endpoint control from #236 remains follow-up work.

Compare the single-hop wildcard with an explicit T|S match returning the
same endpoints and relationship type. Keep the typed CSR plan check and
let the untyped plan change as the planner improves. Check the typed
labels against an independent UNION ALL over the two edge tables.

Follow up on hyperdimensionalcomputingai#236.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 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-29T14:17:05.766103Z 44c2c98 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.

@MuddyBootsCode

Copy link
Copy Markdown
Contributor Author

When the query returns type(r) on v0.16.0, [r] takes about 6.8× as long in memory and 16.2× as long with lazy Lance reads as [r:T|S]. Both return the same 2,885 rows. The endpoint-only queries take about the same time, so the gap shows up when we ask for the relationship type. @prrao87, would you like me to investigate why the planner picks a different path here and report back in a separate issue?

@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.

LGTM!

@prrao87
prrao87 merged commit e326ba2 into hyperdimensionalcomputingai:main Nov 29, 2026
3 checks passed
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.

2 participants