Skip to content

chore: add dynamic stash buckets #5258

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

chore: add dynamic stash buckets #5258

wants to merge 1 commit into from

Conversation

romange
Copy link
Collaborator

@romange romange commented Jun 9, 2025

Before: our Dash segments contained both regular and stash buckets. Each segment was allocated in one shot.
The the segment parameters was carefully chosen to be "allocator friendly" so that segment size was very close to what mimalloc actually allocates a block with size close to the segment size. This indeed has a good memory locality.

However when a segment is split, the occupancy rate of two new segments drops to 47-50% which causes memory spikes for small value workloads.

This change alters the structure of the segment. Now its stash buckets will be allocated separately and lazily when an item can not be inserted into its home buckets. When a segment is split, its stash buckets will be most likely deallocated. So for example, a 56+4 bucket segment will be split into two 56 bucket segments, so the occupancy rate of each one of them will at ~53.5% percent. Moreover, we will be able to use more stash buckets in the future to be able reach near 100% occupancy rate because now the stash bucket count can be chosen separately without affecting the block size of the "stripped" segment.

@romange romange force-pushed the Pr5 branch 8 times, most recently from bc56305 to d75f1be Compare June 12, 2025 05:32
Before: our Dash segments contained both regular and stash buckets.
Each segment was allocated in one shot.
The the segment parameters was carefully chosen to be "allocator friendly" so that
segment size was very close to what mimalloc actually allocates a block with size close to
the segment size. This indeed has a good memory locality.

However when a segment is split, the occupancy rate of two new segments drops to 47-50%
which causes memory spikes for small value workloads.

This change alters the structure of the segment. Now its stash buckets will be allocated separately
and lazily when an item can not be inserted into its home buckets. When a segment is split,
its stash buckets will be most likely deallocated. So for example, a 56+4 bucket segment will be split into
two 56 bucket segments, so the occupancy rate of each one of them will at ~53.5% percent.
Moreover, we will be able to use more stash buckets in the future to be able reach near 100% occupancy rate
because now the stash bucket count can be chosen separately without affecting the block size of the "stripped" segment.

Signed-off-by: Roman Gershman <[email protected]>
@romange romange added this to the v1.32 milestone Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant