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

Allow specifying compression encoding order #1

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

CapCap
Copy link

@CapCap CapCap commented Jun 12, 2024

Motivation

Although Zstd is significantly more performant (> 5x in our testing), the default chosen encoding remains Gzip when both are enabled. This blocks us from being able to gradually roll out zstd support for existing downstream clients before disabling Gzip entirely.

Solution

This PR introduces a feature that allows for specifying the order of compression encodings. The key changes include:
- Updated EnabledCompressionEncodings to support ordering/prioritizing multiple compression encodings such as Gzip and Zstd.
- Modified the enable function to reorder encodings based on the priority, ensuring the most recently enabled encoding has the lowest priority- i.e "first in highest priority"
- Added new tests to validate the correct priority ordering of compression encodings settings.
- Make sure GRPC correctly copies this order for each connection as well.

The behavior is now "given a list of supported encodings, I will pick the highest priority one that I support"

@CapCap CapCap requested a review from grao1991 June 12, 2024 02:49
tonic/src/codec/compression.rs Outdated Show resolved Hide resolved
tonic/src/codec/compression.rs Outdated Show resolved Hide resolved
@CapCap CapCap force-pushed the max_specify_encoding_orderings branch 2 times, most recently from b1a5936 to 6f5922b Compare June 12, 2024 04:20
@CapCap CapCap changed the base branch from master to v0.11.x June 12, 2024 04:29
@CapCap CapCap force-pushed the max_specify_encoding_orderings branch from 6f5922b to b584ecd Compare June 12, 2024 04:30
@CapCap CapCap requested a review from grao1991 June 12, 2024 06:02
@CapCap CapCap force-pushed the max_specify_encoding_orderings branch 4 times, most recently from d6288d7 to be08ac2 Compare June 13, 2024 00:51
tonic/src/codec/compression.rs Outdated Show resolved Hide resolved
@@ -30,22 +38,58 @@ impl EnabledCompressionEncodings {
}

/// Enable a [`CompressionEncoding`].
/// Every time an encoding is enabled, it is given the lowest priority (the start of the list)
/// In order to enable both `gzip` and `zstd`, and have zstd have higher priority, you would call:
Copy link

Choose a reason for hiding this comment

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

Nice, good clear comment.

tonic/src/codec/compression.rs Outdated Show resolved Hide resolved
tonic/src/codec/compression.rs Show resolved Hide resolved
@CapCap CapCap force-pushed the max_specify_encoding_orderings branch from be08ac2 to e07fdca Compare June 14, 2024 17:37
@CapCap CapCap force-pushed the max_specify_encoding_orderings branch from e07fdca to e7f9d3f Compare June 14, 2024 18:57
@CapCap CapCap merged commit 0da1ba8 into v0.11.x Jun 14, 2024
@CapCap CapCap deleted the max_specify_encoding_orderings branch June 14, 2024 19:55
CapCap added a commit that referenced this pull request Jun 15, 2024
Allow specifying compression encoding order
CapCap added a commit that referenced this pull request Jun 15, 2024
Allow specifying compression encoding order
CapCap added a commit that referenced this pull request Jun 15, 2024
Allow specifying compression encoding order
CapCap added a commit that referenced this pull request Jun 15, 2024
Allow specifying compression encoding order
CapCap added a commit that referenced this pull request Jun 18, 2024
Allow specifying compression encoding order
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.

3 participants