Skip to content

Commit ae4df56

Browse files
committed
drop criterion variants of iai-covered benches
1 parent 05067d7 commit ae4df56

9 files changed

Lines changed: 199 additions & 535 deletions

File tree

.github/workflows/benchmarks.yml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ jobs:
4141
fail-fast: false
4242
matrix:
4343
bench:
44-
- name: writer_encode
45-
adapter: rust_criterion
46-
command: cargo bench --package dial9-tokio-telemetry --bench writer_encode
47-
- name: codec
48-
adapter: rust_criterion
49-
command: cargo bench --package dial9-trace-format --bench codec
5044
- name: overhead_bench
5145
adapter: json
5246
command: cargo bench --bench overhead_bench -- --bmf 10
@@ -117,19 +111,19 @@ jobs:
117111
BENCHER_BRANCH: ${{ github.event.inputs.bencher_branch != '' && github.event.inputs.bencher_branch || github.ref_name }}
118112
run: |
119113
set -euo pipefail
120-
for entry in \
121-
"dial9-tokio-telemetry:writer_encode_iai" \
122-
"dial9-tokio-telemetry:writer_write_encoded_iai" \
123-
"dial9-tokio-telemetry:threadlocal_encode_iai" \
124-
"dial9-trace-format:codec_iai"; do
125-
pkg="${entry%:*}"; bench="${entry#*:}"
114+
for cmd in \
115+
"cargo bench -p dial9-tokio-telemetry --bench writer_encode_iai" \
116+
"cargo bench -p dial9-tokio-telemetry --bench writer_write_encoded_iai" \
117+
"cargo bench -p dial9-tokio-telemetry --bench threadlocal_encode_iai" \
118+
"cargo bench -p dial9-tokio-telemetry --bench tracing_layer_iai --features tracing-layer" \
119+
"cargo bench -p dial9-trace-format --bench codec_iai"; do
126120
bencher run \
127121
--token '${{ secrets.BENCHER_API_TOKEN }}' \
128122
--branch "$BENCHER_BRANCH" \
129123
--testbed ubuntu-latest \
130124
--adapter rust_iai_callgrind \
131125
--ci-only-thresholds \
132-
"cargo bench -p $pkg --bench $bench"
126+
"$cmd"
133127
done
134128
135129
# iai micro tier on PRs: regression gate against main baseline on
@@ -167,12 +161,12 @@ jobs:
167161
- name: Run iai benches → Bencher (gated vs main)
168162
run: |
169163
set -euo pipefail
170-
for entry in \
171-
"dial9-tokio-telemetry:writer_encode_iai" \
172-
"dial9-tokio-telemetry:writer_write_encoded_iai" \
173-
"dial9-tokio-telemetry:threadlocal_encode_iai" \
174-
"dial9-trace-format:codec_iai"; do
175-
pkg="${entry%:*}"; bench="${entry#*:}"
164+
for cmd in \
165+
"cargo bench -p dial9-tokio-telemetry --bench writer_encode_iai" \
166+
"cargo bench -p dial9-tokio-telemetry --bench writer_write_encoded_iai" \
167+
"cargo bench -p dial9-tokio-telemetry --bench threadlocal_encode_iai" \
168+
"cargo bench -p dial9-tokio-telemetry --bench tracing_layer_iai --features tracing-layer" \
169+
"cargo bench -p dial9-trace-format --bench codec_iai"; do
176170
bencher run \
177171
--token '${{ secrets.BENCHER_API_TOKEN }}' \
178172
--branch '${{ github.head_ref }}' \
@@ -186,5 +180,5 @@ jobs:
186180
--ci-only-thresholds \
187181
--error-on-alert \
188182
--github-actions '${{ secrets.GITHUB_TOKEN }}' \
189-
"cargo bench -p $pkg --bench $bench"
183+
"$cmd"
190184
done

dial9-tokio-telemetry/Cargo.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,12 @@ name = "thread_per_core"
123123
required-features = ["analysis"]
124124

125125
[[bench]]
126-
name = "writer_encode"
127-
harness = false
128-
129-
[[bench]]
130-
name = "threadlocal_encode"
126+
name = "tracing_layer_bench"
131127
harness = false
128+
required-features = ["tracing-layer"]
132129

133130
[[bench]]
134-
name = "tracing_layer_bench"
131+
name = "tracing_layer_iai"
135132
harness = false
136133
required-features = ["tracing-layer"]
137134

dial9-tokio-telemetry/benches/threadlocal_encode.rs

Lines changed: 0 additions & 117 deletions
This file was deleted.
Lines changed: 8 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,20 @@
1-
//! Micro-benchmark for the tracing layer's per-span overhead.
1+
//! Multi-thread bench for the tracing layer.
22
//!
3-
//! Uses a current_thread runtime so block_on runs on the worker thread
4-
//! (which has a TelemetryHandle). This measures the actual encoding cost.
5-
//!
6-
//! Two groups:
7-
//! - `tracing_only`: spans with registry subscriber (no dial9 encoding)
8-
//! - `with_dial9`: spans with Dial9TokioLayer (full encoding path)
9-
//!
10-
//! The difference between the two is the dial9 encoding overhead.
3+
//! Measures span emission throughput as N threads share one
4+
//! `Dial9TokioLayer` (and therefore one schemas Mutex). Each thread
5+
//! emits 100 spans after a barrier sync; the iteration is timed end to
6+
//! end across N ∈ {1, 2, 4, 8, 16, 32}.
117
//!
128
//! Usage:
139
//! cargo bench --bench tracing_layer_bench --features tracing-layer
1410
1511
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
16-
use dial9_tokio_telemetry::telemetry::{NullWriter, TracedRuntime};
1712
use dial9_tokio_telemetry::tracing_layer::Dial9TokioLayer;
13+
use std::sync::{Arc, Barrier};
14+
use tracing::Dispatch;
1815
use tracing_subscriber::prelude::*;
1916

20-
fn bench_tracing_only(c: &mut Criterion) {
21-
let mut group = c.benchmark_group("tracing_only");
22-
23-
// current_thread runtime: block_on IS the worker thread
24-
let mut builder = tokio::runtime::Builder::new_current_thread();
25-
builder.enable_all();
26-
let (runtime, _guard) = TracedRuntime::builder()
27-
.build_and_start(builder, NullWriter)
28-
.unwrap();
29-
30-
// Registry only, no dial9 layer. Use set_default (thread-local) since
31-
// set_global_default can only be called once.
32-
let subscriber = tracing_subscriber::registry();
33-
let _sub_guard = tracing::subscriber::set_default(subscriber);
34-
35-
group.bench_function("baseline", |b| {
36-
b.iter(|| {
37-
runtime.block_on(async { std::hint::black_box(42) });
38-
});
39-
});
40-
41-
for depth in [1, 3, 5] {
42-
group.bench_with_input(BenchmarkId::new("depth", depth), &depth, |b, &depth| {
43-
b.iter(|| {
44-
runtime.block_on(async { nested_spans(depth) });
45-
});
46-
});
47-
}
48-
49-
group.bench_function("with_fields", |b| {
50-
b.iter(|| {
51-
runtime.block_on(async {
52-
let span = tracing::info_span!(
53-
"fielded",
54-
user_id = 42,
55-
method = "GET",
56-
path = "/api/v1/users"
57-
);
58-
let _enter = span.enter();
59-
});
60-
});
61-
});
62-
63-
group.finish();
64-
}
65-
66-
fn bench_with_dial9(c: &mut Criterion) {
67-
let mut group = c.benchmark_group("with_dial9");
68-
69-
let mut builder = tokio::runtime::Builder::new_current_thread();
70-
builder.enable_all();
71-
let (runtime, _guard) = TracedRuntime::builder()
72-
.build_and_start(builder, NullWriter)
73-
.unwrap();
74-
75-
let subscriber = tracing_subscriber::registry().with(Dial9TokioLayer::new());
76-
let _sub_guard = tracing::subscriber::set_default(subscriber);
77-
78-
group.bench_function("baseline", |b| {
79-
b.iter(|| {
80-
runtime.block_on(async { std::hint::black_box(42) });
81-
});
82-
});
83-
84-
for depth in [1, 3, 5] {
85-
group.bench_with_input(BenchmarkId::new("depth", depth), &depth, |b, &depth| {
86-
b.iter(|| {
87-
runtime.block_on(async { nested_spans(depth) });
88-
});
89-
});
90-
}
91-
92-
group.bench_function("with_fields", |b| {
93-
b.iter(|| {
94-
runtime.block_on(async {
95-
let span = tracing::info_span!(
96-
"fielded",
97-
user_id = 42,
98-
method = "GET",
99-
path = "/api/v1/users"
100-
);
101-
let _enter = span.enter();
102-
});
103-
});
104-
});
105-
106-
group.finish();
107-
}
108-
109-
fn nested_spans(depth: usize) {
110-
if depth == 0 {
111-
return;
112-
}
113-
let span = tracing::info_span!("nested", level = depth);
114-
let _enter = span.enter();
115-
nested_spans(depth - 1);
116-
}
117-
11817
fn bench_multi_thread(c: &mut Criterion) {
119-
use std::sync::{Arc, Barrier};
120-
use tracing::Dispatch;
121-
12218
let mut group = c.benchmark_group("multi_thread");
12319
group.measurement_time(std::time::Duration::from_secs(8));
12420

@@ -157,10 +53,5 @@ fn bench_multi_thread(c: &mut Criterion) {
15753
group.finish();
15854
}
15955

160-
criterion_group!(
161-
benches,
162-
bench_tracing_only,
163-
bench_with_dial9,
164-
bench_multi_thread
165-
);
56+
criterion_group!(benches, bench_multi_thread);
16657
criterion_main!(benches);

0 commit comments

Comments
 (0)