Skip to content

Commit 7c6e56a

Browse files
committed
fix(server): Skip missed ticks instead of bursting in EWMA estimators
Tokio's default MissedTickBehavior::Burst fires catch-up ticks in rapid succession after a delayed tick, making duration_since(last) near-zero on catch-up iterations and inflating the rate estimate. Skip is the right behavior for a rate estimator — recomputing stale windows has no value.
1 parent 426f1c7 commit 7c6e56a

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

objectstore-server/src/rate_limits.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ impl BandwidthRateLimiter {
380380
const TICK: Duration = Duration::from_millis(50); // Recompute EWMA on every TICK
381381

382382
let mut interval = tokio::time::interval(TICK);
383+
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
383384
// The first tick of a tokio interval fires immediately. Consume it so the
384385
// first real iteration has a full ~50ms of elapsed time.
385386
interval.tick().await;
@@ -558,6 +559,7 @@ impl ThroughputRateLimiter {
558559
tokio::task::spawn(async move {
559560
const TICK: Duration = Duration::from_millis(50);
560561
let mut interval = tokio::time::interval(TICK);
562+
interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Skip);
561563
interval.tick().await;
562564
let mut last = Instant::now();
563565
let mut global_ewma: f64 = 0.0;

0 commit comments

Comments
 (0)