Skip to content

Commit 418313c

Browse files
authored
refactor(tls-harness): separate benchmark abstractions (#5444)
1 parent 13a6bdc commit 418313c

File tree

30 files changed

+894
-625
lines changed

30 files changed

+894
-625
lines changed

.github/workflows/bench.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
run: ./generate.sh --skip-tests
3636

3737
- name: Benchmark
38-
working-directory: bindings/rust/standard/bench
38+
working-directory: bindings/rust/standard/benchmarks
3939
run: cargo criterion --message-format json > criterion_output.log
4040

4141
- name: Configure AWS Credentials
@@ -51,6 +51,6 @@ jobs:
5151
if: github.event_name != 'pull_request'
5252
run: |
5353
python3 .github/bin/criterion_to_cloudwatch.py \
54-
--criterion_output_path bindings/rust/standard/bench/criterion_output.log \
54+
--criterion_output_path bindings/rust/standard/benchmarks/criterion_output.log \
5555
--namespace s2n-tls-bench \
5656
--platform ${{ runner.os }}-${{ runner.arch }}

.github/workflows/ci_rust.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -155,26 +155,6 @@ jobs:
155155
echo "${output}"
156156
echo "${output}" | grep -q "test result: ok. 1 passed; 0 failed; 0 ignored;"
157157
158-
# our benchmark testing includes interop tests between s2n-tls, rustls, and
159-
# openssl
160-
harness-interop-tests:
161-
runs-on: ubuntu-latest
162-
steps:
163-
- uses: actions/checkout@v4
164-
165-
- name: Install Rust toolchain
166-
id: toolchain
167-
run: |
168-
rustup toolchain install stable
169-
rustup override set stable
170-
171-
- name: generate bindings
172-
run: ${{env.ROOT_PATH}}/generate.sh --skip-tests
173-
174-
- name: bench tests
175-
working-directory: ${{env.STANDARD_PATH}}/bench
176-
run: cargo test
177-
178158
s2n-tls-binding-examples:
179159
runs-on: ubuntu-latest
180160
steps:

bindings/rust/standard/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[workspace]
22
members = [
3-
"bench",
3+
"benchmarks",
44
"integration",
5-
"s2n-tls-hyper"
5+
"s2n-tls-hyper",
6+
"tls-harness",
67
]

bindings/rust/standard/bench/src/lib.rs

Lines changed: 0 additions & 22 deletions
This file was deleted.

bindings/rust/standard/bench/Cargo.toml renamed to bindings/rust/standard/benchmarks/Cargo.toml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
[package]
2-
name = "bench"
2+
name = "benchmarks"
33
version = "0.1.0"
44
edition = "2021"
5-
publish = false
65

76
[dependencies]
7+
tls-harness = { path = "../tls-harness" }
88
s2n-tls = { path = "../../extended/s2n-tls" }
9-
errno = "0.3"
10-
libc = "0.2"
119
strum = { version = "0.27", features = ["derive"] }
12-
rustls = { version = "0.23" }
13-
rustls-pemfile = { version = "2" }
14-
openssl = { version = "0.10", features = ["vendored"] }
10+
rustls = "0.23.31"
11+
openssl = { version = "0.10.73", features = ["vendored"] }
1512

1613
[dev-dependencies]
1714
criterion = "0.7"
18-
pprof = { version = "0.15", features = ["criterion", "flamegraph"] }
1915
# env_logger and log are used to enable logging for rustls, which can help with
2016
# debugging interop failures
21-
env_logger = "0.11"
22-
log = "0.4"
17+
env_logger = "0.11.8"
18+
log = "0.4.27"
2319

2420
[[bench]]
2521
name = "handshake"
File renamed without changes.

bindings/rust/standard/bench/benches/handshake.rs renamed to bindings/rust/standard/benchmarks/benches/handshake.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use bench::{
5-
harness::{TlsBenchConfig, TlsInfo},
6-
CipherSuite, CryptoConfig, HandshakeType, KXGroup, Mode, OpenSslConnection, RustlsConnection,
7-
S2NConnection, SigType, TlsConnPair, TlsConnection,
8-
};
4+
use benchmarks::*;
95
use criterion::{
106
criterion_group, criterion_main, measurement::WallTime, BatchSize, BenchmarkGroup, Criterion,
117
};
128
use strum::IntoEnumIterator;
9+
use tls_harness::{
10+
cohort::{OpenSslConnection, RustlsConnection, S2NConnection},
11+
harness::TlsInfo,
12+
Mode, SigType, TlsConnPair, TlsConnection,
13+
};
1314

1415
fn bench_handshake_for_library<T>(
1516
bench_group: &mut BenchmarkGroup<WallTime>,

bindings/rust/standard/bench/benches/resumption.rs renamed to bindings/rust/standard/benchmarks/benches/resumption.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use bench::{
5-
harness::{TlsBenchConfig, TlsInfo},
6-
CipherSuite, CryptoConfig, HandshakeType, KXGroup, S2NConnection, SigType, TlsConnPair,
7-
TlsConnection,
8-
};
4+
use benchmarks::*;
5+
use tls_harness::cohort::S2NConnection;
6+
97
use criterion::{
108
criterion_group, criterion_main, measurement::WallTime, BatchSize, BenchmarkGroup, Criterion,
119
};
10+
use tls_harness::{harness::TlsInfo, SigType, TlsConnection};
1211

1312
fn bench_handshake_pair<T>(bench_group: &mut BenchmarkGroup<WallTime>, sig_type: SigType)
1413
where
@@ -21,7 +20,7 @@ where
2120
bench_group.bench_function(format!("{:?}-{}", handshake, T::name()), |b| {
2221
b.iter_batched_ref(
2322
|| {
24-
TlsConnPair::<T, T>::new_bench_pair(
23+
new_bench_pair::<T, T>(
2524
CryptoConfig::new(CipherSuite::default(), KXGroup::default(), sig_type),
2625
handshake,
2726
)
@@ -46,7 +45,7 @@ where
4645
bench_group.bench_function(format!("{:?}-{}", handshake, T::name()), |b| {
4746
b.iter_batched_ref(
4847
|| {
49-
let mut pair = TlsConnPair::<T, T>::new_bench_pair(
48+
let mut pair = new_bench_pair::<T, T>(
5049
CryptoConfig::new(CipherSuite::default(), KXGroup::default(), sig_type),
5150
handshake,
5251
)

bindings/rust/standard/bench/benches/throughput.rs renamed to bindings/rust/standard/benchmarks/benches/throughput.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use bench::{
5-
harness::{TlsBenchConfig, TlsInfo},
6-
CipherSuite, CryptoConfig, HandshakeType, KXGroup, Mode, OpenSslConnection, RustlsConnection,
7-
S2NConnection, SigType, TlsConnPair, TlsConnection,
8-
};
4+
use benchmarks::*;
95
use criterion::{
106
criterion_group, criterion_main, measurement::WallTime, BatchSize, BenchmarkGroup, Criterion,
117
Throughput,
128
};
139
use strum::IntoEnumIterator;
10+
use tls_harness::{
11+
cohort::{OpenSslConnection, RustlsConnection, S2NConnection},
12+
harness::TlsInfo,
13+
Mode, SigType, TlsConnPair, TlsConnection,
14+
};
1415

1516
fn bench_throughput_for_library<T>(
1617
bench_group: &mut BenchmarkGroup<WallTime>,

0 commit comments

Comments
 (0)