Skip to content

perf(query): cache literal keyword entity resolutions (#774) - #788

Merged
adityamukho merged 1 commit into
v3from
perf/774-expression-keywords
Oct 29, 2026
Merged

adityamukho merged 1 commit into
v3from
perf/774-expression-keywords

Conversation

@adityamukho

@adityamukho adityamukho commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Queries such as [:find ?f :where [?f :name ?n] [(= ?f :p5)]] resolved the same literal keyword once per input row. Resolve literals when each filter/binding operator is built and reuse them across rows and rewinds. The immutable cache is bounded by expression literals, including nested expressions and substituted prepared slots; dynamic operands never enlarge it. Equality semantics, public APIs, dependencies and storage formats are unchanged.

Measurement preceded implementation. On idle, pinned benchmark runs at 100K and 1M facts, four socket-swapped pairs per shape show 9.0–11.0% lower latency for named-keyword =/!= in both operand orders. The report retains UUID-keyword controls, scan/join guards, and a 20-pair point-query repeat. The final comparison uses current v3 at 5f8073250; the report separately retains the measurements gathered before implementation. This is not a general-query speedup claim. Expression metadata, like parsed query text, remains outside the query data-memory meter.

Validation: the regression counter failed before the change (8 → 2,048 conversions as rows increased) and passes afterward across plain/nested/binding/negation/disjunction/rule expressions. Full default suite: 1,989 passed, 17 ignored. Targeted test-hooks equality/plan-independence suites: 31 passed. Strict all-feature clippy and formatting pass. Prepared keyword slots are alternated across executions, including checkpoint/reopen tests.

Raw measurements, lockfile, reproduction driver and limitations are in docs/benchmarks/774-expression-keywords.md. Repository status/test documentation is synchronized. Companion docs-site PR #85 documents the v3-only behavior; its build passed across 13 versions and 368 pages.

Fixes #774. Targets v3; no v2.x performance backport.

Rebased onto #723. A compact literal table keeps the release binary at 1,263,016 bytes, within the unchanged 1,263,616-byte cap. The full default suite and targeted test-hooks suites, lint and formatting were rerun after rebasing.

@adityamukho
adityamukho force-pushed the perf/774-expression-keywords branch from 17b6a56 to 04d0294 Compare October 29, 2026 04:11
@codecov

codecov Bot commented Oct 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.70115% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/query/datalog/executor.rs 95.23% 0 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho marked this pull request as ready for review October 29, 2026 04:23
@adityamukho
adityamukho merged commit c2e862f into v3 Oct 29, 2026
20 checks passed
@adityamukho
adityamukho deleted the perf/774-expression-keywords branch October 29, 2026 04:24
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.

1 participant