From a87b379941c0d5795198ed4b35c49aba1950895e Mon Sep 17 00:00:00 2001 From: Max Inden Date: Sun, 8 Dec 2024 23:21:00 +0100 Subject: [PATCH] fix(sim): correct `Waiting` state comparison in `NodeHolder::ready()` (#2263) A `Node` (e.g. a `Client`, `Server` or `TailDrop` router) can be in 3 states: ``` rust enum NodeState { /// The node just produced a datagram. It should be activated again as soon as possible. Active, /// The node is waiting. Waiting(Instant), /// The node became idle. Idle, } ``` `NodeHolder::ready()` determines whether a `Node` is ready to be processed again. When `NodeState::Waiting`, it should only be ready when `t <= now`, i.e. the waiting time has passed, not `t >= now`. ``` rust impl NodeHolder { fn ready(&self, now: Instant) -> bool { match self.state { Active => true, Waiting(t) => t <= now, // not >= Idle => false, } } } ``` The previous behavior lead to wastefull non-ready `Node`s being processed and thus a large test runtime when e.g. simulating a gbit connection (https://github.com/mozilla/neqo/pull/2203). --- test-fixture/src/sim/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-fixture/src/sim/mod.rs b/test-fixture/src/sim/mod.rs index 14c21dd75c..5969d0b282 100644 --- a/test-fixture/src/sim/mod.rs +++ b/test-fixture/src/sim/mod.rs @@ -110,7 +110,7 @@ impl NodeHolder { fn ready(&self, now: Instant) -> bool { match self.state { Active => true, - Waiting(t) => t >= now, + Waiting(t) => t <= now, Idle => false, } }