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

confighttp: Including lz4 as supported compression encoding #11108

Conversation

MovieStoreGuy
Copy link
Contributor

Description

Adding in support for lz4 compression into the project, I have seen it perform amazing well in other projects that send a lot of traffic and were originally using gzip or flate.

It would be really great to have for environments that are cpu, memory sensitive.

Link to tracking issue

Fixes 9128

Testing

I've updated the existing test frameworks to include lz4 in their suite

Documentation

I've updated the readmes to include lz4 but I suspect there might be more places to update.

@MovieStoreGuy MovieStoreGuy requested review from a team and jpkrohling September 10, 2024 05:58
@MovieStoreGuy MovieStoreGuy force-pushed the msg/feature-include-lz4-compression branch from 0e22c51 to 623ae28 Compare September 10, 2024 05:59
@MovieStoreGuy
Copy link
Contributor Author

Fixes #9128

@MovieStoreGuy MovieStoreGuy force-pushed the msg/feature-include-lz4-compression branch from d84a596 to 4c355ac Compare September 10, 2024 06:11
Copy link

codecov bot commented Sep 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.92%. Comparing base (8bc3eae) to head (e529edf).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11108   +/-   ##
=======================================
  Coverage   91.91%   91.92%           
=======================================
  Files         430      430           
  Lines       20313    20327   +14     
=======================================
+ Hits        18671    18685   +14     
  Misses       1268     1268           
  Partials      374      374           

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

@MovieStoreGuy MovieStoreGuy force-pushed the msg/feature-include-lz4-compression branch 2 times, most recently from d068cd4 to bc5b681 Compare September 10, 2024 07:50
Copy link
Member

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

This looks good. I reviewed the library's code as well, and I don't think it would be affected by a situation similar to the CVE we had a couple of months ago. That said, would you be able to do a positive confirmation? The test would be to encode a huge blob that compressed to a tiny payload, and see if the decoding would explode the collector.

@MovieStoreGuy MovieStoreGuy force-pushed the msg/feature-include-lz4-compression branch from 12f1972 to 5cf5312 Compare September 11, 2024 05:43
@MovieStoreGuy
Copy link
Contributor Author

This looks good. I reviewed the library's code as well, and I don't think it would be affected by a situation similar to the CVE we had a couple of months ago. That said, would you be able to do a positive confirmation? The test would be to encode a huge blob that compressed to a tiny payload, and see if the decoding would explode the collector.

So this somewhat blew out the original PR intent but, I also noticed that snappy would also be subject to a similar attack considering the steps it would take:

  1. Create a buffer to write uncompress information to
  2. Read the compressed body and write to uncompressed buffer
  3. return uncompressed buffer

To work around this, I wrote a small wrapper that effectively delays the read until it is actually needed however, since we are no longer reading the entire compressed body, that buffer is also coupled with the compressed reader. This allows the wrapper on close to discard any remaining compressed values and return the result of the original buffer's closed state.

@MovieStoreGuy
Copy link
Contributor Author

Turns out I don't actually need the wrapper, I could move the logic into the ServeHTTP method.

I will clean up the commit history once the pipeline is happy.

@MovieStoreGuy MovieStoreGuy force-pushed the msg/feature-include-lz4-compression branch 2 times, most recently from 171bcdc to 5ea30fc Compare September 11, 2024 22:58
@MovieStoreGuy MovieStoreGuy force-pushed the msg/feature-include-lz4-compression branch 3 times, most recently from e77f66c to 3f6fb5f Compare September 16, 2024 00:04
Copy link
Member

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

Looks great now!

@MovieStoreGuy MovieStoreGuy force-pushed the msg/feature-include-lz4-compression branch 2 times, most recently from a27996b to 34f2030 Compare September 18, 2024 04:21
@MovieStoreGuy MovieStoreGuy requested a review from a team as a code owner September 18, 2024 23:01
@MovieStoreGuy MovieStoreGuy force-pushed the msg/feature-include-lz4-compression branch 4 times, most recently from 2e2827d to a4c6dac Compare September 29, 2024 23:45
Having trialed out the compression algorithm in a differnt project, the
performance impact has greatly reduced the amount of resource overhead
with similar compression ratios when compared to flate or gzip.
@MovieStoreGuy MovieStoreGuy force-pushed the msg/feature-include-lz4-compression branch from 9e77f44 to 51ddec9 Compare October 9, 2024 01:23
@dmitryax dmitryax merged commit d2f844f into open-telemetry:main Oct 9, 2024
49 checks passed
@github-actions github-actions bot added this to the next release milestone Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants