Skip to content

refactor(transport): replace magic +1 with named constant#3047

Merged
larseggert merged 2 commits into
mozilla:mainfrom
mxinden:datagram-frame-type
Oct 16, 2025
Merged

refactor(transport): replace magic +1 with named constant#3047
larseggert merged 2 commits into
mozilla:mainfrom
mxinden:datagram-frame-type

Conversation

@mxinden
Copy link
Copy Markdown
Member

@mxinden mxinden commented Oct 14, 2025

Connection::max_datagram_size accounts for the datagram frame type length (i.e. + 1). Instead of an omnious + 1, document it through a named constant.


Previously raised in https://github.com/mozilla/neqo/pull/1201/files#r2414614536.

`Connection::max_datagram_size` accounts for the datagram frame type length
(i.e. `+ 1`). Instead of an omnious `+ 1`, document it through a named constant.
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 14, 2025

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3047      +/-   ##
==========================================
- Coverage   93.42%   93.36%   -0.06%     
==========================================
  Files         124      124              
  Lines       35967    35977      +10     
  Branches    35967    35977      +10     
==========================================
- Hits        33601    33589      -12     
- Misses       1522     1544      +22     
  Partials      844      844              
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.76% <ø> (ø)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 14, 2025

🐰 Bencher Report

Branchdatagram-frame-type
TestbedOn-prem
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
google vs. neqo (cubic, paced)📈 view plot
🚷 view threshold
278.67 ms
(+0.35%)Baseline: 277.69 ms
280.32 ms
(99.41%)
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
msquic vs. neqo (cubic, paced)📈 view plot
🚷 view threshold
220.92 ms
(+13.67%)Baseline: 194.35 ms
228.05 ms
(96.87%)
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
neqo vs. google (cubic, paced)📈 view plot
🚷 view threshold
758.49 ms
(+0.11%)Baseline: 757.63 ms
764.86 ms
(99.17%)
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
neqo vs. msquic (cubic, paced)📈 view plot
🚷 view threshold
159.31 ms
(+1.30%)Baseline: 157.27 ms
159.69 ms
(99.76%)
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
neqo vs. neqo (cubic)📈 view plot
🚷 view threshold
91.00 ms
(+0.40%)Baseline: 90.64 ms
94.44 ms
(96.36%)
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
neqo vs. neqo (cubic, paced)📈 view plot
🚷 view threshold
90.30 ms
(-1.68%)Baseline: 91.84 ms
95.55 ms
(94.50%)
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
neqo vs. neqo (reno)📈 view plot
🚷 view threshold
91.17 ms
(+0.63%)Baseline: 90.60 ms
93.95 ms
(97.04%)
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
neqo vs. neqo (reno, paced)📈 view plot
🚷 view threshold
90.52 ms
(-1.40%)Baseline: 91.81 ms
95.41 ms
(94.87%)
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
neqo vs. quiche (cubic, paced)📈 view plot
🚷 view threshold
194.69 ms
(+0.47%)Baseline: 193.78 ms
197.24 ms
(98.71%)
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
neqo vs. s2n (cubic, paced)📈 view plot
🚷 view threshold
223.12 ms
(+1.04%)Baseline: 220.83 ms
223.67 ms
(99.75%)
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
quiche vs. neqo (cubic, paced)📈 view plot
🚷 view threshold
155.71 ms
(+2.04%)Baseline: 152.59 ms
158.24 ms
(98.40%)
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
s2n vs. neqo (cubic, paced)📈 view plot
🚷 view threshold
176.74 ms
(+1.61%)Baseline: 173.95 ms
178.10 ms
(99.24%)
🐰 View full continuous benchmarking report in Bencher

@mxinden mxinden marked this pull request as ready for review October 14, 2025 13:46
Copilot AI review requested due to automatic review settings October 14, 2025 13:46
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 PR refactors the QUIC datagram implementation to replace magic numbers with named constants. It introduces a constant DATAGRAM_FRAME_TYPE_VARINT_LEN to explicitly document the length of datagram frame types in QUIC varint encoding, replacing hardcoded +1 values throughout the codebase.

Key Changes:

  • Introduces DATAGRAM_FRAME_TYPE_VARINT_LEN constant with compile-time assertions
  • Replaces magic +1 values in datagram size calculations with the named constant
  • Updates import statements to include the new constant

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
neqo-transport/src/quic_datagrams.rs Defines the new constant with static assertions and updates datagram frame building logic
neqo-transport/src/connection/mod.rs Imports the new constant and uses it in max datagram size calculation

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

Comment thread neqo-transport/src/quic_datagrams.rs
Comment thread neqo-transport/src/quic_datagrams.rs Outdated
@github-actions
Copy link
Copy Markdown
Contributor

Failed Interop Tests

QUIC Interop Runner, client vs. server, differences relative to e94d8c6.

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

@github-actions
Copy link
Copy Markdown
Contributor

Client/server transfer results

Performance differences relative to e94d8c6.

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 456.1 ± 3.9 449.4 465.1 70.2 ± 8.2
google vs. neqo (cubic, paced) 278.7 ± 4.3 268.9 287.9 114.8 ± 7.4 💔 2.8 1.0%
msquic vs. msquic 188.2 ± 64.4 139.2 476.2 170.1 ± 0.5
msquic vs. neqo (cubic, paced) 220.9 ± 72.5 156.4 575.8 144.8 ± 0.4 -3.5 -1.6%
neqo vs. google (cubic, paced) 758.5 ± 5.0 751.2 779.2 42.2 ± 6.4 0.2 0.0%
neqo vs. msquic (cubic, paced) 159.3 ± 8.0 147.8 184.8 200.9 ± 4.0 1.6 1.0%
neqo vs. neqo (cubic) 91.0 ± 4.8 82.3 107.6 351.6 ± 6.7 💔 1.5 1.6%
neqo vs. neqo (cubic, paced) 90.3 ± 5.2 79.6 107.0 354.4 ± 6.2 -0.0 -0.1%
neqo vs. neqo (reno) 91.2 ± 4.8 79.5 108.9 351.0 ± 6.7 💔 3.1 3.5%
neqo vs. neqo (reno, paced) 90.5 ± 4.0 82.4 99.1 353.5 ± 8.0 -0.7 -0.7%
neqo vs. quiche (cubic, paced) 194.7 ± 4.2 186.8 203.2 164.4 ± 7.6 💔 1.3 0.7%
neqo vs. s2n (cubic, paced) 223.1 ± 4.6 212.4 238.5 143.4 ± 7.0 0.9 0.4%
quiche vs. neqo (cubic, paced) 155.7 ± 5.1 145.6 166.6 205.5 ± 6.3 -0.3 -0.2%
quiche vs. quiche 144.9 ± 4.2 137.9 156.3 220.9 ± 7.6
s2n vs. neqo (cubic, paced) 176.7 ± 5.0 166.6 191.0 181.1 ± 6.4 -0.1 -0.0%
s2n vs. s2n 251.9 ± 29.9 232.8 349.3 127.0 ± 1.1

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

@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results

Performance differences relative to e94d8c6.

1-conn/1-100mb-resp/mtu-1504 (aka. Download)/client: No change in performance detected.
       time:   [193.93 ms 194.28 ms 194.63 ms]
       thrpt:  [513.80 MiB/s 514.71 MiB/s 515.65 MiB/s]
change:
       time:   [−0.3392% +0.0081% +0.3153%] (p = 0.96 > 0.05)
       thrpt:  [−0.3143% −0.0081% +0.3404%]

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

1-conn/10_000-parallel-1b-resp/mtu-1504 (aka. RPS)/client: Change within noise threshold.
       time:   [287.46 ms 289.12 ms 290.80 ms]
       thrpt:  [34.388 Kelem/s 34.588 Kelem/s 34.788 Kelem/s]
change:
       time:   [+0.1301% +0.9370% +1.7736%] (p = 0.02 < 0.05)
       thrpt:  [−1.7427% −0.9283% −0.1299%]

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

1-conn/1-1b-resp/mtu-1504 (aka. HPS)/client: No change in performance detected.
       time:   [28.313 ms 28.390 ms 28.479 ms]
       thrpt:  [35.114   B/s 35.224   B/s 35.319   B/s]
change:
       time:   [−1.2081% −0.5433% +0.0749%] (p = 0.11 > 0.05)
       thrpt:  [−0.0749% +0.5463% +1.2229%]

Found 24 outliers among 100 measurements (24.00%)
14 (14.00%) low severe
1 (1.00%) high mild
9 (9.00%) high severe

1-conn/1-100mb-req/mtu-1504 (aka. Upload)/client: 💔 Performance has regressed.
       time:   [202.00 ms 202.32 ms 202.72 ms]
       thrpt:  [493.28 MiB/s 494.27 MiB/s 495.04 MiB/s]
change:
       time:   [+1.9426% +2.2155% +2.4790%] (p = 0.00 < 0.05)
       thrpt:  [−2.4190% −2.1675% −1.9056%]

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

decode 4096 bytes, mask ff: No change in performance detected.
       time:   [11.586 µs 11.619 µs 11.659 µs]
       change: [−0.6872% −0.2662% +0.1161%] (p = 0.21 > 0.05)

Found 11 outliers among 100 measurements (11.00%)
2 (2.00%) low severe
3 (3.00%) low mild
6 (6.00%) high severe

decode 1048576 bytes, mask ff: No change in performance detected.
       time:   [3.0244 ms 3.0357 ms 3.0490 ms]
       change: [−0.4047% +0.1069% +0.6422%] (p = 0.71 > 0.05)

Found 11 outliers among 100 measurements (11.00%)
1 (1.00%) high mild
10 (10.00%) high severe

decode 4096 bytes, mask 7f: No change in performance detected.
       time:   [19.958 µs 20.044 µs 20.159 µs]
       change: [−1.1262% −0.4170% +0.1626%] (p = 0.23 > 0.05)

Found 17 outliers among 100 measurements (17.00%)
4 (4.00%) low mild
1 (1.00%) high mild
12 (12.00%) high severe

decode 1048576 bytes, mask 7f: No change in performance detected.
       time:   [5.0484 ms 5.0611 ms 5.0743 ms]
       change: [−0.1210% +0.2109% +0.5439%] (p = 0.22 > 0.05)

Found 15 outliers among 100 measurements (15.00%)
15 (15.00%) high severe

decode 4096 bytes, mask 3f: No change in performance detected.
       time:   [8.2561 µs 8.2781 µs 8.3077 µs]
       change: [−1.4166% −0.5252% +0.1577%] (p = 0.22 > 0.05)

Found 7 outliers among 100 measurements (7.00%)
7 (7.00%) high severe

decode 1048576 bytes, mask 3f: No change in performance detected.
       time:   [1.5863 ms 1.5919 ms 1.5989 ms]
       change: [−0.9800% −0.3536% +0.2609%] (p = 0.30 > 0.05)

Found 7 outliers among 100 measurements (7.00%)
7 (7.00%) high severe

1-streams/each-1000-bytes/wallclock-time: No change in performance detected.
       time:   [581.12 µs 582.96 µs 585.13 µs]
       change: [−0.9633% −0.4494% +0.0728%] (p = 0.10 > 0.05)

Found 6 outliers among 100 measurements (6.00%)
1 (1.00%) high mild
5 (5.00%) high severe
1-streams/each-1000-bytes/simulated-time
time: [118.80 ms 119.01 ms 119.21 ms]
thrpt: [8.1919 KiB/s 8.2059 KiB/s 8.2201 KiB/s]
change:
time: [−0.1306% +0.1272% +0.3903%] (p = 0.33 > 0.05)
thrpt: [−0.3887% −0.1270% +0.1308%]
No change in performance detected.
Found 3 outliers among 100 measurements (3.00%)
3 (3.00%) low mild

1000-streams/each-1-bytes/wallclock-time: 💔 Performance has regressed.
       time:   [13.655 ms 13.678 ms 13.702 ms]
       change: [+1.1727% +1.5065% +1.8241%] (p = 0.00 < 0.05)

Found 1 outliers among 100 measurements (1.00%)
1 (1.00%) high mild
1000-streams/each-1-bytes/simulated-time
time: [14.986 s 15.001 s 15.016 s]
thrpt: [66.597 B/s 66.664 B/s 66.730 B/s]
change:
time: [−0.0900% +0.0460% +0.1855%] (p = 0.51 > 0.05)
thrpt: [−0.1852% −0.0459% +0.0900%]
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: Change within noise threshold.
       time:   [47.980 ms 48.224 ms 48.543 ms]
       change: [+0.3244% +0.9790% +1.8227%] (p = 0.00 < 0.05)

Found 3 outliers among 100 measurements (3.00%)
2 (2.00%) high mild
1 (1.00%) high severe
1000-streams/each-1000-bytes/simulated-time
time: [18.919 s 19.097 s 19.275 s]
thrpt: [50.665 KiB/s 51.137 KiB/s 51.617 KiB/s]
change:
time: [−0.6582% +0.5926% +1.8944%] (p = 0.37 > 0.05)
thrpt: [−1.8592% −0.5891% +0.6626%]
No change in performance detected.

coalesce_acked_from_zero 1+1 entries: No change in performance detected.
       time:   [88.095 ns 88.457 ns 88.808 ns]
       change: [−0.7143% −0.1254% +0.4424%] (p = 0.68 > 0.05)

Found 11 outliers among 100 measurements (11.00%)
9 (9.00%) high mild
2 (2.00%) high severe

coalesce_acked_from_zero 3+1 entries: No change in performance detected.
       time:   [106.03 ns 106.43 ns 106.83 ns]
       change: [−4.3619% −1.7345% −0.0597%] (p = 0.13 > 0.05)

Found 13 outliers among 100 measurements (13.00%)
2 (2.00%) high mild
11 (11.00%) high severe

coalesce_acked_from_zero 10+1 entries: No change in performance detected.
       time:   [105.20 ns 105.58 ns 106.04 ns]
       change: [−0.7985% −0.3268% +0.0758%] (p = 0.15 > 0.05)

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

coalesce_acked_from_zero 1000+1 entries: No change in performance detected.
       time:   [88.713 ns 88.911 ns 89.200 ns]
       change: [−0.7862% +0.2642% +1.3808%] (p = 0.63 > 0.05)

Found 9 outliers among 100 measurements (9.00%)
1 (1.00%) high mild
8 (8.00%) high severe

RxStreamOrderer::inbound_frame(): No change in performance detected.
       time:   [108.49 ms 108.64 ms 108.85 ms]
       change: [−0.1335% +0.0237% +0.2178%] (p = 0.82 > 0.05)

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

sent::Packets::take_ranges: No change in performance detected.
       time:   [4.4808 µs 4.5520 µs 4.6099 µs]
       change: [−4.7997% −1.7619% +1.3399%] (p = 0.26 > 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.267 ms 25.315 ms 25.371 ms]
       change: [−0.9149% −0.6326% −0.3611%] (p = 0.00 < 0.05)

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

transfer/pacing-false/varying-seeds/simulated-time/run: No change in performance detected.
       time:   [25.152 s 25.187 s 25.223 s]
       thrpt:  [162.39 KiB/s 162.62 KiB/s 162.85 KiB/s]
change:
       time:   [−0.0975% +0.1067% +0.3096%] (p = 0.32 > 0.05)
       thrpt:  [−0.3086% −0.1066% +0.0976%]

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

transfer/pacing-true/varying-seeds/wallclock-time/run: Change within noise threshold.
       time:   [25.737 ms 25.801 ms 25.866 ms]
       change: [−1.1764% −0.8346% −0.5087%] (p = 0.00 < 0.05)

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

transfer/pacing-true/varying-seeds/simulated-time/run: No change in performance detected.
       time:   [24.993 s 25.035 s 25.078 s]
       thrpt:  [163.33 KiB/s 163.61 KiB/s 163.89 KiB/s]
change:
       time:   [−0.1338% +0.1059% +0.3358%] (p = 0.40 > 0.05)
       thrpt:  [−0.3346% −0.1058% +0.1340%]
transfer/pacing-false/same-seed/wallclock-time/run: Change within noise threshold.
       time:   [25.432 ms 25.464 ms 25.511 ms]
       change: [−1.2885% −1.1023% −0.8872%] (p = 0.00 < 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/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: No change in performance detected.
       time:   [26.656 ms 26.680 ms 26.711 ms]
       change: [−0.1720% −0.0356% +0.1133%] (p = 0.63 > 0.05)

Found 1 outliers among 100 measurements (1.00%)
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.

@larseggert larseggert added this pull request to the merge queue Oct 16, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 16, 2025
@larseggert larseggert merged commit 1cec0d1 into mozilla:main Oct 16, 2025
92 of 94 checks passed
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.

4 participants