Skip to content

refactor(transport): move UDP datagram limit calc outside loop#3045

Merged
mxinden merged 1 commit into
mozilla:mainfrom
mxinden:outside-loop
Oct 14, 2025
Merged

refactor(transport): move UDP datagram limit calc outside loop#3045
mxinden merged 1 commit into
mozilla:mainfrom
mxinden:outside-loop

Conversation

@mxinden
Copy link
Copy Markdown
Member

@mxinden mxinden commented Oct 13, 2025

There is no need to calculate the UDP datagram limit for each QUIC packet within the same UDP datagram.

There is no need to calculate the UDP datagram limit for each QUIC packet within
the same UDP datagram.
Copilot AI review requested due to automatic review settings October 13, 2025 18:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This refactoring moves the UDP datagram size limit calculation outside the packet building loop to avoid redundant calculations. The limit calculation was previously performed for each QUIC packet within the same UDP datagram, but since all packets in a datagram share the same size constraints, this computation only needs to happen once.

  • Moved UDP datagram limit calculation outside the packet iteration loop
  • Preserved the AEAD expansion subtraction logic but moved it to the packet builder call
  • Added clarifying comments about the AEAD expansion handling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.35%. Comparing base (791fd40) to head (b8a7684).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3045      +/-   ##
==========================================
- Coverage   93.42%   93.35%   -0.07%     
==========================================
  Files         124      124              
  Lines       35967    35969       +2     
  Branches    35967    35969       +2     
==========================================
- Hits        33601    33580      -21     
- Misses       1522     1546      +24     
+ Partials      844      843       -1     
Components Coverage Δ
neqo-common 97.50% <ø> (ø)
neqo-crypto 83.25% <ø> (-0.48%) ⬇️
neqo-http3 93.34% <ø> (ø)
neqo-qpack 94.18% <ø> (ø)
neqo-transport 94.41% <100.00%> (-0.07%) ⬇️
neqo-udp 79.32% <ø> (ø)
mtu 85.57% <ø> (-0.20%) ⬇️

@github-actions
Copy link
Copy Markdown
Contributor

Client/server transfer results

Performance differences relative to 791fd40.

Transfer of 33554432 bytes over loopback, min. 100 runs. All unit-less numbers are in milliseconds.

Client vs. server (params) Mean ± σ Min Max MiB/s ± σ Δ main Δ main
google vs. google 454.9 ± 3.3 447.7 464.0 70.3 ± 9.7
google vs. neqo (cubic, paced) 278.9 ± 3.8 272.0 286.3 114.7 ± 8.4 💔 1.1 0.4%
msquic vs. msquic 188.3 ± 59.3 136.2 374.4 170.0 ± 0.5
msquic vs. neqo (cubic, paced) 208.3 ± 62.2 145.3 419.3 153.6 ± 0.5 -7.9 -3.7%
neqo vs. google (cubic, paced) 762.6 ± 5.2 752.9 777.8 42.0 ± 6.2 💔 1.5 0.2%
neqo vs. msquic (cubic, paced) 158.9 ± 6.6 148.4 183.4 201.3 ± 4.8 1.5 1.0%
neqo vs. neqo (cubic) 90.5 ± 4.4 82.7 102.9 353.5 ± 7.3 -0.8 -0.8%
neqo vs. neqo (cubic, paced) 90.5 ± 5.1 82.7 107.7 353.6 ± 6.3 0.4 0.4%
neqo vs. neqo (reno) 87.5 ± 4.2 79.9 103.9 365.6 ± 7.6 💚 -1.8 -2.1%
neqo vs. neqo (reno, paced) 90.4 ± 6.1 80.5 125.4 354.1 ± 5.2 -0.6 -0.7%
neqo vs. quiche (cubic, paced) 196.0 ± 4.3 186.0 201.8 163.3 ± 7.4 💔 1.4 0.7%
neqo vs. s2n (cubic, paced) 220.4 ± 4.6 211.0 229.1 145.2 ± 7.0 -1.1 -0.5%
quiche vs. neqo (cubic, paced) 151.0 ± 4.4 140.7 162.3 211.9 ± 7.3 💚 -1.7 -1.1%
quiche vs. quiche 148.3 ± 5.8 137.6 181.8 215.7 ± 5.5
s2n vs. neqo (cubic, paced) 172.0 ± 4.5 164.4 182.5 186.0 ± 7.1 0.2 0.1%
s2n vs. s2n 248.3 ± 25.8 231.5 345.0 128.9 ± 1.2

Download data for profiler.firefox.com or download performance comparison data.

@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results

Performance differences relative to 791fd40.

1-conn/1-100mb-resp/mtu-1504 (aka. Download)/client: Change within noise threshold.
       time:   [193.97 ms 194.37 ms 194.86 ms]
       thrpt:  [513.18 MiB/s 514.48 MiB/s 515.55 MiB/s]
change:
       time:   [+0.1983% +0.4353% +0.7118%] (p = 0.00 < 0.05)
       thrpt:  [−0.7067% −0.4334% −0.1979%]

Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high severe

1-conn/10_000-parallel-1b-resp/mtu-1504 (aka. RPS)/client: Change within noise threshold.
       time:   [285.68 ms 288.00 ms 290.25 ms]
       thrpt:  [34.453 Kelem/s 34.723 Kelem/s 35.005 Kelem/s]
change:
       time:   [+0.3303% +1.3591% +2.5385%] (p = 0.01 < 0.05)
       thrpt:  [−2.4757% −1.3409% −0.3292%]

Found 3 outliers among 100 measurements (3.00%)
3 (3.00%) low mild

1-conn/1-1b-resp/mtu-1504 (aka. HPS)/client: No change in performance detected.
       time:   [28.309 ms 28.414 ms 28.539 ms]
       thrpt:  [35.040   B/s 35.193   B/s 35.324   B/s]
change:
       time:   [−0.4254% +0.0181% +0.4910%] (p = 0.94 > 0.05)
       thrpt:  [−0.4886% −0.0181% +0.4272%]

Found 25 outliers among 100 measurements (25.00%)
17 (17.00%) low severe
8 (8.00%) high severe

1-conn/1-100mb-req/mtu-1504 (aka. Upload)/client: Change within noise threshold.
       time:   [203.24 ms 203.58 ms 204.00 ms]
       thrpt:  [490.20 MiB/s 491.20 MiB/s 492.03 MiB/s]
change:
       time:   [+0.0748% +0.3667% +0.6535%] (p = 0.01 < 0.05)
       thrpt:  [−0.6493% −0.3654% −0.0747%]

Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high severe

decode 4096 bytes, mask ff: No change in performance detected.
       time:   [11.593 µs 11.627 µs 11.668 µs]
       change: [−0.8111% −0.0328% +0.7685%] (p = 0.93 > 0.05)

Found 14 outliers among 100 measurements (14.00%)
2 (2.00%) low severe
4 (4.00%) low mild
8 (8.00%) high severe

decode 1048576 bytes, mask ff: No change in performance detected.
       time:   [3.0228 ms 3.0323 ms 3.0436 ms]
       change: [−0.2576% +0.1901% +0.6378%] (p = 0.42 > 0.05)

Found 9 outliers among 100 measurements (9.00%)
9 (9.00%) high severe

decode 4096 bytes, mask 7f: No change in performance detected.
       time:   [19.966 µs 20.022 µs 20.083 µs]
       change: [−1.3257% −0.3883% +0.3873%] (p = 0.42 > 0.05)

Found 22 outliers among 100 measurements (22.00%)
2 (2.00%) low severe
4 (4.00%) low mild
2 (2.00%) high mild
14 (14.00%) high severe

decode 1048576 bytes, mask 7f: No change in performance detected.
       time:   [5.0455 ms 5.0589 ms 5.0755 ms]
       change: [−0.2574% +0.1043% +0.5058%] (p = 0.60 > 0.05)

Found 12 outliers among 100 measurements (12.00%)
12 (12.00%) high severe

decode 4096 bytes, mask 3f: No change in performance detected.
       time:   [8.2820 µs 8.3201 µs 8.3650 µs]
       change: [−0.5700% +0.4105% +1.8430%] (p = 0.58 > 0.05)

Found 23 outliers among 100 measurements (23.00%)
2 (2.00%) low severe
9 (9.00%) low mild
3 (3.00%) high mild
9 (9.00%) high severe

decode 1048576 bytes, mask 3f: No change in performance detected.
       time:   [1.5853 ms 1.5896 ms 1.5952 ms]
       change: [−1.8567% −0.7288% +0.1077%] (p = 0.17 > 0.05)

Found 5 outliers among 100 measurements (5.00%)
5 (5.00%) high severe

1-streams/each-1000-bytes/wallclock-time: No change in performance detected.
       time:   [583.70 µs 586.73 µs 590.46 µs]
       change: [−0.1172% +0.6230% +1.3432%] (p = 0.10 > 0.05)

Found 10 outliers among 100 measurements (10.00%)
2 (2.00%) low mild
1 (1.00%) high mild
7 (7.00%) high severe
1-streams/each-1000-bytes/simulated-time
time: [118.66 ms 118.86 ms 119.07 ms]
thrpt: [8.2019 KiB/s 8.2158 KiB/s 8.2297 KiB/s]
change:
time: [−0.3676% −0.0856% +0.1796%] (p = 0.52 > 0.05)
thrpt: [−0.1793% +0.0857% +0.3690%]
No change in performance detected.
Found 2 outliers among 100 measurements (2.00%)
1 (1.00%) low mild
1 (1.00%) high mild

1000-streams/each-1-bytes/wallclock-time: No change in performance detected.
       time:   [13.664 ms 13.704 ms 13.752 ms]
       change: [−0.5619% −0.2425% +0.1292%] (p = 0.20 > 0.05)

Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high severe
1000-streams/each-1-bytes/simulated-time
time: [14.981 s 14.993 s 15.006 s]
thrpt: [66.639 B/s 66.696 B/s 66.752 B/s]
change:
time: [+0.0004% +0.1259% +0.2572%] (p = 0.05 > 0.05)
thrpt: [−0.2566% −0.1257% −0.0004%]
No change in performance detected.
Found 2 outliers among 100 measurements (2.00%)
2 (2.00%) high mild

1000-streams/each-1000-bytes/wallclock-time: 💚 Performance has improved.
       time:   [48.641 ms 48.833 ms 49.028 ms]
       change: [−2.1399% −1.6198% −1.1249%] (p = 0.00 < 0.05)

Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high mild
1000-streams/each-1000-bytes/simulated-time
time: [18.938 s 19.126 s 19.313 s]
thrpt: [50.566 KiB/s 51.061 KiB/s 51.567 KiB/s]
change:
time: [−1.2892% +0.0927% +1.4418%] (p = 0.89 > 0.05)
thrpt: [−1.4213% −0.0926% +1.3061%]
No change in performance detected.
Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high mild

coalesce_acked_from_zero 1+1 entries: No change in performance detected.
       time:   [87.965 ns 88.360 ns 88.767 ns]
       change: [−0.5262% −0.0908% +0.3470%] (p = 0.69 > 0.05)

Found 11 outliers among 100 measurements (11.00%)
7 (7.00%) high mild
4 (4.00%) high severe

coalesce_acked_from_zero 3+1 entries: No change in performance detected.
       time:   [106.01 ns 106.35 ns 106.70 ns]
       change: [+0.0271% +0.6838% +1.5180%] (p = 0.08 > 0.05)

Found 15 outliers among 100 measurements (15.00%)
3 (3.00%) high mild
12 (12.00%) high severe

coalesce_acked_from_zero 10+1 entries: No change in performance detected.
       time:   [105.34 ns 105.72 ns 106.20 ns]
       change: [−0.2804% +0.4519% +1.5644%] (p = 0.39 > 0.05)

Found 9 outliers among 100 measurements (9.00%)
2 (2.00%) low mild
7 (7.00%) high severe

coalesce_acked_from_zero 1000+1 entries: No change in performance detected.
       time:   [88.911 ns 89.056 ns 89.230 ns]
       change: [−0.8617% −0.0023% +0.8455%] (p = 1.00 > 0.05)

Found 9 outliers among 100 measurements (9.00%)
3 (3.00%) high mild
6 (6.00%) high severe

RxStreamOrderer::inbound_frame(): Change within noise threshold.
       time:   [108.28 ms 108.34 ms 108.40 ms]
       change: [−1.1266% −0.8775% −0.7128%] (p = 0.00 < 0.05)

Found 20 outliers among 100 measurements (20.00%)
2 (2.00%) low severe
7 (7.00%) low mild
9 (9.00%) high mild
2 (2.00%) high severe

sent::Packets::take_ranges: No change in performance detected.
       time:   [4.4849 µs 4.5788 µs 4.6662 µs]
       change: [−3.2553% +1.1919% +7.1894%] (p = 0.68 > 0.05)

Found 2 outliers among 100 measurements (2.00%)
1 (1.00%) high mild
1 (1.00%) high severe

transfer/pacing-false/varying-seeds/wallclock-time/run: Change within noise threshold.
       time:   [25.008 ms 25.052 ms 25.103 ms]
       change: [−0.5293% −0.3028% −0.0749%] (p = 0.01 < 0.05)

Found 3 outliers among 100 measurements (3.00%)
1 (1.00%) low mild
1 (1.00%) high mild
1 (1.00%) high severe

transfer/pacing-false/varying-seeds/simulated-time/run: No change in performance detected.
       time:   [25.152 s 25.188 s 25.225 s]
       thrpt:  [162.38 KiB/s 162.61 KiB/s 162.85 KiB/s]
change:
       time:   [−0.3352% −0.1129% +0.1018%] (p = 0.29 > 0.05)
       thrpt:  [−0.1017% +0.1130% +0.3363%]
transfer/pacing-true/varying-seeds/wallclock-time/run: Change within noise threshold.
       time:   [25.408 ms 25.469 ms 25.529 ms]
       change: [−1.1634% −0.8145% −0.4614%] (p = 0.00 < 0.05)
transfer/pacing-true/varying-seeds/simulated-time/run: No change in performance detected.
       time:   [24.984 s 25.018 s 25.052 s]
       thrpt:  [163.50 KiB/s 163.72 KiB/s 163.94 KiB/s]
change:
       time:   [−0.1707% +0.0300% +0.2491%] (p = 0.77 > 0.05)
       thrpt:  [−0.2485% −0.0300% +0.1710%]

Found 4 outliers among 100 measurements (4.00%)
1 (1.00%) low mild
3 (3.00%) high mild

transfer/pacing-false/same-seed/wallclock-time/run: Change within noise threshold.
       time:   [25.335 ms 25.370 ms 25.418 ms]
       change: [−1.8344% −1.6088% −1.3807%] (p = 0.00 < 0.05)

Found 5 outliers among 100 measurements (5.00%)
2 (2.00%) low mild
2 (2.00%) high mild
1 (1.00%) high severe

transfer/pacing-false/same-seed/simulated-time/run: No change in performance detected.
       time:   [25.710 s 25.710 s 25.710 s]
       thrpt:  [159.31 KiB/s 159.31 KiB/s 159.31 KiB/s]
change:
       time:   [+0.0000% +0.0000% +0.0000%] (p = NaN > 0.05)
       thrpt:  [+0.0000% +0.0000% +0.0000%]
transfer/pacing-true/same-seed/wallclock-time/run: Change within noise threshold.
       time:   [26.893 ms 26.921 ms 26.953 ms]
       change: [+0.7016% +0.8988% +1.0732%] (p = 0.00 < 0.05)

Found 2 outliers among 100 measurements (2.00%)
1 (1.00%) low mild
1 (1.00%) high severe

transfer/pacing-true/same-seed/simulated-time/run: No change in performance detected.
       time:   [25.675 s 25.675 s 25.675 s]
       thrpt:  [159.53 KiB/s 159.53 KiB/s 159.53 KiB/s]
change:
       time:   [+0.0000% +0.0000% +0.0000%] (p = NaN > 0.05)
       thrpt:  [+0.0000% +0.0000% +0.0000%]

Download data for profiler.firefox.com or download performance comparison data.

@mxinden mxinden marked this pull request as ready for review October 14, 2025 08:09
@github-actions
Copy link
Copy Markdown
Contributor

Failed Interop Tests

QUIC Interop Runner, client vs. server, differences relative to 791fd40.

neqo-latest as client

neqo-latest as server

All results

Succeeded Interop Tests

QUIC Interop Runner, client vs. server

neqo-latest as client

neqo-latest as server

Unsupported Interop Tests

QUIC Interop Runner, client vs. server

neqo-latest as client

neqo-latest as server

Copy link
Copy Markdown
Collaborator

@larseggert larseggert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we should factor that out into a helper? That function is already very long. (I realize you just move code here, but since we're touching it, why not?)

@mxinden
Copy link
Copy Markdown
Member Author

mxinden commented Oct 14, 2025

I have a couple of follow-ups. More to come. Preference for separate pull requests.

@mxinden mxinden added this pull request to the merge queue Oct 14, 2025
Merged via the queue into mozilla:main with commit b90ded6 Oct 14, 2025
130 of 134 checks passed
@mxinden mxinden deleted the outside-loop branch October 14, 2025 10:30
@mxinden mxinden mentioned this pull request Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants