Skip to content

Track max buffer usage in memory channel statistics#3474

Open
pctablet505 wants to merge 1 commit into
python-trio:mainfrom
pctablet505:track-max-buffer-used-1723
Open

Track max buffer usage in memory channel statistics#3474
pctablet505 wants to merge 1 commit into
python-trio:mainfrom
pctablet505:track-max-buffer-used-1723

Conversation

@pctablet505

Copy link
Copy Markdown

Adds a max_buffer_used field to MemoryChannelStatistics, tracking the largest number of items the channel's buffer has ever held at once.

The use case: when you need buffering but math.inf isn't a reasonable max_buffer_size, this makes it possible to observe real-world peak usage during a run and pick a sensible limit, instead of guessing.

Closes #1723

Add a max_buffer_used field to MemoryChannelStatistics that reports
the largest number of items the channel's buffer has held at once
since it was created. This lets users pick a sensible
max_buffer_size based on data from a real run instead of guessing.

Closes python-trio#1723
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00000%. Comparing base (83b96a3) to head (92093ef).

Additional details and impacted files
@@               Coverage Diff               @@
##                 main        #3474   +/-   ##
===============================================
  Coverage   100.00000%   100.00000%           
===============================================
  Files             128          128           
  Lines           19439        19448    +9     
  Branches         1318         1318           
===============================================
+ Hits            19439        19448    +9     
Files with missing lines Coverage Δ
src/trio/_channel.py 100.00000% <100.00000%> (ø)
src/trio/_tests/test_channel.py 100.00000% <100.00000%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pctablet505
pctablet505 marked this pull request as ready for review July 17, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature request: track max queue length in memory channel stats

1 participant