-
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.
perf(bin): add criterion benchmarks (#1758)
* perf(bin): add criterion benchmarks Wraps the `neqo-client` and `neqo-server` code, starts the server and runs various benchmarks through the client. Benchmarks: - single-request-1gb - single-request-1mb - requests-per-second - handshakes-per-second * Rename benchmark instances * Turn off logging * Remove 100mb sample size restriction * Use v6 * Remove 1gb It just takes too long on the bench machine * Use /dev/null * rework imports * Fix import * Test without CPU pinning * Revert "Test without CPU pinning" This reverts commit a0ef46a. * Pin all but neqo-bin to CPU 0 * Quote package * Add rational for neqo-bin handling * Rework tuples * Pin first * Just duplicate the two calls * Add --workspace flag * Remove taskset from neqo-bin --------- Co-authored-by: Martin Thomson <[email protected]>
- Loading branch information
1 parent
efc4813
commit 36fae62
Showing
12 changed files
with
262 additions
and
42 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
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,92 @@ | ||
// 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::{path::PathBuf, str::FromStr}; | ||
|
||
use criterion::{criterion_group, criterion_main, BatchSize, Criterion, Throughput}; | ||
use neqo_bin::{client, server}; | ||
use tokio::runtime::Runtime; | ||
|
||
struct Benchmark { | ||
name: String, | ||
requests: Vec<u64>, | ||
/// Download resources in series using separate connections. | ||
download_in_series: bool, | ||
sample_size: Option<usize>, | ||
} | ||
|
||
fn transfer(c: &mut Criterion) { | ||
neqo_common::log::init(Some(log::LevelFilter::Off)); | ||
neqo_crypto::init_db(PathBuf::from_str("../test-fixture/db").unwrap()); | ||
|
||
let done_sender = spawn_server(); | ||
|
||
for Benchmark { | ||
name, | ||
requests, | ||
download_in_series, | ||
sample_size, | ||
} in [ | ||
Benchmark { | ||
name: "1-conn/1-100mb-resp (aka. Download)".to_string(), | ||
requests: vec![100 * 1024 * 1024], | ||
download_in_series: false, | ||
sample_size: Some(10), | ||
}, | ||
Benchmark { | ||
name: "1-conn/10_000-1b-seq-resp (aka. RPS)".to_string(), | ||
requests: vec![1; 10_000], | ||
download_in_series: false, | ||
sample_size: None, | ||
}, | ||
Benchmark { | ||
name: "100-seq-conn/1-1b-resp (aka. HPS)".to_string(), | ||
requests: vec![1; 100], | ||
download_in_series: true, | ||
sample_size: None, | ||
}, | ||
] { | ||
let mut group = c.benchmark_group(name); | ||
group.throughput(if requests[0] > 1 { | ||
assert_eq!(requests.len(), 1); | ||
Throughput::Bytes(requests[0]) | ||
} else { | ||
Throughput::Elements(requests.len() as u64) | ||
}); | ||
if let Some(size) = sample_size { | ||
group.sample_size(size); | ||
} | ||
group.bench_function("client", |b| { | ||
b.to_async(Runtime::new().unwrap()).iter_batched( | ||
|| client::client(client::Args::new(&requests, download_in_series)), | ||
|client| async move { | ||
client.await.unwrap(); | ||
}, | ||
BatchSize::PerIteration, | ||
); | ||
}); | ||
group.finish(); | ||
} | ||
|
||
done_sender.send(()).unwrap(); | ||
} | ||
|
||
fn spawn_server() -> tokio::sync::oneshot::Sender<()> { | ||
let (done_sender, mut done_receiver) = tokio::sync::oneshot::channel(); | ||
std::thread::spawn(move || { | ||
Runtime::new().unwrap().block_on(async { | ||
let mut server = Box::pin(server::server(server::Args::default())); | ||
tokio::select! { | ||
_ = &mut done_receiver => {} | ||
_ = &mut server => {} | ||
} | ||
}); | ||
}); | ||
done_sender | ||
} | ||
|
||
criterion_group!(benches, transfer); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// 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 clap::Parser; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), neqo_bin::client::Error> { | ||
let args = neqo_bin::client::Args::parse(); | ||
|
||
neqo_bin::client::client(args).await | ||
} |
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,14 @@ | ||
// 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 clap::Parser; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), std::io::Error> { | ||
let args = neqo_bin::server::Args::parse(); | ||
|
||
neqo_bin::server::server(args).await | ||
} |
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
Oops, something went wrong.