Skip to content

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
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

lalitb
Copy link
Member

@lalitb lalitb commented Jun 4, 2025

Changes

  • Added benchmark test

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@lalitb lalitb requested a review from a team as a code owner June 4, 2025 04:43
@lalitb lalitb changed the title [Geneva Exporter] Optimize lz4 compression, and add benchmark fix: [Geneva Exporter] Optimize lz4 compression, and add benchmark Jun 4, 2025
Copy link

codecov bot commented Jun 4, 2025

Codecov Report

Attention: Patch coverage is 19.23077% with 21 lines in your changes missing coverage. Please review.

Project coverage is 47.9%. Comparing base (ea3320a) to head (b6e078b).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
...metry-exporter-geneva/geneva-uploader/src/bench.rs 0.0% 21 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main    #284     +/-   ##
=======================================
- Coverage   48.0%   47.9%   -0.1%     
=======================================
  Files         60      61      +1     
  Lines       8576    8602     +26     
=======================================
+ Hits        4121    4126      +5     
- Misses      4455    4476     +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@utpilla
Copy link
Contributor

utpilla commented Jun 9, 2025

@lalitb We want the tests related to the changes in the PR to be run in the CI. Could we update the workspace to include these projects first?

# "opentelemetry-exporter-geneva/geneva-uploader",
# "opentelemetry-exporter-geneva/geneva-uploader-ffi",
# "opentelemetry-exporter-geneva/opentelemetry-exporter-geneva",

- No significant regressions or improvements detected.
- Machine: WSL2, Linux 6.6.36, AMD EPYC 7763 64-core (8 cores visible), 62GiB RAM, 16GiB swap.
*/
#[test]
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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 under src/. That way you can access private methods of the crate.

Copy link
Member Author

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.

#[test]
fn lz4_benchmark() {
let mut criterion = Criterion::default()
.sample_size(100)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any specific reason to be changing the default sample size and measurement time?

Copy link
Member Author

Choose a reason for hiding this comment

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

The benchmark was not completing in default time, so the sample size was changed. But not getting the issue anymore, so removed this.

@lalitb
Copy link
Member Author

lalitb commented Jun 9, 2025

Could we update the workspace to include these projects first?

Sure.

let max_chunk_compressed = get_maximum_output_size(CHUNK_SIZE);
let num_chunks = input.len().div_ceil(CHUNK_SIZE);
let mut output = Vec::with_capacity(num_chunks * (4 + max_chunk_compressed));
let mut temp_buf = vec![0u8; max_chunk_compressed];
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't follow. We had removed all temporary buffer allocation. Why are we introducing it again?

Copy link
Member Author

@lalitb lalitb Jun 11, 2025

Choose a reason for hiding this comment

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

Good point. This is not correct. I see improvements in the small size with this, but not with large size. Have reverted the optimization efforts - the PR is now limited to adding the benchmark! Thanks for catching this.

return Ok(Vec::new());
}
// Special case: very small data (less than one chunk)
if input.len() <= CHUNK_SIZE {
Copy link
Contributor

Choose a reason for hiding this comment

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

From the PR description:

Added a fast path for small inputs (≤ one chunk): compresses the whole input in a single step, avoiding the main loop and extra allocations.

It doesn't look like there is anything special happening for this case. It would have been same (cost-wise) even if you didn't have a special case for this. The while loop would have only run once.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree.

@lalitb lalitb changed the title fix: [Geneva Exporter] Optimize lz4 compression, and add benchmark fix: [Geneva Exporter] Add LZ4 compression benchmark Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants