Repository navigation
fix: use HashTable::allocation_size() in GroupValuesColumn::size() - #26093
Draft
mohitgurav20 wants to merge 1 commit into
Draft
mohitgurav20 wants to merge 1 commit into
mohitgurav20 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #26093 +/- ##
==========================================
+ Coverage 82.80% 82.82% +0.01%
==========================================
Files 1149 1149
Lines 452213 452785 +572
Branches 452213 452785 +572
==========================================
+ Hits 374473 375029 +556
- Misses 54945 54957 +12
- Partials 22795 22799 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
mohitgurav20
force-pushed
the
fix/exact-hashtable-accounting-group-values-column
branch
from
October 25, 2026 09:54
e27ed80 to
4fea79e
Compare
Fixes apache#25736 The previous implementation tracked map memory via a map_size: usize field that was updated incrementally using insert_accounted. That approach charges only the entry-capacity portion of the hashbrown allocation, silently omitting control bytes and trailing layout. The resulting GroupValues::size() underreports the true retained memory, particularly for small or recently grown tables. This commit replaces the approximate accounting with a direct call to HashTable::allocation_size(), which reports the complete allocation as observed by the allocator. This is the same approach already used by ArrowBytesMap::size() in physical-expr-common. Changes: - Remove the map_size: usize field and all insert_accounted call sites that maintained it; use insert_unique (the plain hashbrown insert) instead. - Remove the now-unused HashTableAllocExt import from the production path (the test module retains what it still needs). - Remove the size_of import that was only used in the deleted clear_shrink map_size update. - Update GroupValuesColumn::size() to use self.map.allocation_size(). - Add four focused unit tests covering the acceptance criteria from the issue: map growth accounting, forced-collision chain independence, retained capacity after partial emit, and correct reuse after full emit.
mohitgurav20
force-pushed
the
fix/exact-hashtable-accounting-group-values-column
branch
from
October 25, 2026 10:02
4fea79e to
8d97aa1
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?
GroupValuesColumn#25736Rationale for this change
GroupValuesColumnstores its hash map as aHashTable<(u64, GroupIndexView)>,but
size()was computing the map's contribution using a hand-maintainedmap_sizefield — incremented viainsert_accountedon every insert.That only accounts for the raw entry storage, not hashbrown's internal
control bytes or trailing layout padding.
The result:
GroupValues::size()quietly underreports real memory,especially right after a table growth. This weakens memory-pool
enforcement and spill decisions.
ArrowBytesMapalready solves this correctly withHashTable::allocation_size().This PR brings
GroupValuesColumnin line with that (same approach as merged #25750 forGroupValuesRowsand #25825 forGroupValuesPrimitive).What changes are included in this PR?
Only
datafusion/physical-plan/src/aggregates/group_values/multi_group_by/mod.rsis touched.map_size: usizefield and everyinsert_accountedcall that maintained it.insert_accountedwithinsert_unique(hashbrown's plain insert) — no behavioural change, just stops threading an accumulator through.GroupValuesColumn::size()now callsself.map.allocation_size()directly, matchingArrowBytesMap::size().group_index_lists,emit_group_index_list_buffer,vectorized_operation_buffers,hashes_buffer, andsize_of::<Self>().HashTableAllocExtimports.What is the testing strategy for this PR?
Four focused unit tests added, one per acceptance criterion from the issue:
map_allocation_size_included_in_size_after_growthsize()covers the fullallocation_size()collision_chain_size_is_separate_from_map_allocationgroup_index_listsare tracked independentlysize_reflects_retained_capacity_after_partial_emitEmitTo::Firstdoesn't shrink the map allocation — retained capacity stays chargedreuse_after_full_emit_produces_correct_groupssize()stays accurateAll 122 tests in
aggregates::group_values::multi_group_bypass locally.Are there any user-facing changes?
No. This is a memory-accounting fix only. Group values, group IDs, and query
results are completely unchanged.