Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Modify perf tests to pass event name correctly to avoid string allocation #2762

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions opentelemetry-appender-tracing/benches/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@
| noop_layer_disabled | 12 ns |
| noop_layer_enabled | 25 ns |
| ot_layer_disabled | 19 ns |
| ot_layer_enabled | 196 ns |
| ot_layer_enabled | 167 ns |

Hardware: Apple M4 Pro
Total Number of Cores: 14 (10 performance and 4 efficiency)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be great if you could also add the CPU speed as part of the details.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to find that detail. @lalitb do you know?

| Test | Average time|
|-----------------------------|-------------|
| log_no_subscriber | 285 ps |
| noop_layer_disabled | 8 ns |
| noop_layer_enabled | 14 ns |
| ot_layer_disabled | 12 ns |
| ot_layer_enabled | 186 ns |
*/

use criterion::{criterion_group, criterion_main, Criterion};
Expand Down Expand Up @@ -94,7 +104,7 @@ fn benchmark_no_subscriber(c: &mut Criterion) {
c.bench_function("log_no_subscriber", |b| {
b.iter(|| {
error!(
name = "CheckoutFailed",
name : "CheckoutFailed",
book_id = "12345",
book_title = "Rust Programming Adventures",
message = "Unable to process checkout."
Expand All @@ -120,7 +130,7 @@ fn benchmark_with_ot_layer(c: &mut Criterion, enabled: bool, bench_name: &str) {
c.bench_function(bench_name, |b| {
b.iter(|| {
error!(
name = "CheckoutFailed",
name : "CheckoutFailed",
book_id = "12345",
book_title = "Rust Programming Adventures",
message = "Unable to process checkout."
Expand All @@ -137,10 +147,10 @@ fn benchmark_with_noop_layer(c: &mut Criterion, enabled: bool, bench_name: &str)
c.bench_function(bench_name, |b| {
b.iter(|| {
error!(
name = "CheckoutFailed",
name : "CheckoutFailed",
book_id = "12345",
book_title = "Rust Programming Adventures",
"Unable to process checkout."
message = "Unable to process checkout."
);
});
});
Expand Down
6 changes: 3 additions & 3 deletions stress/src/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
~31 M/sec

Hardware: AMD EPYC 7763 64-Core Processor - 2.44 GHz, 16vCPUs,
~40 M /sec
~44 M /sec

Hardware: Apple M4 Pro
Total Number of Cores: 14 (10 performance and 4 efficiency)
~40 M/sec
~50 M/sec
~1.1 B/sec (when disabled)
*/

Expand Down Expand Up @@ -88,7 +88,7 @@ fn main() {

fn test_log() {
error!(
name = "CheckoutFailed",
name : "CheckoutFailed",
Copy link
Member Author

@cijothomas cijothomas Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case anyone wondering what this is doing - previous "name" was just any attribute, so the string has to copied to new heap memory.
now, name is part of metadata of tracing, and is &static. Otel stores it as event_name, which is static &str, so allocation and copying is gone.

book_id = "12345",
book_title = "Rust Programming Adventures",
message = "Unable to process checkout."
Expand Down
Loading