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 preference #1727

Closed
wants to merge 2 commits into from

Conversation

CapCap
Copy link

@CapCap CapCap commented Jun 14, 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 encoding enabled has the 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"

tonic/src/codec/compression.rs Outdated Show resolved Hide resolved
tonic/src/codec/compression.rs Outdated Show resolved Hide resolved
tonic/src/codec/compression.rs Show resolved Hide resolved
tonic/src/codec/compression.rs Outdated Show resolved Hide resolved
Allow specifying compression encoding order
@LucioFranco
Copy link
Member

@CapCap I ran CI looks like there are some failures, can you address those and then ping me again when its ready for review and CI is passing? thanks

@djc djc mentioned this pull request Jun 21, 2024
}
}

/// Enable a [`CompressionEncoding`].
/// Every time an encoding is enabled, it is given the lowest priority: i.e first added, highest priority
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about we adopt push_front(), push_back() instead of this?

None
}
})
.max_by_key(|(_, priority)| *priority)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm confused by this. It seems to suggest that we pick the max by priority (which is implemented as index in the array), but in the other comment you said that the array represents highest-to-lowest priority order. So which is it?

@djc
Copy link
Collaborator

djc commented Jun 28, 2024

@CapCap we merged #1757 which is substantially similar to this -- hope that's okay and that it address your issues. If not, please open an issue so we can discuss in more detail what you need.

@djc djc closed this Jun 28, 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.

None yet

3 participants