perf: increase backpressure limit to 16384 and reduce retransmit tick to 10ms for multi-gigabit speeds

This commit is contained in:
ospab 2026-05-26 23:21:33 +03:00
parent 8e7c1e58e6
commit 800c07de5d
2 changed files with 4 additions and 4 deletions

View File

@ -134,7 +134,7 @@ impl Bridge {
) -> Result<()> {
let mut metrics_tick = interval(Duration::from_millis(500));
let mut keepalive_tick = tokio::time::interval(Duration::from_secs(self.keepalive_interval_sec.max(1)));
let mut retransmit_tick = tokio::time::interval(Duration::from_millis(50));
let mut retransmit_tick = tokio::time::interval(Duration::from_millis(10));
let init_msg = if self.mode == "tun" {
"Bridge initialized (TUN mode)".to_string()
} else {
@ -591,7 +591,7 @@ impl Bridge {
}
proxy_ev = proxy_rx.recv(), if self.running && sessions_opt.as_ref().map(|s| {
// Backpressure: suspend proxy reads when ARQ window is saturated
s.iter().all(|ses| ses.machine.in_flight_count() < ses.machine.cwnd_packets().clamp(16, 256))
s.iter().all(|ses| ses.machine.in_flight_count() < ses.machine.cwnd_packets().clamp(16, 16384))
}).unwrap_or(true) => {
if let Some(ev) = proxy_ev {
if let Some(sessions) = sessions_opt.as_mut() {

View File

@ -356,7 +356,7 @@ async fn run_server_loop(
let socket = primary_socket;
// Spawn a recv task for each socket, all feeding into the same channel
let (udp_tx, mut udp_rx) = mpsc::channel(10000);
let (udp_tx, mut udp_rx) = mpsc::channel(100000);
for sock in &sockets {
let sock_clone = sock.clone();
let tx = udp_tx.clone();
@ -460,7 +460,7 @@ async fn run_server_loop(
let _ = ui_event_tx.send(UiEvent::KeyCount(shared_keys.read().unwrap().len()));
}
let mut retransmit_tick = interval(Duration::from_millis(50));
let mut retransmit_tick = interval(Duration::from_millis(10));
let mut last_empty_app_log = Instant::now() - Duration::from_secs(10);
let mut peer_last_seen: HashMap<IpAddr, Instant> = HashMap::new();
let mut peer_available: HashMap<IpAddr, bool> = HashMap::new();