Skip to content

merkle: avoid PageId clones and child computations on the hot seek path - #993

Draft
citizen-stig wants to merge 1 commit into
thrumdev:masterfrom
citizen-stig:nikolai/seek-fewer-page-id-clones
Draft

citizen-stig wants to merge 1 commit into
thrumdev:masterfrom
citizen-stig:nikolai/seek-fewer-page-id-clones

Conversation

@citizen-stig

@citizen-stig citizen-stig commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Three fewer PageId clones or computations per seek step:

  • continue_seek takes the page ID by value.
  • The child page ID is computed only when the child is elided.
  • The page walker checks depth() <= 1 instead of building parent_page_id() and comparing it with ROOT_PAGE_ID.

Benchmarks

base this PR Δ
finish on master 77.04 ± 0.67 ms 76.51 ± 1.01 ms −0.7%
finish on master + #979 + #987 66.12 ± 0.23 ms 65.48 ± 0.55 ms −1.0%

No clear gain on its own at either base. With #991, #992 and #994 on master, the four give −7.1% (77.04 → 71.55 ms). That is 0.6 ms more than #991 and #992 alone sum to, so this PR and #994 may add a little together. That is not verified.

Conflict: this conflicts with #979 in one hunk of merkle/page_walker.rs. The resolution keeps #979's shape with the depth() <= 1 condition.

finish_bench: an isolated Session::finish benchmark with the user-namespace access profile of a Sovereign SDK node (benchtop/src/bin/finish_bench.rs @ 3469d5c, not part of this PR). 50k–145k ReadThenWrite accesses per slot (68% updates with the prior value, 32% inserts), 36-byte values, BinaryHasher<Sha256>, rollback on, tree growing from 5.35M leaves, 10 warm-up + 20 measured slots from a restored seed DB. commit_concurrency 8 on all 16 CPUs of an AMD Ryzen 7 7700 (8 cores). Mean of 8 runs. Master is 6ee36d3. This PR, the three other small-commit PRs, and the same four on master + #979 + #987 were measured in one batch, with order rotated each round. Every run ends at the same root. Linux cargo test --workspace and cargo test -p nomt-core --features borsh,serde pass on this branch.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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