-
Notifications
You must be signed in to change notification settings - Fork 210
feat: yamux receive window auto-tuning #1270
Copy link
Copy link
Open
Description
Summary
The yamux stream muxer in py-libp2p currently uses a fixed 256KB receive window, which limits throughput on high-bandwidth links. Other libp2p implementations (notably go-yamux) implement receive window auto-tuning that dynamically grows the window up to 16MB based on RTT measurements.
Proposed Change
Implement yamux receive window auto-tuning that:
- Starts at the default 256KB window size
- Doubles the target receive window each RTT epoch when the buffer is being consumed quickly
- Caps at 16MB max receive window (matching go-yamux)
- Sends
WINDOW_UPDATEframes to the peer as the window grows
This is the same algorithm used in go-yamux.
Implementation
A working implementation is available in #1269 and is currently being tested in the unified-testing perf suite (see libp2p/unified-testing#62).
Key changes:
- Added
MAX_WINDOW_SIZE = 16 * 1024 * 1024constant - Added
target_recv_windowtracking per stream - Added
_auto_tune_and_send_window_update()method that grows the window based on consumption rate - Called on every
read()and_read_stream_data()to keep the window responsive
Impact
Perf test results show significant throughput improvement with auto-tuning enabled, particularly for upload/download benchmarks over tcp+yamux.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels