ding-young opened a new pull request, #16535:
URL: https://github.com/apache/datafusion/pull/16535
## Which issue does this PR close?
Related to #16367
## Rationale for this change
Previously, the `spilled_bytes` metric reported the estimated in-memory size
of spilled `RecordBatches`, based on their array sizes. However, with the
introduction of spill file compression in the `SpillManager`, the in-memory
size no longer reflects the actual bytes written to disk.
This PR updates the `spilled_bytes` metric to instead report the total
number of bytes physically **written to disk** during spilling.
## What changes are included in this PR?
Whenever `in_progress_file.finish()` is called, it updates the spill file
metric based on `current_disk_usage` for this spill file. Since spill files are
append-only, we only update this value once.
## Are these changes tested?
Yes. We manually compare the spill file size and reported metric.
## Are there any user-facing changes?
After this PR, running certain spilling aggregate queries may show
significantly lower `spilled_bytes` values compared to previous runs—even when
using the uncompressed spill option.
This is because the previous metric was based on an inaccurate estimate of
in-memory size. In particular, when a large `RecordBatch` was sliced into
smaller batches during `spill_record_batch_by_size`, the underlying buffers
were not resized due to zero-copy semantics, resulting in inflated memory
accounting.
The updated `spilled_bytes` metric now reflects the actual number of bytes
written to disk, and therefore provides a more accurate representation of spill
size.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]