Repository navigation
Fix the default write buffer low-water mark - #778
Open
Shaisolaris wants to merge 1 commit into
Open
Shaisolaris wants to merge 1 commit into
Shaisolaris wants to merge 1 commit into
Conversation
Shaisolaris
force-pushed
the
default-low-water-mark
branch
from
October 31, 2026 12:46
165ba64 to
87bdb02
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UVBaseTransport.__cinit__sets the initial write buffer limits toFLOW_CONTROL_HIGH_WATERis in KiB (64), so the low-water mark starts at 16 bytes instead of 16 KiB. vanilla asyncio starts at(16384, 65536), and uvloop itself returns(16384, 65536)afterset_write_buffer_limits()is called with no arguments, becauseadd_flowcontrol_defaults()multiplies by 1024 before dividing.Reproducer:
On main this prints
(16, 65536)for TCP, and the same for streams and write pipes; asyncio prints(16384, 65536). In practice a protocol that getspause_writing()is only resumed once the buffer is almost fully drained, rather than at 16 KiB as with asyncio.The change adds the missing
* 1024, and adds an assertion on the initial limits totest_flowcontrol_mixin_set_write_limits.Tested on Linux x86_64, CPython 3.12:
tests/test_tcp.py -k flowcontrol_mixin_set_write_limits: fails before the change ((16, 65536) != (16384, 65536)), passes after.tests/test_tcp.py tests/test_pipes.py tests/test_unix.py: 141 passed, 21 skipped after the change.I did not run the full test suite, macOS, or other Python versions.