Skip to content

feat(memory_pool): add TrackConsumersPool::metrics() to expose cons…#21147

Open
bert-beyondloops wants to merge 1 commit intoapache:mainfrom
bert-beyondloops:track-consumers-pool-formatting
Open

feat(memory_pool): add TrackConsumersPool::metrics() to expose cons…#21147
bert-beyondloops wants to merge 1 commit intoapache:mainfrom
bert-beyondloops:track-consumers-pool-formatting

Conversation

@bert-beyondloops
Copy link
Contributor

Which issue does this PR close?

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

@github-actions github-actions bot added the execution Related to the execution crate label Mar 25, 2026
@bert-beyondloops bert-beyondloops force-pushed the track-consumers-pool-formatting branch from ac10b8f to 37cf8e4 Compare March 25, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

execution Related to the execution crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose TrackConsumersPool memory consumer metrics programmatically

1 participant