fix: account for initial hash table allocation in ArrowBytesMap/ArrowBytesViewMap#21249
Open
yashrb24 wants to merge 1 commit intoapache:mainfrom
Open
fix: account for initial hash table allocation in ArrowBytesMap/ArrowBytesViewMap#21249yashrb24 wants to merge 1 commit intoapache:mainfrom
yashrb24 wants to merge 1 commit intoapache:mainfrom
Conversation
03429d9 to
0673088
Compare
…BytesViewMap ArrowBytesMap and ArrowBytesViewMap allocate their hash tables with HashTable::with_capacity(INITIAL_MAP_CAPACITY) but initialize map_size to 0. insert_accounted only tracks incremental growth beyond the current capacity, so the initial allocation is never counted and size() understates memory usage until the first resize. Initialize map_size with map.allocation_size() in both constructors, and add regression tests covering both map types. Closes apache#21248.
fddbaf6 to
22b7e1a
Compare
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.
Which issue does this PR close?
Rationale for this change
ArrowBytesMapandArrowBytesViewMapallocate their hash tables withHashTable::with_capacity(INITIAL_MAP_CAPACITY)but initializemap_sizeto0. Theinsert_accountedmethod only tracks incremental growth beyond the current capacity, so the initial allocation fromwith_capacityis never counted.size()understates memory usage until the first resize.What changes are included in this PR?
Initialize
map_sizewithmap.allocation_size()in bothArrowBytesMap::newandArrowBytesViewMap::newto capture the pre-allocated memory.Are these changes tested?
The change is a one-line init fix. Existing tests cover the
size()method behavior.Are there any user-facing changes?
No API changes.
size()now returns the memory estimate that includes the initial hash table allocation.