You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR improves performance of writing big keys/values into BTreeMap that take several pages.
Now it preallocate overflow pages in advance, which helps in cases of allocating a single chunk of bytes, say 10 MB.
Improvement on write_chunks_btreemap_1 benchmark is -1.37% instructions.
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the performance of writing large keys/values into a BTreeMap by preallocating overflow pages, which helps avoid repeated page allocations. Key changes include:
Renaming and using a unified variable (position) in both read and write loops for clarity.
Adding a preallocation step for overflow pages in the NodeWriter.
Updating benchmark result YAMLs to reflect performance improvements.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File
Description
src/btreemap/node/io.rs
Refactored read/write loops and added batch allocation of overflow pages.
benchmarks/vec/canbench_results.yml
Updated benchmark metrics for vec operations.
benchmarks/compare/canbench_results.yml
Updated benchmark metrics for compare operations.
benchmarks/btreeset/canbench_results.yml
Updated benchmark metrics for btreeset operations.
benchmarks/btreemap/canbench_results.yml
Updated benchmark metrics for btreemap operations.
Comments suppressed due to low confidence (2)
src/btreemap/node/io.rs:243
Consider adding a clarifying comment about how 'end_offset' is determined and how compute_num_overflow_pages_needed handles edge cases, to help future maintainers understand the overflow preallocation logic.
compute_num_overflow_pages_needed(end_offset, self.page_size.get() as u64) as usize;
src/btreemap/node/io.rs:266
[nitpick] Verify that the transition from using 'bytes_written' to 'position' consistently preserves the intended semantics when processing segments of varying lengths.
match page_idx {
maksymar
changed the title
perf: TBD
perf: batch allocate overflow pages
Jun 30, 2025
maksymar
changed the title
perf: batch allocate overflow pages
perf: batch allocate overflow pages in BTreeMap
Jun 30, 2025
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
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 improves performance of writing big keys/values into BTreeMap that take several pages.
Now it preallocate overflow pages in advance, which helps in cases of allocating a single chunk of bytes, say 10 MB.
Improvement on
write_chunks_btreemap_1benchmark is -1.37% instructions.