perf: use node cache in insert and remove operations for BTreeMap#426
Open
perf: use node cache in insert and remove operations for BTreeMap#426
Conversation
|
|
|
|
|
|
Contributor
Author
Contributor
Author
Contributor
Author
Contributor
Author
Contributor
Author
Contributor
Author
|
Comparing to base commit 04fe601 before all cache optimizations. |
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.







This PR uses node cache for write operations like
insertandremove.Extends the node cache (previously read-only) to
insert,remove,pop_first, andpop_last. Nodes are taken from cache instead of stable memory when descending the tree. Unmodified parent nodes are returned to cache on the happy path. Modified nodes go throughsave_nodewhich invalidates their cache slot. Adepthparameter is threaded through recursive helpers to inform the cache eviction policy. Siblings during rebalancing bypass the cache since they are always modified.131 improvements vs 13 regressions across 252 benchmarks.
insertimproves 25-30%pop_first/pop_last~20%get_then_insert25-31%Regressions are in
first/last_key_value(+2-5%) — read-only paths not on changed code paths, caused by write operations filling pinned depth 0-1 cache slots that read traversals also need.Pop improvements are smaller than insert because single-pass pop (#417) already eliminates redundant traversals — cache only helps by reusing root and near-root nodes across consecutive calls.
Comparing to base commit 04fe601 before all cache optimizations.
