-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add microbenchmark for spilling with compression #16512
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
To run bench, Results
|
As expected, although If there are other interesting directions for benchmarking such as measuring write and read times separately, or isolating compression and decompression overhead, or testing on different data types, I’d love to hear suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the micro-benches 💯 It's great to know these specific numbers.
Suggestion for this PR
To make the bench result easier to interpret, I suggest to print the bandwidth (calculated as raw-batch-size/time *2):
This way we can compare it with the typical compression bandwidth, then figure out if there are any room to optimize the speed in our implementation.
Case | Compression | Time (ms) | Memory (MB) | Disk (MB) | Compression Ratio | Bandwidth (MB/s) |
---|---|---|---|---|---|---|
Q2 | Uncompressed | 51.521 | 9.4 | 9.5 | 0.990 | ~400MB/s |
For potential future optimizations:
(I set the number of batches to 1000 manually, to make the dataset larger than cache)
On my machine, the bandwidth is roughly:
plain: 2GB/s
lz4: 600MB/s
zstd: 270MB/s
The takeaway for this result is: since plain encoding is a very simple operation that don't require much computation, its bandwidth should be close to disk bandwidth (~5GB/s on my machine), the result shows that there might be some room to make the codec faster?
I'm not sure the bandwidth for compressions are ideal, I'll try to find out later.
.with_precision_and_scale(15, 2) | ||
.unwrap(); | ||
|
||
for _ in 0..8192 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make this 8192
a global variable or function arg
// using realistic input data inspired by TPC-H aggregate spill scenarios. | ||
// | ||
// This function prepares synthetic RecordBatches that mimic the schema and distribution | ||
// of intermediate aggregate results from representative TPC-H queries (Q2, Q16, Q20) and sort-tpch Q10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can also copy the schemas of each workload in implementation comments to here.
let num_batches = 50; | ||
|
||
// Q2 [Int64, Decimal128] | ||
let (schema, batches) = create_q2_like_batches(50); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let (schema, batches) = create_q2_like_batches(50); | |
let (schema, batches) = create_q2_like_batches(num_batches); |
and same for the below two functions
Which issue does this PR close?
What changes are included in this PR?
This pr adds some microbenchmarks to compare performance characteristics between different compression codecs. It generates 50 RecordBatch for each case, and run both write & read. It manually prints out compression ratio (mem_bytes / disk_bytes) after each run.
To make benchmark more realistic, this pr generates
RecordBatches
that resemble the data it spills onAggregateExec
(tpc-h) andSortExec
(sort-tpch). It covers both thin batch consists of primitive arrays and wide batches with complex data type.Rationale for this change
Benchmark Case Overview
Below are schema of RecordBatch & original query for each benchmark case.
Are these changes tested?
Are there any user-facing changes?