optimize(LargeSmtForest): reduce repeated history scans in historical open#971
Merged
huitseeker merged 4 commits into0xMiden:nextfrom Apr 18, 2026
Merged
optimize(LargeSmtForest): reduce repeated history scans in historical open#971huitseeker merged 4 commits into0xMiden:nextfrom
huitseeker merged 4 commits into0xMiden:nextfrom
Conversation
iamrecursion
approved these changes
Apr 17, 2026
Collaborator
There was a problem hiding this comment.
This looks generally good to me. I can't see any obvious way that we could speed it up even more, so I'm inclined to say that this is good. Correctness obviously takes precedence over speed, and this is very close to the performance of the slightly buggy version.
Please do add a changelog entry for this!
huitseeker
approved these changes
Apr 18, 2026
Collaborator
huitseeker
left a comment
There was a problem hiding this comment.
Lovely, thanks @AlexWaker !
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #923.
This change reduces repeated scans of the historical change set during a single historical LargeSmtForest::open() query.
The implementation does a single pass over
view.changed_keys(), collects the entries relevant to the queried leaf and the deepest sibling leaf, and then reuses those prefiltered changes in both leaf reconstruction and path reconstruction. The intent is to reduce repeated work on the historical open path without changing the current correctness semantics.I reran the relevant large_smt_forest query benchmarks locally and compared this change against a clean baseline worktree on the same machine. To avoid over-interpreting Criterion's saved baseline state, I did not rely on the change line in the Criterion output. Instead, I compared the medians directly from the time triplets across repeated runs.
For the focused large_smt_forest_persistent_open_historical_tree benchmark, I ran 3 full rounds on each side. The results were effectively tied:
Average median:
That is approximately 0.525% faster on average for this change. Given that the changes in #886 was about 1.5% slower, and this change recovers about 0.5%, the net performance overhead is reduced to under 1%.
Do you think this improvement is acceptable, or should we try a more aggressive approach? @iamrecursion