diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-10-16 10:41:17 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-10-16 10:41:17 +0200 |
| commit | d74d371bd7c0ed25f60754e475a78975bf2dc4ee (patch) | |
| tree | 88f732b318ebe7fef1e684eb28ae780baec4233b /packages/meshbay-cli/src/meshbay_cli/client/udp_buffer.py | |
| parent | 2167b7cd7ec006ba3f736bc18970f86f15d88a2a (diff) | |
| download | meshbay-d74d371bd7c0ed25f60754e475a78975bf2dc4ee.tar.gz | |
perf: linear SCTP reassembly, one SACK every second packet, 4 MB buffer in the CLI
aiortc walked a message's fragments after each one arrived (n^2/2 steps
for a 1 MiB chunk) and acknowledged every packet. Measured on loopback,
400 MB to the CLI: 19 MB/s before, 39 after (49 by the node's count);
uploads from the CLI 25 -> 29 MB/s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-cli/src/meshbay_cli/client/udp_buffer.py')
| -rw-r--r-- | packages/meshbay-cli/src/meshbay_cli/client/udp_buffer.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/packages/meshbay-cli/src/meshbay_cli/client/udp_buffer.py b/packages/meshbay-cli/src/meshbay_cli/client/udp_buffer.py new file mode 100644 index 0000000..c0045d8 --- /dev/null +++ b/packages/meshbay-cli/src/meshbay_cli/client/udp_buffer.py @@ -0,0 +1,18 @@ +"""A larger receive buffer on the client's ICE sockets, applied on import. + +In a download the client is the receiver, and it reads its socket from Python +— on the same event loop as the terminal interface — more slowly than a node +sends in bursts. aioice asks the kernel for 256 KB per socket; what does not fit +is dropped by this machine's kernel (`UdpRcvbufErrors`), the node's SCTP sender +takes each drop for congestion and halves its window. Measured on loopback, 400 +MB: 3245 drops and 19 MB/s with 256 KB. The node does the same for the same +reason in the other direction (`meshbay_node/transport/webrtc/udp_buffer.py`). + +Linux grants no more than `net.core.rmem_max`; Windows grants what is asked. +""" + +import aioice.turn + +WANTED = 4 * 1024 * 1024 + +aioice.turn.UDP_SOCKET_BUFFER_SIZE = WANTED |