From 8bb596f3ff9137ef32cde5014a45c3229abe4a04 Mon Sep 17 00:00:00 2001 From: Lars Eggert Date: Fri, 20 Mar 2026 20:19:33 +0900 Subject: [PATCH] feat: Increase default UDP send buffer size to 1MB See https://bugzilla.mozilla.org/show_bug.cgi?id=2024900 --- neqo-bin/src/udp.rs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/neqo-bin/src/udp.rs b/neqo-bin/src/udp.rs index 46e286415e..15e7b6b721 100644 --- a/neqo-bin/src/udp.rs +++ b/neqo-bin/src/udp.rs @@ -30,20 +30,19 @@ impl Socket { let socket = std::net::UdpSocket::bind(addr)?; let state = quinn_udp::UdpSocketState::new((&socket).into())?; - // FIXME: We need to experiment if increasing this actually improves performance. - // Also, on BSD and Apple targets, this seems to increase the `net.inet.udp.maxdgram` - // sysctl, which is not the same as the socket buffer. - // if send_buf_before < ONE_MB { - // state.set_send_buffer_size((&socket).into(), ONE_MB)?; - // let send_buf_after = state.send_buffer_size((&socket).into())?; - // qdebug!("Increasing socket send buffer size from {send_buf_before} to {ONE_MB}, now: - // {send_buf_after}"); } else { - // qdebug!("Default socket send buffer size is {send_buf_before}, not changing"); - // } - qdebug!( - "Default socket send buffer size is {:?}", - state.send_buffer_size((&socket).into()) - ); + let send_buf_before = state.send_buffer_size((&socket).into())?; + if send_buf_before < ONE_MB { + // Same as Firefox. + // The initial default equals `net.inet.udp.maxdgram` (9216 on macOS) but setting + // `SO_SNDBUF` does not modify that sysctl; it only changes the per-socket buffer. + state.set_send_buffer_size((&socket).into(), ONE_MB)?; + qdebug!( + "Increasing socket send buffer size from {send_buf_before} to {ONE_MB}, now: {:?}", + state.send_buffer_size((&socket).into()) + ); + } else { + qdebug!("Default socket send buffer size is {send_buf_before}, not changing"); + } let recv_buf_before = state.recv_buffer_size((&socket).into())?; if recv_buf_before < ONE_MB {