Skip to content
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

Reclaim empty overflow slots in memory hash index #3438

Merged
merged 1 commit into from
May 9, 2024

Conversation

benjaminwinger
Copy link
Collaborator

@benjaminwinger benjaminwinger commented May 2, 2024

When splitting, move empty overflow slots into a global linked list and re-use them before allocating new slots.

I started working on this to try and simplify how deletions will work in the in memory hash index (needed to unify the hash index local storage for copies and inserts/deletions), as removing empty overflow slots from the end of the slot chains makes it easier to find the last entry in a slot without having to backtrack if the last slot is empty.
This ended up being a little more complicated than I expected, but for a hash index of 60 million consecutive integers it reduces memory use from the slots from roughly 2.28GB to 1.75GB, reducing the number of overflow slots by more than half, and it seems to slightly increase performance (presumably because it reduces the number of allocations).

Something similar could be done for disk slots (see last TODO in #2938 (comment)), the main difference being that disk slots may have gaps, but the gaps could be removed when splitting.

This avoids breaking the storage format by adding the new field (which is not used by the on-disk index) to the end of the hash index header.

@benjaminwinger benjaminwinger force-pushed the hash-index-reclaiming branch 2 times, most recently from 658ad60 to 3603c9e Compare May 3, 2024 14:47
src/storage/index/in_mem_hash_index.cpp Outdated Show resolved Hide resolved
When splitting, move empty overflow slots into a global linked list and re-use them before allocating new slots
@benjaminwinger benjaminwinger merged commit ea1e798 into master May 9, 2024
18 checks passed
@benjaminwinger benjaminwinger deleted the hash-index-reclaiming branch May 9, 2024 14:52
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.

None yet

2 participants