-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bench(transport/recovery): benchmark
SentPackets::take_ranges
(#2253)
* bench: add SentPackets::take_ranges benchmark * Fix clippy lints for pub mod packets, recovery and sent with feat bench In order to benchmark `SentPackets::take_ranges`, we need to make `packets`, `recovery` and `sent` public modules, feature flagged with `bench`. Public modules have stricter clippy lints. This commit addresses the failing clippy lints. * Trigger benchmark * Update neqo-transport/src/recovery/mod.rs Co-authored-by: Martin Thomson <[email protected]> Signed-off-by: Max Inden <[email protected]> * Remove useless is_empty --------- Signed-off-by: Max Inden <[email protected]> Co-authored-by: Martin Thomson <[email protected]>
- Loading branch information
1 parent
2fb1a3b
commit baae4f2
Showing
6 changed files
with
113 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
use std::time::Instant; | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use neqo_common::IpTosEcn; | ||
use neqo_transport::{ | ||
packet::{PacketNumber, PacketType}, | ||
recovery::sent::{SentPacket, SentPackets}, | ||
}; | ||
|
||
fn sent_packets() -> SentPackets { | ||
let mut pkts = SentPackets::default(); | ||
let now = Instant::now(); | ||
// Simulate high bandwidth-delay-product connection. | ||
for i in 0..2_000u64 { | ||
pkts.track(SentPacket::new( | ||
PacketType::Short, | ||
PacketNumber::from(i), | ||
IpTosEcn::default(), | ||
now, | ||
true, | ||
Vec::new(), | ||
100, | ||
)); | ||
} | ||
pkts | ||
} | ||
|
||
/// Confirm that taking a small number of ranges from the front of | ||
/// a large span of sent packets is performant. | ||
/// This is the most common pattern when sending at a higher rate. | ||
/// New acknowledgments will include low-numbered packets, | ||
/// while the acknowledgment rate will ensure that most of the | ||
/// outstanding packets remain in flight. | ||
fn take_ranges(c: &mut Criterion) { | ||
c.bench_function("SentPackets::take_ranges", |b| { | ||
b.iter_batched_ref( | ||
sent_packets, | ||
// Take the first 90 packets, minus some gaps. | ||
|pkts| pkts.take_ranges([70..=89, 40..=59, 10..=29]), | ||
criterion::BatchSize::SmallInput, | ||
); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, take_ranges); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters