-
Notifications
You must be signed in to change notification settings - Fork 12
Update chaindb
to use a slab allocator for small size buffers.
#1070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
greg7mdp
wants to merge
21
commits into
release/2.0
Choose a base branch
from
gh_1049
base: release/2.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Note:start |
heifner
reviewed
Dec 16, 2024
Closed
chaindb
to use a slab allocator for small size buffers.
heifner
approved these changes
Apr 29, 2025
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.
Resolves #1049.
Now this integrates the changes from AntelopeIO/chainbase#54, which can be referred to for previous comments.
As the issue describes, the current chainbase does a lot of small buffer allocations directly through the bip allocator which hits the segment manager directly. Not only this is inefficient (the rbtree of free buffers need to be rebalanced for every alloc/free), it also has a higher memory overhead.
The slab allocators for small buffers (in the updated chainbase submodule) batch allocations of small buffers into larger blocks, reducing the fragmentattion within the shared memory segment, and providing better efficiency and a smaller memory footprint.
For comparison, here are some results comparing snapshot loading on my linux box (release build)
snapshot from Aug 11, 2024
snapshot from Sept 29, 2024
I also expect a slight performance increase for processing transactions, as the
_undo_stack
deque allocations used to go through the segment allocator as well (for blocks of 16undo_state
), and these allocations are now batched.