perf: lazily size RegionTracker bitmaps to reduce memory overhead#1111
Merged
cberner merged 3 commits intocberner:masterfrom Mar 18, 2026
Merged
perf: lazily size RegionTracker bitmaps to reduce memory overhead#1111cberner merged 3 commits intocberner:masterfrom
cberner merged 3 commits intocberner:masterfrom
Conversation
df28a77 to
aabb047
Compare
RegionTracker pre-allocated 21 BtreeBitmaps at MAX_REGIONS (1,048,576) capacity. Start at the actual region count instead with the tree pre-padded to full height so resize() never needs to insert new levels.
aabb047 to
2c5be19
Compare
cberner
reviewed
Mar 18, 2026
Move height padding from BtreeBitmap::new() into a new_padded() method so buddy allocators are not affected. Only RegionTracker calls new_padded() with MAX_PAGE_INDEX+1 as the max capacity.
cberner
requested changes
Mar 18, 2026
cberner
approved these changes
Mar 18, 2026
Owner
|
Merged. Thanks! |
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.
Summary
RegionTracker::new()allocates bitmap capacity matching the actual region count instead ofMAX_REGIONS(1,048,576)BtreeBitmap::new_padded()method soresize()stays simple — just grows each level'sVec, no structural changes neededRegionTrackerusesnew_padded(); buddy allocators continue usingnew()and are unaffectedMAX_REGIONSconstantCommit 592c2f8 changed the bitmap capacity from
(regions, regions)to(regions, MAX_REGIONS)to avoid tree height changes duringresize(). This trades ~2.7 MB of RAM for simpler resize logic — 21 bitmaps × 128 KB leaf allocation even for empty databases.This PR keeps
resize()simple by pre-padding only theRegionTrackerbitmaps to full height at construction. Extra levels cost ~36 bytes each (single-entryU64GroupedBitmap), so the total overhead for padding is ~1.5 KB across all 21 bitmaps.Measured impact
Minimal create → insert → query,
set_cache_size(0), release optimizations: