Optimize Hash Index slot splitting #3325
Merged
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.
As referenced in #3298 , the
rehashSlots
method (now merged withsplitSlot
intosplitSlots
) had not been optimized for bulk splitting, which was bottlenecking the performance of multiple copies. This removes that bottleneck, improving the performance of the second copy to ~2.8x the cost of the first (when they are the same size that is).It was necessary to remove the locking on the disk array
WriteIterator
so that multiple can be used on different pages at the same time (the original slot and new slot in this case). Overflow slots are more complicated, and since we can generally assume there are relatively few of them I made it cache new overflow slots in memory and append them at the end so that it's not necessary to juggle two different slot pointers and iterators which can't overlap at the risk of invalidating the other slot pointer and needing to track which iterator is used for which slot at any given time.To avoid a similar issue with primary slots, I made the minimum number of primary slots allocated the first time be 16 (one full page of slots) so that the original slot and the new slot are never on the same page when splitting.