Skip to content

core: compute TriePosition::page_id from path bytes directly - #992

Open
citizen-stig wants to merge 1 commit into
thrumdev:masterfrom
citizen-stig:nikolai/page-id-from-path-bytes
Open

citizen-stig wants to merge 1 commit into
thrumdev:masterfrom
citizen-stig:nikolai/page-id-from-path-bytes

Conversation

@citizen-stig

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

Copy link
Copy Markdown
Contributor

What

TriePosition::page_id builds the page path directly from the position's path bytes: one 6-bit child index per full page, read from a big-endian u16 window. Before, it walked from the root with ChildPageIndex::new and PageId::child_page_id once per page. A new test compares it with the old walk for depths 1–256 on four bit patterns.

Why

page_id is called on the seek and page-walker paths for every key.

Benchmarks

master this PR Δ
finish 77.04 ± 0.67 ms 75.33 ± 0.83 ms −2.2%
into_overlay 53.78 ms 54.46 ms unchanged

It doesn't need any open PR. On master + #979 + #987: finish 66.12 ± 0.23 → 65.75 ± 0.38 ms (−0.6%). Together with #991, #993 and #994 it gives −7.1% on master.

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