perf(peer): tune QUIC flow control for LAN downloads

Raise the s2n-quic connection and stream data windows on both the client and
server, increase the max send buffer, and use BBR with a larger initial
congestion window. The download path was already able to pipeline multiple chunk
streams, but those streams still shared small default connection-level budgets
that limited sustained LAN throughput.

The tuning keeps one current wire protocol and does not add fallback behavior.
It is deliberately centralized in the peer networking module so later transport
changes can use the same limits on both sides of the connection.

S37 single-source throughput:
- Before: 733.22 MiB/s, 6150.72 Mbit/s, 2.793s
- After: 824.94 MiB/s, 6920.09 Mbit/s, 2.483s
- Delta: +91.72 MiB/s, +769.37 Mbit/s, about +12.5%

Test Plan:
- just fmt
- python3 crates/lanspread-peer-cli/scripts/run_extended_scenarios.py S37 --build-image

Refs: local LAN download performance investigation on 2026-05-20.
Depends-on: 14e772c5c71a (peer-cli S37 throughput measurement).
This commit is contained in:
2026-05-20 08:27:49 +02:00
parent 8a9f420a06
commit 5b689ec5f4
3 changed files with 46 additions and 5 deletions
+4 -2
View File
@@ -2,7 +2,7 @@
use std::{net::SocketAddr, time::Duration};
use s2n_quic::{Connection, Server, provider::limits::Limits};
use s2n_quic::{Connection, Server};
use tokio::sync::mpsc::UnboundedSender;
use crate::{
@@ -10,6 +10,7 @@ use crate::{
config::{CERT_PEM, KEY_PEM},
context::PeerCtx,
events,
network::{quic_congestion_controller, quic_limits},
services::{
advertise::{monitor_mdns_events, start_mdns_advertiser},
stream::handle_peer_stream,
@@ -22,7 +23,7 @@ pub async fn run_server_component(
ctx: PeerCtx,
tx_notify_ui: UnboundedSender<PeerEvent>,
) -> eyre::Result<()> {
let limits = Limits::default()
let limits = quic_limits()?
.with_max_handshake_duration(Duration::from_secs(3))?
.with_max_idle_timeout(Duration::from_secs(3))?;
@@ -30,6 +31,7 @@ pub async fn run_server_component(
.with_tls((CERT_PEM, KEY_PEM))?
.with_io(addr)?
.with_limits(limits)?
.with_congestion_controller(quic_congestion_controller())?
.start()?;
let server_addr = server.local_addr()?;