ningsiyuan1024 opened a new pull request, #7840:
URL: https://github.com/apache/datafusion-comet/pull/7840
## Which issue does this PR close?
Closes #7688.
## Rationale for this change
A one-byte slice can retain a 524,416-byte merged object-store response. The
decoder also holds uncompressed pages and an output batch. Without a scan
reservation other consumers see more free memory than the task has.
## What changes are included in this PR?
Register a scan consumer on the reader factory. Hold compressed response
reservations through the lifetime of their bytes. Estimate decode memory at the
first data fetch using the overlapping row groups, fetched leaves, uncompressed
chunk sizes, repetition/definition levels and batch size. Retain the reader's
largest granted estimate until close. Metadata-only and fully pruned reads do
not take a decode reservation. The switch is on by default; set
spark.comet.parquet.pageMemory.enabled=false for the old behavior. The metrics
and memory guide describe refusals and what remains uncharged.
## How are these changes tested?
The three affected Rust test groups passed all 48 tests. Coverage includes a
one-row, 500-column file, a refused reservation followed by recovery, an
interrupted request, and the last slice of a merged response. With real Parquet
dictionary pages and nested lists, exported Arrow C arrays remained alive after
the scan pool returned to zero. Reimport verified nulls, empty lists and
values. Cargo formatting also passed.
For the Spark comparison, write one Snappy Parquet partition from
range(600000) with id and sha2(cast(id as string), 256) as payload, using 1 MiB
row groups. On Spark 4.1.1 with a locally compiled JVM bridge and native
library, run sortWithinPartitions("payload", "id") with fair_unified, 32 MiB
off-heap and a Comet batch size of 2048. Alternate the switch and hash every
output row in order. Both arms matched the Spark-only result in all ten
measured runs.
| Per run | Off (5 runs) | On (5 runs) |
| --- | ---: | ---: |
| Native sort spills | 5 | 6 |
| Bytes spilled | 43,484,960 | 43,462,344 |
| Data bytes read | 42,071,849 | 42,071,849 |
| Decode reservation bytes granted, cumulative | 0 | 1,274,327 |
| Median wall time including digest, seconds | 14.64 | 14.40 |
The enabled scan caused one additional spill per run. The timing ranges
overlap, and these are debug builds. This single-partition sort does not
establish the spill impact on SF100 TPC-H q9/q10. Fork Spark SQL CI is tracked
[here](https://github.com/ningsiyuan1024/datafusion-comet/actions/runs/47046349598).
AI assistance: OpenAI Codex wrote and tested the patch.
--
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]