Repository navigation
fix: count a sent packet before judging the sender app-limited - #3963
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The accounting order is corrected and the affected boundary conditions are adequately tested.
Pull request overview
Corrects app-limited detection by accounting for a sent packet before evaluating congestion-window utilization.
Changes:
- Reorders bytes-in-flight accounting.
- Updates app-limited thresholds and adds a regression test.
File summaries
| File | Description |
|---|---|
neqo-transport/src/cc/classic_cc.rs |
Fixes congestion-window growth classification and tests boundary behavior. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3963 +/- ##
==========================================
- Coverage 96.91% 96.75% -0.17%
==========================================
Files 113 118 +5
Lines 39533 39862 +329
Branches 39533 39862 +329
==========================================
+ Hits 38315 38567 +252
- Misses 1203 1270 +67
- Partials 15 25 +10
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Moving bytes_in_flight += pkt.len() above the app_limited() check looks correct to me: it makes the code match the comment right below it ("all in-flight packets up to this one are NOT app-limited") and it fixes the case where first_app_limited stays None, which makes on_packets_acked treat every ack as app-limited and permanently suppress window growth.
I checked the adjusted test constants against the two branches of app_limited() and they're right:
- slow start: app-limited iff
n * MSS < cwnd / 2⟹ largest app-limited burst isCWND_INITIAL_PKTS / 2 - 1; - congestion avoidance: app-limited iff
n * MSS + PACING_BURST_SIZE * MSS < cwnd⟹CWND_PKTS_CA - PACING_BURST_SIZE - 1.
Both derivations assume cwnd_initial() is an exact multiple of the PLPMTU. That holds today (1252 B PLPMTU at the test MTU ⟹ 12520 B), but it silently stops holding if the 14_720 clamp in cwnd_initial() ever applies (PLPMTU ≥ 1472). Deriving the constants from cc.cwnd() / cc.max_datagram_size() would make these tests self-maintaining.
Architecturally, the net effect is that the non-app-limited threshold moves down by exactly one packet, so a sender that sends precisely cwnd / 2 (slow start) or cwnd - PACING_BURST_SIZE * MSS (CA) is now credited with fully utilizing the window even though it genuinely had nothing more to send. That's a heuristic either way and RFC 9002 §7.8 leaves the determination implementation-specific, so this isn't a regression — but the authoritative signal ("no more data to send while cwnd_avail() > 0") lives at the process_output layer, not in bytes_in_flight. If this heuristic keeps producing bugs, plumbing that signal down would remove the guesswork entirely.
Minor: the PR description frames this as "a batch can exceed cwnd", but on_packet_sent runs per packet, so packets earlier in a batch are already accounted for — the fix is really an off-by-one on the packet being sent. Worth rewording the commit message since it lands in the history.
Also, CI had not reported any results at review time, so I could not confirm the full suite passes with the new boundaries (sender.rs and connection/tests/cc.rs app-limited expectations look unaffected by inspection).
Merging this PR will degrade performance by 3.89%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | coalesce_acked_from_zero 1 ranges |
2.7 µs | 2.8 µs | -3.89% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing larseggert:fix/cc-app-limited-accounting (e1703fb) with main (154244d)
martinthomson
left a comment
There was a problem hiding this comment.
I am still unclear on why our app-limited check is the way it is. It makes little sense to me. But this is an obvious improvement.
e646f6e to
0dd96c9
Compare
There was a problem hiding this comment.
The reordering is correct: app_limited() should see the in-flight state after the send, which is what first_app_limited = Some(pkt.pn() + 1) already assumes, and it matches RFC 9002 §7.8 ("unable to fill the congestion window"). Without it, a send that consumes the whole window is judged app-limited, first_app_limited stays None, and on_packets_acked() takes the on_app_limited() path forever — so the "life of the connection" claim in the description holds.
Two architectural notes:
- The effect is broader than the description suggests: because
on_packet_sent()is per-packet, the change shifts the non-app-limited boundary one packet earlier for every burst (bif_before >= Tbecomesbif_after >= T), which is exactly why both existing tests' expected counts drop by one (5/6 → 4/5 in slow start, 3/4 → 2/3 in CA with the default fixture). Worth saying so in the commit message, since it also means a sender putting exactlycwnd / 2in flight during slow start is now congestion-limited rather than app-limited. Thesender.rsapp_limited_suppresses_cwnd_growth_*tests sendPACING_BURST_SIZE + 1packets against a 10-packet initial window, so they are unaffected. - Re #discussion_r3977261356: the byte-budget framing is fair —
app_limited()only sees bytes. Then the name/doc are the misleading part, since what is being pinned isbytes_in_flight == cwnd, not "one packet". Something likenot_app_limited_when_cwnd_fully_consumedwould match the property. (My earlier note onsent::make_packetis addressed.)
Minor: several sent::Packet::new() call sites remain in this test module (ecn_ce, no_reaction_to_non_ack_eliciting, …) and could use sent::make_packet for consistency — not this PR's job, but it would finish the cleanup.
A batch can exceed `cwnd`, leaving the pipe empty when it is sent. Judging `app_limited()` there suspends congestion window growth for the life of the connection.
0dd96c9 to
e1703fb
Compare
Performance profiles for profiler.firefox.comBenchmarks (14)
|
There was a problem hiding this comment.
Ordering fix looks right: counting the packet before evaluating app_limited() makes the predicate answer "is the window utilized now that this packet is out", which is what the following block's comment ("all in-flight packets up to this one are NOT app-limited") already assumed. Consistent with RFC 9002 §7.8.
Verified the retuned constants are exact rather than approximate, which is worth noting since the comments only say "one short":
- Slow start:
cwnd_initial == CWND_INITIAL_PKTS * MSS(the14_720clamp does not bite for the test PLPMTU), socwnd / 2 == 5 * MSSandCWND_INITIAL_PKTS / 2 - 1 == 4is the largest burst withbif < cwnd / 2. - CA: after halving,
cwnd == 5 * MSS, sobif < cwnd - PACING_BURST_SIZE * MSS == 3 * MSS, andCWND_PKTS_CA - PACING_BURST_SIZE - 1 == 2.
Both also confirm the tests are real regression pins: on main, ABOVE_APP_LIMIT_PKTS was one larger, so the old ordering happened to cross the threshold and the tests passed; with the new values they would fail without the fix.
Resolved from earlier rounds: sent::make_packet is now used throughout, the // A batch exceeding cwnd… comment was reworded per @martinthomson's #discussion_r3976440219, the max_app_limited_pkts helper (and its div_ceil underflow) is gone, and cwnd growth is now asserted exactly as 2 * cwnd.
Two remaining PR-wide observations, neither blocking:
- Replacing the derived helper with literal constants was the right call for a regression pin, but it does mean both constants silently encode "the
14_720clamp is inactive at the test PLPMTU". Ifcc::tests::MTUever yields a PLPMTU > 1472 the boundary shifts; the newapp_limited()assertions turn that into a loud failure rather than a silent one, so this is fine as-is — just worth a one-line comment onCWND_INITIAL_PKTS / 2 - 1. - On @larseggert's reply about the
cwnd-sized packet: agreed thatapp_limited()is a byte-budget comparison and the test is not redundant withABOVE_APP_LIMIT_PKTS. It's still the only place exercisingbytes_in_flight >= congestion_window, so if the unrealistic packet size bothers reviewers, awhile cc.bytes_in_flight() < cc.cwnd()loop of MSS-sized packets (as incc/tests/cubic.rs::fill_cwnd) reaches the same state with a production-reachable shape.
Client/server transfer resultsPerformance differences relative to 154244d. No significant performance differences. Table above only shows statistically significant changes. See all results below. All resultsTransfer of 33554432 bytes over loopback, min. 100 runs. All unit-less numbers are in milliseconds.
Download data for |
Failed Interop TestsQUIC Interop Runner, client vs. server, differences relative to
All resultsSucceeded Interop TestsQUIC Interop Runner, client vs. server neqo-pr as client
neqo-pr as server
Unsupported Interop TestsQUIC Interop Runner, client vs. server neqo-pr as client
neqo-pr as server
|
Benchmark resultsNo significant performance differences relative to 154244d. All resultstransfer/1-conn/1-100mb-resp (aka. Download)/mtu-1504: Change within noise threshold. time: [157.87 ms 158.14 ms 158.41 ms]
thrpt: [631.28 MiB/s 632.36 MiB/s 633.43 MiB/s]
change:
time: [-0.9230% -0.6797% -0.4328%] (p = 0.00 < 0.05)
thrpt: [+0.4347% +0.6843% +0.9316%]
Change within noise threshold.transfer/1-conn/10_000-parallel-1b-resp (aka. RPS)/mtu-1504: Change within noise threshold. time: [221.78 ms 222.05 ms 222.31 ms]
thrpt: [44.982 Kelem/s 45.035 Kelem/s 45.090 Kelem/s]
change:
time: [+0.3323% +0.5299% +0.7134%] (p = 0.00 < 0.05)
thrpt: [-0.7084% -0.5271% -0.3312%]
Change within noise threshold.transfer/1-conn/1-1b-resp (aka. HPS)/mtu-1504: Change within noise threshold. time: [35.886 ms 35.973 ms 36.065 ms]
thrpt: [27.728 B/s 27.799 B/s 27.866 B/s]
change:
time: [-0.7996% -0.4370% -0.0286%] (p = 0.02 < 0.05)
thrpt: [+0.0286% +0.4390% +0.8060%]
Change within noise threshold.
Found 5 outliers among 100 measurements (5.00%)
5 (5.00%) high mildtransfer/1-conn/1-100mb-req (aka. Upload)/mtu-1504: Change within noise threshold. time: [161.17 ms 161.45 ms 161.75 ms]
thrpt: [618.24 MiB/s 619.37 MiB/s 620.45 MiB/s]
change:
time: [+0.7567% +1.0048% +1.2313%] (p = 0.00 < 0.05)
thrpt: [-1.2163% -0.9948% -0.7510%]
Change within noise threshold.
Found 5 outliers among 100 measurements (5.00%)
1 (1.00%) low mild
3 (3.00%) high mild
1 (1.00%) high severestreams/walltime/1-streams/each-1000-bytes: No change in performance detected. time: [548.77 µs 550.91 µs 553.34 µs]
thrpt: [1.7235 MiB/s 1.7311 MiB/s 1.7378 MiB/s]
change:
time: [-0.3852% +0.1773% +0.7560%] (p = 0.55 > 0.05)
thrpt: [-0.7504% -0.1770% +0.3867%]
No change in performance detected.
Found 13 outliers among 100 measurements (13.00%)
13 (13.00%) high severestreams/walltime/1000-streams/each-1-bytes: Change within noise threshold. time: [10.500 ms 10.514 ms 10.527 ms]
thrpt: [92.765 KiB/s 92.886 KiB/s 93.004 KiB/s]
change:
time: [-0.4721% -0.2840% -0.0999%] (p = 0.00 < 0.05)
thrpt: [+0.1000% +0.2848% +0.4743%]
Change within noise threshold.streams/walltime/1000-streams/each-1000-bytes: Change within noise threshold. time: [30.325 ms 30.362 ms 30.398 ms]
thrpt: [31.373 MiB/s 31.410 MiB/s 31.448 MiB/s]
change:
time: [-1.1193% -0.9605% -0.7910%] (p = 0.00 < 0.05)
thrpt: [+0.7973% +0.9698% +1.1319%]
Change within noise threshold.streams-flow-controlled/walltime/1-streams/each-4194304-bytes: Change within noise threshold. time: [25.420 ms 25.453 ms 25.487 ms]
thrpt: [156.94 MiB/s 157.15 MiB/s 157.36 MiB/s]
change:
time: [-1.1185% -0.9239% -0.7333%] (p = 0.00 < 0.05)
thrpt: [+0.7388% +0.9325% +1.1312%]
Change within noise threshold.streams-flow-controlled/walltime/10-streams/each-1048576-bytes: Change within noise threshold. time: [69.381 ms 69.454 ms 69.527 ms]
thrpt: [143.83 MiB/s 143.98 MiB/s 144.13 MiB/s]
change:
time: [-1.8161% -1.6746% -1.5287%] (p = 0.00 < 0.05)
thrpt: [+1.5524% +1.7031% +1.8497%]
Change within noise threshold.transfer/walltime/pacing-false/varying-seeds: Change within noise threshold. time: [16.859 ms 16.869 ms 16.879 ms]
thrpt: [236.98 MiB/s 237.12 MiB/s 237.26 MiB/s]
change:
time: [-0.2200% -0.1320% -0.0400%] (p = 0.01 < 0.05)
thrpt: [+0.0400% +0.1321% +0.2205%]
Change within noise threshold.transfer/walltime/pacing-true/varying-seeds: Change within noise threshold. time: [17.459 ms 17.471 ms 17.484 ms]
thrpt: [228.79 MiB/s 228.95 MiB/s 229.11 MiB/s]
change:
time: [+1.7837% +1.8876% +1.9926%] (p = 0.00 < 0.05)
thrpt: [-1.9537% -1.8526% -1.7524%]
Change within noise threshold.
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) low mildtransfer/walltime/pacing-false/same-seed: Change within noise threshold. time: [17.006 ms 17.016 ms 17.026 ms]
thrpt: [234.93 MiB/s 235.07 MiB/s 235.21 MiB/s]
change:
time: [+0.7390% +0.8324% +0.9244%] (p = 0.00 < 0.05)
thrpt: [-0.9159% -0.8255% -0.7336%]
Change within noise threshold.transfer/walltime/pacing-true/same-seed: Change within noise threshold. time: [17.319 ms 17.335 ms 17.351 ms]
thrpt: [230.53 MiB/s 230.75 MiB/s 230.96 MiB/s]
change:
time: [-1.0710% -0.9574% -0.8438%] (p = 0.00 < 0.05)
thrpt: [+0.8509% +0.9666% +1.0826%]
Change within noise threshold.Instructions per cycleCriterion reported no significant timing changes. All benchmarks
Download data for |
A batch can exceed
cwnd, leaving the pipe empty when it is sent. Judgingapp_limited()there suspends congestion window growth for the life of the connection.