-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conversation
dba38a5
to
5cc673b
Compare
Allow specifying compression encoding order
@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 |
} | ||
} | ||
|
||
/// Enable a [`CompressionEncoding`]. | ||
/// Every time an encoding is enabled, it is given the lowest priority: i.e first added, highest priority |
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.
How about we adopt push_front()
, push_back()
instead of this?
None | ||
} | ||
}) | ||
.max_by_key(|(_, priority)| *priority) |
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.
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?
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"