bert-beyondloops opened a new pull request, #21147:
URL: https://github.com/apache/datafusion/pull/21147
## Which issue does this PR close?
- Closes #21146
## Rationale for this change
There is currently no way to programmatically inspect the memory consumption
of individual consumers tracked by TrackConsumersPool. The only available
method, report_top(), returns a formatted string intended for human-readable
output, making it unsuitable for programmatic use (e.g., metrics collection,
monitoring, or custom reporting).
## What changes are included in this PR?
Added a metrics() method to TrackConsumersPool that returns a Vec — a
snapshot of all currently tracked consumers. Each MemoryConsumerMetrics entry
exposes:
name — the consumer's name
can_spill — whether the consumer supports spilling to disk
reserved — current bytes reserved
peak — peak bytes reserved
This allows callers to inspect memory usage programmatically without parsing
formatted strings.
## Are these changes tested?
Yes. A dedicated unit test test_track_consumers_pool_metrics was added in
pool.rs that verifies:
- An empty pool returns no metrics
- name, can_spill, reserved, and peak are correctly reported for each
consumer
- Peak is tracked independently from current reservation (grow then shrink
scenario)
- Dropped consumers are removed from metrics
## Are there any user-facing changes?
No
--
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]