Skip to content

Commit a7c878f

Browse files
committed
fix(client): scope recursive poll throttling to multi-resolver mode
1 parent 201f9d7 commit a7c878f

2 files changed

Lines changed: 25 additions & 22 deletions

File tree

crates/slipstream-client/src/runtime.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ pub async fn run_client(config: &ClientConfig<'_>) -> Result<i32, ClientError> {
861861
last_flow_block_log_at = now;
862862
}
863863
watchdog.set_phase(PHASE_POLL_QUERIES);
864+
let multi_resolver_mode = resolver_manager.as_slice().len() > 1;
864865
for resolver in resolver_manager.as_mut_slice().iter_mut() {
865866
if !resolver.is_active() && resolver.mode == ResolverMode::Recursive {
866867
continue;
@@ -900,9 +901,9 @@ pub async fn run_client(config: &ClientConfig<'_>) -> Result<i32, ClientError> {
900901
cnx,
901902
&mut dispatch,
902903
resolver,
904+
multi_resolver_mode,
903905
has_ready_stream,
904906
flow_blocked,
905-
sent_quic_data,
906907
)
907908
.await?;
908909
}

crates/slipstream-client/src/runtime/actions.rs

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ use tracing::debug;
88

99
use super::path::{fetch_path_quality, path_poll_burst_max};
1010

11-
const RECURSIVE_POLL_MIN_INTERVAL_US_ACTIVE: u64 = 5_000;
12-
const RECURSIVE_POLL_MIN_INTERVAL_US_IDLE: u64 = 1_000;
13-
const RECURSIVE_POLL_BURST_ACTIVE_STREAMS: usize = 1;
14-
const RECURSIVE_POLL_BURST_IDLE: usize = 4;
11+
const RECURSIVE_POLL_MIN_INTERVAL_US_ACTIVE: u64 = 1_000;
12+
const RECURSIVE_POLL_MIN_INTERVAL_US_IDLE: u64 = 500;
13+
const RECURSIVE_POLL_BURST_ACTIVE_STREAMS: usize = 2;
14+
const RECURSIVE_POLL_BURST_IDLE: usize = 8;
1515

1616
pub(crate) struct PollDispatch<'a, 'cfg> {
1717
pub(crate) udp: &'a TokioUdpSocket,
@@ -82,9 +82,9 @@ pub(crate) async fn poll_recursive_resolver(
8282
cnx: *mut picoquic_cnx_t,
8383
dispatch: &mut PollDispatch<'_, '_>,
8484
resolver: &mut ResolverState,
85+
multi_resolver_mode: bool,
8586
has_ready_stream: bool,
8687
flow_blocked: bool,
87-
sent_quic_data: bool,
8888
) -> Result<(), ClientError> {
8989
if resolver.mode != ResolverMode::Recursive {
9090
return Ok(());
@@ -96,26 +96,28 @@ pub(crate) async fn poll_recursive_resolver(
9696
}
9797

9898
let now = unsafe { slipstream_ffi::picoquic::picoquic_current_time() };
99-
let min_interval = if has_ready_stream {
100-
RECURSIVE_POLL_MIN_INTERVAL_US_ACTIVE
101-
} else {
102-
RECURSIVE_POLL_MIN_INTERVAL_US_IDLE
103-
};
104-
if resolver.last_recursive_poll_sent_at > 0
105-
&& now.saturating_sub(resolver.last_recursive_poll_sent_at) < min_interval
106-
{
107-
return Ok(());
108-
}
109-
110-
if has_ready_stream && !flow_blocked && sent_quic_data {
111-
return Ok(());
99+
if multi_resolver_mode {
100+
let min_interval = if has_ready_stream {
101+
RECURSIVE_POLL_MIN_INTERVAL_US_ACTIVE
102+
} else {
103+
RECURSIVE_POLL_MIN_INTERVAL_US_IDLE
104+
};
105+
if resolver.last_recursive_poll_sent_at > 0
106+
&& now.saturating_sub(resolver.last_recursive_poll_sent_at) < min_interval
107+
{
108+
return Ok(());
109+
}
112110
}
113111

114112
let burst_max = path_poll_burst_max(resolver);
115-
let burst_cap = if has_ready_stream {
116-
RECURSIVE_POLL_BURST_ACTIVE_STREAMS
113+
let burst_cap = if multi_resolver_mode {
114+
if has_ready_stream && !flow_blocked {
115+
RECURSIVE_POLL_BURST_ACTIVE_STREAMS
116+
} else {
117+
RECURSIVE_POLL_BURST_IDLE
118+
}
117119
} else {
118-
RECURSIVE_POLL_BURST_IDLE
120+
burst_max
119121
};
120122
let burst_max = burst_max.min(burst_cap.max(1));
121123
let polls_sent_before = resolver.debug.polls_sent;

0 commit comments

Comments
 (0)