feat: enable request hedging for all upstream protocols

Hedging was DoH-only (hyper dispatch spike mitigation). Now applies to
UDP (rescues packet loss) and DoT (rescues TLS handshake stalls) too.
Same-upstream hedging: fires a second independent request after hedge_ms
delay. First response wins. Disable with hedge_ms = 0.
This commit is contained in:
Razvan Dimescu
2026-04-12 21:34:47 +03:00
parent 50828c411a
commit 02e1449a45

View File

@@ -360,9 +360,11 @@ pub async fn forward_with_failover_raw(
for upstream in &all_upstreams { for upstream in &all_upstreams {
let start = Instant::now(); let start = Instant::now();
let result = if !hedge_delay.is_zero() && matches!(upstream, Upstream::Doh { .. }) { let result = if !hedge_delay.is_zero() {
// Hedge against the same upstream: parallel h2 streams on same // Hedge against the same upstream: independent h2 streams (DoH),
// connection. Independent stream scheduling rescues dispatch spikes. // independent UDP packets (plain DNS), or independent TLS
// connections (DoT). Rescues packet loss, dispatch spikes, and
// TLS handshake stalls.
forward_with_hedging_raw(wire, upstream, upstream, hedge_delay, timeout_duration).await forward_with_hedging_raw(wire, upstream, upstream, hedge_delay, timeout_duration).await
} else { } else {
forward_query_raw(wire, upstream, timeout_duration).await forward_query_raw(wire, upstream, timeout_duration).await