Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(transport/recovery): optimize SentPackets::take_ranges #2245

Merged
merged 9 commits into from
Nov 26, 2024

Conversation

mxinden
Copy link
Collaborator

@mxinden mxinden commented Nov 24, 2024

SentPackets keep track of all inflight packets. On receiving an ACK, the acked
packet ranges are removed via SentPackets:take_ranges.

In normal network scenarios one can assume that the amount of packets before a
range is small (e.g. due to reordering) or zero, while the amount of packets
after a range is large, i.e. all remaining in-flight packets.

The previous implementation assumed the opposite, leading to an overhead linear
to the amount of packets after the range. This commit changes the algorithm such
that it is linear to the amount of packets before the range, which again, is
assumed to be smaller than the amount of packets after the acked range.

Fixes #2242.

`SentPackets` keep track of all inflight packets. On receiving an ACK, the acked
packet ranges are removed via `SentPackets:take_ranges`.

In normal network scenarios one can assume that the amount of packets before a
range is small (e.g. due to reordering) or zero, while the amount of packets
after a range is large, i.e. all remaining in-flight packets.

The previous implementation assumed the opposite, leading to an overhead linear
to the amount of packets after the range. This commit changes the algorithm such
that it is linear to the amount of packets before the range, which again, is
assumed to be smaller than the amount of packets after the acked range.
Copy link

codecov bot commented Nov 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.37%. Comparing base (baae4f2) to head (88f1ceb).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2245   +/-   ##
=======================================
  Coverage   95.37%   95.37%           
=======================================
  Files         112      112           
  Lines       36567    36593   +26     
=======================================
+ Hits        34876    34902   +26     
  Misses       1691     1691           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Nov 24, 2024

Failed Interop Tests

QUIC Interop Runner, client vs. server

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

neqo-transport/benches/sent_packets.rs Outdated Show resolved Hide resolved
neqo-transport/src/recovery/sent.rs Outdated Show resolved Hide resolved
neqo-transport/src/recovery/sent.rs Outdated Show resolved Hide resolved
neqo-transport/src/recovery/sent.rs Show resolved Hide resolved
Copy link
Member

@martinthomson martinthomson left a comment

Choose a reason for hiding this comment

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

Land the other first, but this is good to go.

neqo-transport/src/recovery/sent.rs Outdated Show resolved Hide resolved
neqo-transport/src/recovery/sent.rs Show resolved Hide resolved
@mxinden mxinden marked this pull request as ready for review November 26, 2024 09:46
Copy link

Benchmark results

Performance differences relative to baae4f2.

coalesce_acked_from_zero 1+1 entries: No change in performance detected.
       time:   [99.203 ns 99.489 ns 99.775 ns]
       change: [-0.5171% -0.0372% +0.4029%] (p = 0.88 > 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:   [116.89 ns 117.16 ns 117.46 ns]
       change: [-0.5668% -0.2380% +0.1027%] (p = 0.16 > 0.05)

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

coalesce_acked_from_zero 10+1 entries: No change in performance detected.
       time:   [116.61 ns 116.98 ns 117.45 ns]
       change: [-1.4302% -0.6613% -0.0212%] (p = 0.07 > 0.05)

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

coalesce_acked_from_zero 1000+1 entries: No change in performance detected.
       time:   [97.521 ns 97.675 ns 97.847 ns]
       change: [-0.6665% +0.3071% +1.2996%] (p = 0.58 > 0.05)

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

RxStreamOrderer::inbound_frame(): Change within noise threshold.
       time:   [111.80 ms 111.85 ms 111.91 ms]
       change: [-0.1564% -0.0844% -0.0141%] (p = 0.02 < 0.05)

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

SentPackets::take_ranges: :green_heart: Performance has improved.
       time:   [5.5127 µs 5.5878 µs 5.6587 µs]
       change: [-96.565% -96.506% -96.434%] (p = 0.00 < 0.05)

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

transfer/pacing-false/varying-seeds: No change in performance detected.
       time:   [26.109 ms 27.003 ms 27.900 ms]
       change: [-8.9420% -3.8017% +1.2448%] (p = 0.15 > 0.05)
transfer/pacing-true/varying-seeds: No change in performance detected.
       time:   [35.101 ms 36.688 ms 38.306 ms]
       change: [-4.5918% +1.3010% +7.4725%] (p = 0.68 > 0.05)
transfer/pacing-false/same-seed: Change within noise threshold.
       time:   [25.358 ms 26.150 ms 26.933 ms]
       change: [-8.2356% -4.4806% -0.2481%] (p = 0.03 < 0.05)

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

transfer/pacing-true/same-seed: No change in performance detected.
       time:   [40.601 ms 42.542 ms 44.560 ms]
       change: [-10.928% -4.8190% +1.4345%] (p = 0.15 > 0.05)

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

1-conn/1-100mb-resp/mtu-1504 (aka. Download)/client: 💚 Performance has improved.
       time:   [874.51 ms 884.07 ms 893.81 ms]
       thrpt:  [111.88 MiB/s 113.11 MiB/s 114.35 MiB/s]
change:
       time:   [-5.1108% -3.6084% -2.0380%] (p = 0.00 < 0.05)
       thrpt:  [+2.0804% +3.7434% +5.3861%]
1-conn/10_000-parallel-1b-resp/mtu-1504 (aka. RPS)/client: No change in performance detected.
       time:   [318.59 ms 321.46 ms 324.31 ms]
       thrpt:  [30.834 Kelem/s 31.109 Kelem/s 31.388 Kelem/s]
change:
       time:   [-0.7082% +0.7507% +2.0715%] (p = 0.29 > 0.05)
       thrpt:  [-2.0295% -0.7451% +0.7133%]

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:   [33.800 ms 34.013 ms 34.245 ms]
       thrpt:  [29.202  elem/s 29.401  elem/s 29.586  elem/s]
change:
       time:   [+0.0083% +0.7955% +1.6139%] (p = 0.06 > 0.05)
       thrpt:  [-1.5883% -0.7892% -0.0083%]

Found 6 outliers among 100 measurements (6.00%)
2 (2.00%) high mild
4 (4.00%) high severe

1-conn/1-100mb-resp/mtu-1504 (aka. Upload)/client: Change within noise threshold.
       time:   [1.6550 s 1.6761 s 1.6981 s]
       thrpt:  [58.888 MiB/s 59.664 MiB/s 60.422 MiB/s]
change:
       time:   [+0.6461% +2.5232% +4.4351%] (p = 0.01 < 0.05)
       thrpt:  [-4.2468% -2.4611% -0.6419%]

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

Client/server transfer results

Transfer of 33554432 bytes over loopback.

Client Server CC Pacing MTU Mean [ms] Min [ms] Max [ms]
gquiche gquiche 1504 576.8 ± 136.0 509.1 959.2
neqo gquiche reno on 1504 802.1 ± 59.8 757.0 960.1
neqo gquiche reno 1504 783.2 ± 53.2 743.0 929.1
neqo gquiche cubic on 1504 793.1 ± 65.4 744.1 966.2
neqo gquiche cubic 1504 766.5 ± 5.9 755.1 773.8
msquic msquic 1504 192.2 ± 93.6 100.4 322.1
neqo msquic reno on 1504 279.1 ± 94.7 213.4 482.7
neqo msquic reno 1504 244.0 ± 70.9 197.4 394.4
neqo msquic cubic on 1504 271.6 ± 85.2 210.2 462.7
neqo msquic cubic 1504 276.7 ± 89.6 208.6 475.4
gquiche neqo reno on 1504 695.5 ± 108.1 564.0 873.4
gquiche neqo reno 1504 720.9 ± 121.8 567.1 907.4
gquiche neqo cubic on 1504 718.4 ± 92.3 573.7 863.5
gquiche neqo cubic 1504 687.3 ± 79.6 572.1 798.8
msquic neqo reno on 1504 512.1 ± 38.5 478.1 604.0
msquic neqo reno 1504 484.0 ± 19.7 465.7 525.5
msquic neqo cubic on 1504 520.6 ± 74.5 475.7 708.9
msquic neqo cubic 1504 491.1 ± 36.3 463.7 587.2
neqo neqo reno on 1504 647.5 ± 156.0 479.1 1004.4
neqo neqo reno 1504 497.5 ± 45.0 440.5 586.2
neqo neqo cubic on 1504 558.5 ± 45.2 502.7 652.0
neqo neqo cubic 1504 582.8 ± 67.6 518.5 733.1

⬇️ Download logs

@mxinden
Copy link
Collaborator Author

mxinden commented Nov 26, 2024

For the record, highlighting the performance improvement of this pull request compared to baseline main.

SentPackets::take_ranges: :green_heart: Performance has improved.

   time:   [5.5127 µs 5.5878 µs 5.6587 µs]
   change: [-96.565% -96.506% -96.434%] (p = 0.00 < 0.05)

Found 4 outliers among 100 measurements (4.00%)

@mxinden mxinden added this pull request to the merge queue Nov 26, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 26, 2024
@mxinden mxinden added this pull request to the merge queue Nov 26, 2024
Merged via the queue into mozilla:main with commit c9db498 Nov 26, 2024
64 checks passed
@mxinden mxinden deleted the sent-packets branch November 26, 2024 11:54
@larseggert
Copy link
Collaborator

We got to figure out these issues with idle_timeout_crazy_rtt; it's becoming annoying.

@mxinden
Copy link
Collaborator Author

mxinden commented Nov 26, 2024

We got to figure out these issues with idle_timeout_crazy_rtt; it's becoming annoying.

Agreed. @larseggert I will look into it once I am done releasing Neqo v0.11.0 (#2239).

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.

Optimize SentPackets::take_ranges
3 participants