Benchmark single-column GROUP BY: hash vs direct-indexed flat array#22479
Closed
nathanb9 wants to merge 5 commits into
Closed
Benchmark single-column GROUP BY: hash vs direct-indexed flat array#22479nathanb9 wants to merge 5 commits into
nathanb9 wants to merge 5 commits into
Conversation
return_type() is not implemented by all UDAFs (e.g. first_value, last_value). Use the universally-supported return_field() API to derive the return type for default_value computation.
approx_distinct is semantically COUNT(DISTINCT), so it returns 0 (not NULL) on empty input. Update the window_using_aggregates snapshot to reflect this and add is_nullable() -> false for schema consistency.
…lable, fix snapshot
…ingle-column GROUP BY Adds a direct-indexing GroupValues implementation for integer-typed GROUP BY columns with bounded value ranges, inspired by the ArrayMap used for perfect hash joins. Instead of hashing and probing a hash table, it computes `value - min` to index directly into a flat array. Includes a benchmark comparing hash-based vs flat approaches across varying group counts (10-100K) and densities (10%-100%), with both cold (full lifecycle) and warm (pre-populated, pure lookup) variants. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
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.
Summary
GroupValuesFlatPrimitive, a direct-indexingGroupValuesimplementation for integer GROUP BY columns with bounded value ranges (no hashing, O(1) array lookup viavalue - min)single_group_by_primitive) comparing hash-basedGroupValuesPrimitivevsGroupValuesFlatPrimitivesingle_group_byandrowmodules public for benchmark accessBenchmark design
Uses the same
iter_batched_refmethodology as the multi-column GROUP BY benchmark in #22322:intern()calls are measuredblack_boxprevents dead-code eliminationThree experiments:
Local results (Apple Silicon, release mode)
Related
ArrayMapinjoins/array_map.rs(perfect hash join, PR perfect hash join #19411)Test plan
cargo test -p datafusion-physical-plan --lib flat_primitive— 5 unit tests passcargo clippy -p datafusion-physical-plan --benches -- -D warnings— cleancargo bench -p datafusion-physical-plan --bench single_group_by_primitive— runs successfully🤖 Generated with Claude Code