-
Notifications
You must be signed in to change notification settings - Fork 61
fix: [Geneva Exporter] Add LZ4 compression benchmark #284
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
Open
lalitb
wants to merge
7
commits into
open-telemetry:main
Choose a base branch
from
lalitb:optNbench-lz4
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3354c92
add bench
lalitb 05dcea2
fix
lalitb 307afa8
Merge branch 'main' into optNbench-lz4
lalitb ff2808a
Merge branch 'main' into optNbench-lz4
lalitb 99a9868
fix
lalitb 02daa49
use default criterion conf
lalitb b6e078b
Merge branch 'main' into optNbench-lz4
lalitb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
46 changes: 46 additions & 0 deletions
46
opentelemetry-exporter-geneva/geneva-uploader/src/bench.rs
This file contains hidden or 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,46 @@ | ||
#[cfg(test)] | ||
mod benchmarks { | ||
use crate::payload_encoder::lz4_chunked_compression::lz4_chunked_compression; | ||
use criterion::{BenchmarkId, Criterion, Throughput}; | ||
use rand::{rngs::StdRng, Rng, SeedableRng}; | ||
use std::hint::black_box; | ||
|
||
fn setup_test_data(size: usize) -> Vec<u8> { | ||
let mut data = vec![0u8; size]; | ||
let mut rng = StdRng::seed_from_u64(42); | ||
rng.fill(&mut data[..]); | ||
data | ||
} | ||
|
||
/* | ||
- Criterion benchmarks (lz4_chunked_compression, lz4_flex backend): | ||
|
||
| Input size | Median time | Throughput | | ||
|-------------|--------------------|--------------------| | ||
| 1 byte | ~533 ns | ~1.6 MiB/s | | ||
| 1 KiB | ~597 ns | ~1.5 GiB/s | | ||
| 1 MiB | ~42 us | ~22.1 GiB/s | | ||
- No significant regressions or improvements detected. | ||
- Machine: Apple M4 Pro, 24 GB, Total Number of Cores: 14 (10 performance and 4 efficiency) | ||
*/ | ||
#[test] | ||
#[ignore = "benchmark on crate private, ignored by default during normal test runs"] | ||
/// To run: $cargo test --release lz4_benchmark -- --nocapture --ignored | ||
fn lz4_benchmark() { | ||
let mut criterion = Criterion::default(); | ||
|
||
let mut group = criterion.benchmark_group("lz4_compression"); | ||
|
||
for size in [1, 1024, 1024 * 1024] { | ||
let data = setup_test_data(size); | ||
|
||
group.throughput(Throughput::Bytes(size as u64)); | ||
group.bench_with_input(BenchmarkId::new("lz4_flex", size), &data, |b, data| { | ||
b.iter(|| black_box(lz4_chunked_compression(data).unwrap())); | ||
}); | ||
} | ||
|
||
group.finish(); | ||
criterion.final_summary(); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
opentelemetry-exporter-geneva/geneva-uploader/src/payload_encoder/mod.rs
This file contains hidden or 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 +1 @@ | ||
mod lz4_chunked_compression; | ||
pub(crate) mod lz4_chunked_compression; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This setup looks a bit unusual. Does this mean that we would be running this benchmark in the CI test? I think we only want to run this with
cargo bench
. Could we follow something similar to how we have added benchmarks in other methods?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is testing the crate private code, which won't be possible under
benches/*
. Let me see if this is something which can be re-exported as public specifically for benchmark, and then add it there. Else, will make it to be ignored with cargo test.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. I would suggest using
[[bench]]
target in that case and keep the benchmarks undersrc/
. That way you can access private methods of the crate.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, have made to be ignored by cargo test.