perf: optimize complex-type hash implementations#3140
Merged
mbutrovich merged 2 commits intoapache:mainfrom Jan 15, 2026
Merged
perf: optimize complex-type hash implementations#3140mbutrovich merged 2 commits intoapache:mainfrom
mbutrovich merged 2 commits intoapache:mainfrom
Conversation
Contributor
Author
|
@sqlbenchmark run micro CometHashExpressionBenchmark |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3140 +/- ##
============================================
+ Coverage 56.12% 59.86% +3.73%
- Complexity 976 1414 +438
============================================
Files 119 168 +49
Lines 11743 15579 +3836
Branches 2251 2588 +337
============================================
+ Hits 6591 9326 +2735
- Misses 4012 4944 +932
- Partials 1140 1309 +169 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Comet Microbenchmark Results: CometHashExpressionBenchmarkCommit: Benchmark ResultsAutomated benchmark run by dfbench |
Contributor
Author
|
Claude helped me summarize the benchmarks above compared to #3077 (comment)
I didn't see the win I hoped for in the non-complex-type scenarios. I wonder what I can figure out there, but I'll punt on that for now. We don't have benchmarks for maps so I don't have those numbers. |
This was referenced Jan 16, 2026
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?
Closes #.
Rationale for this change
PR #3077 added support for hashing complex types (arrays, structs, maps) but used a generic recursive approach that could add overhead:
slice(idx, 1)which creates a newArrayRef- this involves heap allocation and reference counting overheadmatch col.data_type()).iter_mut().zip().enumerate()which creates iterator adapter overheadWhat changes are included in this PR?
Changed from iterator chains to direct array indexing:
Applied to all 6 hash macros:
hash_array,hash_array_boolean,hash_array_primitive,hash_array_primitive_float,hash_array_small_decimal, hash_array_decimalAdded new
hash_list_primitive!macro with direct buffer access, eliminating per-element array slicing and recursive calls:Optimized types:
Fallback: Complex nested types still use the original recursive approach, which is appropriate for these less common cases.
How are these changes tested?
Existing tests.