perf: Reduce record batch memory accounting overhead - #24319
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #24319 +/- ##
==========================================
+ Coverage 81.13% 81.14% +0.01%
==========================================
Files 1112 1112
Lines 388220 388488 +268
Branches 388220 388488 +268
==========================================
+ Hits 314985 315244 +259
- Misses 54696 54701 +5
- Partials 18539 18543 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Extend the microbenchmark across row counts and List/Struct layouts. Exercise all legal run-end index types in the ArrayData parity test.
e584d8b to
890be61
Compare
|
Thanks @comphead — added in 890be61:
The updated A/B tables are in the PR description. The row-count cases stay essentially flat as expected for buffer traversal; measured speedups are 7.49–7.97x for four primitive columns, 9.39x for lists, and 8.86x for structs.
|
|
Thanks @ryux1 -- I'll check it out shortly |
|
run benchmark window_query_sql |
1 similar comment
|
run benchmark window_query_sql |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing perf/batch-memory-accounting (890be61) to 8c099dc (merge-base) diff Run configurationrun benchmark window_query_sqlResults will be posted here when complete File an issue against this benchmark runner |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing perf/batch-memory-accounting (890be61) to 8c099dc (merge-base) diff Run configurationrun benchmark window_query_sqlResults will be posted here when complete File an issue against this benchmark runner |
Clarify that the 16-entry threshold avoids allocations for small buffer sets while bounding inline storage and linear lookup. The threshold is a performance heuristic rather than a semantic limit.
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing perf/batch-memory-accounting (890be61) to 8c099dc (merge-base) diff Run configurationrun benchmark window_query_sqlCPU Details (lscpu)Details
Resource Usagewindow_query_sql — base (merge-base)
window_query_sql — branch
File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing perf/batch-memory-accounting (890be61) to 8c099dc (merge-base) diff Run configurationrun benchmark window_query_sqlCPU Details (lscpu)Details
Resource Usagewindow_query_sql — base (merge-base)
window_query_sql — branch
File an issue against this benchmark runner |
Which issue does this PR close?
Rationale for this change
Record batch memory accounting runs on hot execution paths. The current implementation materializes ArrayData for every array and allocates a hash set even for small batches, adding measurable overhead to queries that frequently update memory reservations.
What changes are included in this PR?
Criterion point estimates from
cargo bench -p datafusion-common --bench record_batch_memory, measured sequentially on upstreammainand this PR on the same machine:Column count (8,192 rows, Int64)
Row count (4 Int64 columns)
Array layout (4 columns, 8,192 rows)
Each list row contains two Int64 values. Each struct column contains two Int64 child fields.
Are these changes tested?
Yes.
cargo fmt --all -- --checkcargo clippy --all-targets --all-features -- -D warningscargo test -p datafusion-common utils::memory --lib(10 passed)RUST_BACKTRACE=1 cargo test --profile ci --exclude datafusion-examples --exclude datafusion-benchmarks --exclude datafusion-cli --workspace --lib --tests --bins --features avro,json,backtrace,extended_tests,recursive_protection,parquet_encryptionAre there any user-facing changes?
No API or behavior changes. This reduces CPU and allocation overhead in record batch memory accounting.
AI assistance: OpenAI Codex assisted with implementation and test execution. I reviewed the change and its behavior end to end.