Commit c473c18
feat(memory_pool): add
## 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
Co-authored-by: Bert Vermeiren <bert.vermeiren@datadobi.com>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>TrackConsumersPool::metrics() to expose cons… (#21147)1 parent a9dc1dc commit c473c18
1 file changed
Lines changed: 83 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
305 | 331 | | |
306 | 332 | | |
307 | 333 | | |
| |||
381 | 407 | | |
382 | 408 | | |
383 | 409 | | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
384 | 419 | | |
385 | 420 | | |
386 | 421 | | |
| |||
778 | 813 | | |
779 | 814 | | |
780 | 815 | | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
781 | 864 | | |
782 | 865 | | |
783 | 866 | | |
| |||
0 commit comments