Skip to content

Commit

Permalink
bench(transfer): run with and without pacing
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Jul 24, 2024
1 parent 608c0a7 commit dc56f53
Showing 1 changed file with 41 additions and 34 deletions.
75 changes: 41 additions & 34 deletions neqo-transport/benches/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
use std::time::Duration;

use criterion::{criterion_group, criterion_main, BatchSize::SmallInput, Criterion, Throughput};
use neqo_transport::{ConnectionParameters, State};
use test_fixture::{
boxed,
sim::{
connection::{ConnectionNode, ReceiveData, SendData},
connection::{ConnectionNode, ReachState, ReceiveData, SendData},
network::{Delay, TailDrop},
Simulator,
},
Expand All @@ -21,47 +22,53 @@ const JITTER: Duration = Duration::from_millis(10);
const TRANSFER_AMOUNT: usize = 1 << 22; // 4Mbyte

fn benchmark_transfer(c: &mut Criterion, label: &str, seed: &Option<impl AsRef<str>>) {
let mut group = c.benchmark_group("transfer");
group.throughput(Throughput::Bytes(u64::try_from(TRANSFER_AMOUNT).unwrap()));
group.noise_threshold(0.03);
group.bench_function(label, |b| {
b.iter_batched(
|| {
let nodes = boxed![
ConnectionNode::default_client(boxed![SendData::new(TRANSFER_AMOUNT)]),
TailDrop::dsl_uplink(),
Delay::new(ZERO..JITTER),
ConnectionNode::default_server(boxed![ReceiveData::new(TRANSFER_AMOUNT)]),
TailDrop::dsl_downlink(),
Delay::new(ZERO..JITTER),
];
let mut sim = Simulator::new(label, nodes);
if let Some(seed) = &seed {
sim.seed_str(seed);
}
sim.setup()
},
|sim| {
sim.run();
},
SmallInput,
);
});
group.finish();
for pacing in [false, true] {
let mut group = c.benchmark_group(format!("transfer/pacing-{pacing}"));
group.throughput(Throughput::Bytes(u64::try_from(TRANSFER_AMOUNT).unwrap()));
group.noise_threshold(0.03);
group.bench_function(label, |b| {
b.iter_batched(
|| {
let nodes = boxed![
ConnectionNode::new_client(
ConnectionParameters::default().pmtud(true).pacing(pacing),
boxed![ReachState::new(State::Confirmed)],
boxed![SendData::new(TRANSFER_AMOUNT)]
),
TailDrop::dsl_uplink(),
Delay::new(ZERO..JITTER),
ConnectionNode::new_server(
ConnectionParameters::default().pmtud(true).pacing(pacing),
boxed![ReachState::new(State::Confirmed)],
boxed![ReceiveData::new(TRANSFER_AMOUNT)]
),
TailDrop::dsl_downlink(),
Delay::new(ZERO..JITTER),
];
let mut sim = Simulator::new(label, nodes);
if let Some(seed) = &seed {
sim.seed_str(seed);
}
sim.setup()
},
|sim| {
sim.run();
},
SmallInput,
);
});
group.finish();
}
}

fn benchmark_transfer_variable(c: &mut Criterion) {
benchmark_transfer(
c,
"Run multiple transfers with varying seeds",
&std::env::var("SIMULATION_SEED").ok(),
);
benchmark_transfer(c, "varying-seeds", &std::env::var("SIMULATION_SEED").ok());
}

fn benchmark_transfer_fixed(c: &mut Criterion) {
benchmark_transfer(
c,
"Run multiple transfers with the same seed",
"same-seed",
&Some("62df6933ba1f543cece01db8f27fb2025529b27f93df39e19f006e1db3b8c843"),
);
}
Expand Down

0 comments on commit dc56f53

Please sign in to comment.