8000 feat(query): every build reorders; the wasm feature is a no-op (+ #606) by adityamukho · Pull Request #607 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

feat(query): every build reorders; the wasm feature is a no-op (+ #606) - #607

Merged
adityamukho merged 1 commit into
v3from
feat/reorder-everywhere
Oct 15, 2026
Merged

adityamukho merged 1 commit into
v3from
feat/reorder-everywhere

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

PR 3 of 3 of docs/superpowers/plans/2026-10-15-594-596-plan-independence.md (steps 14–17, decision 10), plus #606, which the plan-independence test found while the gates were being removed. #606 is closed by hand after merge.

What changes

  • Every build reorders. optimizer::reorder() is true except while the test-only switch is off. The wasm Cargo feature no longer keeps clauses in source order or turns off the perf: short-circuit or/or-join branch evaluation using cost model #250 or short-circuits, and the engine's hash-join build side is the cost choice everywhere. The feature stays in Cargo.toml, marked deprecated with no effect, so builds that name it still resolve. No first-party build enabled it: minigraf-wasm uses browser, and wasm.yml builds wasm32 without it.
  • A :db/valid-at pattern that runs first gives its entity variable's keyword-or-ref kind #606. Binders::pattern ranks a pseudo-attribute pattern after every real one. A :db/valid-at pattern that runs first no longer gives its entity variable the keyword-or-ref kind; the first real pattern in the text does. Rows and counts are unchanged.
  • Tests. The optimizer unit tests, three disjunction_test short-circuit tests, join_rules_test::pseudo_attribute_pattern_never_replaces_a_value and an engine planner assertion lose their wasm gates. The plan-independence matrix gains two :db/valid-at-first shapes, which failed before the Binders change. The first uses a fixed :valid-at, because by default ?t is each query's "now".

Checks

cargo test 1534 (1524 passed, 10 ignored). --features wasm now runs the same 1524 tests; --features test-oracle passes. Clippy is clean with --all-features, default, wasm, test-oracle, wasm32 browser and wasm32-wasip1. Codex review: no findings. The #394 envelope with --features wasm (v3 vs this branch, 100K/1M) is running on the bench machine; results will follow in a comment.

Docs

CHANGELOG has two Breaking-changes entries (#606, wasm no-op). CLAUDE.md and TEST_COVERAGE are updated. Docs site: project-minigraf/minigraf-docs PR (use-cases.md and architecture.md wasm notes, join rules). The older optimizer specs and plans are frozen records and are left unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HyLscCUuJ1GQpdAeX79EdR

The wasm Cargo feature kept clauses in source order and turned off the
#250 or short-circuits. With every answer independent of the plan (#594,
#596) it only made queries slower, and no first-party build enabled it.
optimizer::reorder() is now true outside the test switch; the feature
stays declared, deprecated and without effect. The optimizer, engine,
disjunction and join-rules tests lose their wasm gates.

Also #606: a pseudo-attribute pattern never gives a variable its value
(Binders ranks it after every real pattern), so a :db/valid-at pattern
that runs first no longer decides keyword or ref. The plan-independence
matrix gains the shape (with a fixed :valid-at: by default ?t is each
query's now).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HyLscCUuJ1GQpdAeX79EdR
@codecov
codecov Bot commented Oct 15, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit e078e46 into v3 Oct 15, 2026
25 checks passed
@adityamukho
adityamukho deleted the feat/reorder-everywhere branch October 15, 2026 06:40
@adityamukho
Copy link
Copy Markdown
Collaborator Author

#394 envelope with --features wasm, origin/v3 (d689374, source order) vs this PR (reorders), 100K and 1M facts, two alternating runs each, pinned to one NUMA node on an idle machine. p50 latency:

Shape Scale --features wasm before (run 1 / 2) after (run 1 / 2) peak RSS before / after
point_entity 100k 17 µs / 17 µs 26 µs / 26 µs 3 / 3 MiB
attribute_value 100k 26 µs / 26 µs 26 µs / 26 µs 3 / 3 MiB
attribute_scan 100k 23.0 ms / 22.9 ms 23.9 ms / 23.1 ms 5 / 5 MiB
join_2 100k 53 µs / 54 µs 54 µs / 56 µs 3 / 3 MiB
join_3_selective 100k 10.4 ms / 10.7 ms 10.5 ms / 10.5 ms 6 / 6 MiB
join_3_scan 100k 279.3 ms / 279.5 ms 42.9 ms / 41.5 ms 13 / 14 MiB
join_2_pseudo 100k 43 µs / 61 µs 62 µs / 43 µs 3 / 3 MiB
recursive_ancestors 100k 2.74 s / 2.74 s 2.88 s / 2.75 s 252 / 253 MiB
as_of 100k 28 µs / 27 µs 28 µs / 28 µs 3 / 3 MiB
valid_at 100k 19 µs / 19 µs 28 µs / 19 µs 3 / 3 MiB
count_grouped 100k 32.2 ms / 32.2 ms 34.2 ms / 32.4 ms 19 / 19 MiB
hot_current 100k 304 µs / 325 µs 347 µs / 326 µs 3 / 3 MiB
hot_as_of 100k 319 µs / 310 µs 323 µs / 311 µs 3 / 3 MiB
point_entity 1m 26 µs / 26 µs 26 µs / 26 µs 3 / 3 MiB
attribute_value 1m 23 µs / 26 µs 24 µs / 23 µs 3 / 3 MiB
attribute_scan 1m 244.3 ms / 244.0 ms 251.8 ms / 245.5 ms 6 / 7 MiB
join_2 1m 36 µs / 51 µs 51 µs / 52 µs 3 / 3 MiB
join_3_selective 1m 145.0 ms / 145.3 ms 150.7 ms / 145.9 ms 14 / 14 MiB
join_3_scan 1m 3.61 s / 3.60 s 1.13 s / 1.12 s 38 / 44 MiB
join_2_pseudo 1m 61 µs / 61 µs 61 µs / 61 µs 3 / 3 MiB
recursive_ancestors 1m 44.16 s / 44.25 s 44.40 s / 44.49 s 2663 / 2556 MiB
as_of 1m 25 µs / 25 µs 25 µs / 17 µs 3 / 3 MiB
valid_at 1m 29 µs / 29 µs 29 µs / 29 µs 3 / 3 MiB
count_grouped 1m 443.0 ms / 445.6 ms 447.8 ms / 447.8 ms 123 / 134 MiB
hot_current 1m 322 µs / 325 µs 324 µs / 302 µs 3 / 3 MiB
hot_as_of 1m 313 µs / 296 µs 314 µs / 301 µs 3 / 3 MiB

join_3_scan ([?e :follows ?f] [?f :group 7] [?f :name ?n]) is 3.2× faster at 1M and 6.6× at 100K, because the selective :group 7 pattern now runs first. The other shapes are the same within noise: point_entity at 100K switches between about 17 and 26 µs across runs on both sides, as in the #602 A/B.

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

0