-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add benchmark for SpanConcentrator (#603)
* Add benchmark for concentrator * Disable autobenches * Change bench name
- Loading branch information
1 parent
081589b
commit c035537
Showing
7 changed files
with
91 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,7 @@ | ||
// Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
use criterion::criterion_main; | ||
|
||
mod span_concentrator_bench; | ||
|
||
criterion_main!(span_concentrator_bench::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,72 @@ | ||
// Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
use std::{ | ||
collections::HashMap, | ||
time::{self, Duration, SystemTime}, | ||
}; | ||
|
||
use criterion::{criterion_group, Criterion}; | ||
use data_pipeline::span_concentrator::SpanConcentrator; | ||
use datadog_trace_protobuf::pb; | ||
|
||
fn get_bucket_start(now: SystemTime, n: u64) -> i64 { | ||
let start = now.duration_since(time::UNIX_EPOCH).unwrap() + Duration::from_secs(10 * n); | ||
start.as_nanos() as i64 | ||
} | ||
|
||
fn get_span(now: SystemTime, trace_id: u64, span_id: u64) -> pb::Span { | ||
let mut metrics = HashMap::from([("_dd.measured".to_string(), 1.0)]); | ||
if span_id == 1 { | ||
metrics.insert("_dd.top_level".to_string(), 1.0); | ||
} | ||
let mut meta = HashMap::from([("db_name".to_string(), "postgres".to_string())]); | ||
if span_id % 3 == 0 { | ||
meta.insert("bucket_s3".to_string(), "aws_bucket".to_string()); | ||
} | ||
pb::Span { | ||
trace_id, | ||
span_id, | ||
service: "test-service".to_string(), | ||
name: "test-name".to_string(), | ||
resource: format!("test-{trace_id}"), | ||
error: (span_id % 2) as i32, | ||
metrics, | ||
meta, | ||
parent_id: span_id - 1, | ||
start: get_bucket_start(now, trace_id), | ||
duration: span_id as i64 % Duration::from_secs(10).as_nanos() as i64, | ||
..Default::default() | ||
} | ||
} | ||
|
||
pub fn criterion_benchmark(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("concentrator"); | ||
let now = SystemTime::now() - Duration::from_secs(10 * 100); | ||
let concentrator = SpanConcentrator::new( | ||
Duration::from_secs(10), | ||
now, | ||
true, | ||
true, | ||
vec!["db_name".to_string(), "bucket_s3".to_string()], | ||
); | ||
let mut spans = vec![]; | ||
for trace_id in 1..100 { | ||
for span_id in 1..100 { | ||
spans.push(get_span(now, trace_id, span_id)); | ||
} | ||
} | ||
group.bench_function("add_spans_to_concentrator", |b| { | ||
b.iter_batched_ref( | ||
|| (concentrator.clone(), spans.clone()), | ||
|data| { | ||
let concentrator = &mut data.0; | ||
let spans = &data.1; | ||
for span in spans { | ||
concentrator.add_span(span); | ||
} | ||
}, | ||
criterion::BatchSize::LargeInput, | ||
); | ||
}); | ||
} | ||
criterion_group!(benches, criterion_benchmark); |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
mod span_concentrator; | ||
pub mod span_concentrator; | ||
pub mod trace_exporter; |
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