-
Notifications
You must be signed in to change notification settings - Fork 272
perf: optimize native shuffle struct field processing with field-major order #3224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Optimize struct field processing in native shuffle by using field-major instead of row-major order. This moves type dispatch from O(rows × fields) to O(fields), eliminating per-row type matching overhead. Previously, for each row we iterated over all fields and called `append_field()` which did a type match for EVERY field in EVERY row. For a struct with N fields and M rows, that's N×M type matches. The new approach: 1. First pass: Loop over rows, build struct validity 2. Second pass: For each field, get typed builder once, then process all rows for that field This keeps type dispatch at O(fields) instead of O(rows × fields). For complex nested types (struct, list, map), falls back to existing `append_field` since they have their own recursive processing logic. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
@sqlbenchmark run tpch |
Add a Criterion benchmark to measure the performance of struct column processing in native shuffle. Tests various struct sizes (5, 10, 20 fields) and row counts (1K, 10K rows). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3224 +/- ##
============================================
+ Coverage 56.12% 60.02% +3.89%
- Complexity 976 1429 +453
============================================
Files 119 170 +51
Lines 11743 15746 +4003
Branches 2251 2602 +351
============================================
+ Hits 6591 9451 +2860
- Misses 4012 4976 +964
- Partials 1140 1319 +179 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Comet TPC-H Benchmark ResultsCommit: Query Times
Total Time: 307.94 seconds Spark Configuration
Automated benchmark run by dfbench |
Comet TPC-H Benchmark ResultsCommit: Query Times
Total Time: 321.87 seconds Spark Configuration
Automated benchmark run by dfbench |
Summary
Optimizes struct field processing in native shuffle by using field-major instead of row-major order. This moves type dispatch from O(rows × fields) to O(fields), eliminating per-row type matching overhead.
The problem:
Previously, for each row we iterated over all fields and called
append_field()which did a type match for EVERY field in EVERY row. For a struct with N fields and M rows, that's N×M type matches where the types never change.The solution:
Field-major processing with two passes:
This reduces type dispatch from O(rows × fields) to O(fields).
For complex nested types (struct, list, map), falls back to existing
append_fieldsince they have their own recursive processing logic.Benchmark Results
Benchmark for converting Spark UnsafeRow with struct columns to Arrow arrays:
The optimization shows 1.2x-1.6x speedup, with larger benefits for:
Test plan
native/core/benches/struct_conversion.rs)🤖 Generated with Claude Code