8000 perf(engine): keep every query's stream in the allocator's thread cache (#721 follow-up) by adityamukho · Pull Request #726 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

perf(engine): keep every query's stream in the allocator's thread cache (#721 follow-up) - #726

Merged
adityamukho merged 4 commits into
v3from
fix/721-probes-alloc
Oct 24, 2026
Merged

adityamukho merged 4 commits into
v3from
fix/721-probes-alloc

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Found while measuring #551 PR 3. After #722 (#721), every small query took about 1 µs (5%) longer: point_entity 17.0 → 18.0 µs, attribute_value +4.8%, at every scale. Three-way alternation on one NUMA node (base 1096e6a, v3 just before #721 at ef6bc58, v3 now) shows v3 just before #721 level with base, so #721 alone causes it.

Cause

Fix

  • IdSpace::probes is Option<Box<Probes>>, made by the first value probe (probes_mut); reads go through probes(). release drops it.
  • Committed::shadow is None when no pending record decides a triple.
  • New test stream_fits_the_allocator_thread_cache (Linux glibc, 64-bit): size_of::<Stream>() <= 1032. The stream is now 888 bytes in release.

Measured (bench machine, 100K fixture, [:find ?a :where [:p8333 :age ?a]] × 200,000, 4 alternating rounds):

allocations / query bytes / query µs / query
v3 just before #721 (ef6bc58) 261 18,835 14.8–15.1
v3 now (cdba0c7) 262 19,067 15.7–16.6
this PR 261 18,835 15.3–15.8

The remaining ~3% is code layout from #721's scan rework (pending_live, consts, pending_records, push_facts are no longer inlined). That's under the 5% investigation threshold, so it's left as is.

Tests: bench machine, cargo test 1,702 passed / 12 ignored, --features test-hooks 1,718 / 13, no failures. Codex review: no correctness findings; its one note (the size test assumes glibc) is addressed by gating on target_env = "gnu".

Docs: CHANGELOG #721 entry, CLAUDE.md and TEST_COVERAGE counts. No docs-site change (internal).

🤖 Generated with Claude Code

https://claude.ai/code/session_0169pNQsLcCEn48te9X9WuZW

adityamukho and others added 4 commits October 24, 2026 02:02
…allocator's thread cache (#721)

#721 put Probes (176 bytes) inline in IdSpace, growing the boxed Stream
of every query from 880 to 1,056 bytes, past glibc's 1,032-byte tcache
limit: each query's stream went through the locked bins, about 1 us
(5%) on a point query. Probes is now made on first use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0169pNQsLcCEn48te9X9WuZW
…ord (#721)

#721 wrapped every committed scan's shadow set in an Arc, one more
allocation per scan even when no pending record decides a triple.
It is now None when empty: a point query allocates what it did
before #721 (261 allocations, 18,835 bytes at 100K facts).

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

Codecov Report

❌ Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/query/engine/recursive.rs 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit 7402f19 into v3 Oct 24, 2026
19 checks passed
@adityamukho
adityamukho deleted the fix/721-probes-alloc branch October 24, 2026 02:22
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