netty: Support never-indexed metadata keys - #12976
Conversation
|
I vibe coded a benchmark to demonstrate the effect here: https://github.com/petedmarsh/grpc-java/pull/new/netty-never-index-metadata-benchmark Potentially either a lof of CPU or bytes transferred save depending on your mix of headers. |
| */ | ||
| @CanIgnoreReturnValue | ||
| public NettyChannelBuilder neverIndexMetadataKey(Metadata.Key<?> key) { | ||
| neverIndexedMetadataKeys.add(AsciiString.of(checkNotNull(key, "key").name())); |
There was a problem hiding this comment.
Should we add these methods to NettyServerBuilder as well to configure NettyServerHandler so that servers can also prevent HPACK dynamic table bloat on client peers.
| * default, no metadata keys are configured as never indexed. | ||
| */ | ||
| @CanIgnoreReturnValue | ||
| public NettyChannelBuilder neverIndexMetadataKey(Metadata.Key<?> key) { |
There was a problem hiding this comment.
Add @since 1.84.0 annotation to both methods. Also add @ExperimentalApi annotation.
| @CanIgnoreReturnValue | ||
| public NettyChannelBuilder neverIndexMetadataKeys( | ||
| Collection<? extends Metadata.Key<?>> keys) { | ||
| for (Metadata.Key<?> key : checkNotNull(keys, "keys")) { |
There was a problem hiding this comment.
If the input collection contains a null element after several valid keys, a NPE is thrown after the preceding keys have already been added to the builder's internal neverIndexedMetadataKeys set. It is cleaner to validate all elements up-front before mutation to prevent leaving the builder in a partially modified state.
|
Thanks @kannanjgithub - comments addresed |
Add NettyChannelBuilder and NettyServerBuilder APIs so callers can mark selected outbound metadata keys for HPACK's never-indexed literal representation. High-cardinality metadata values provide little compression benefit and can churn the peer's dynamic HPACK table. Keeping them out avoids unnecessary insertion and eviction work while preserving dynamic indexing for other headers. Propagate immutable normalized metadata names through client and server transports and use them in Netty's HPACK sensitivity detector. Add unit and interoperability coverage. Generated with AI using OpenAI Codex (GPT-5). Co-Authored-By: Codex <noreply@openai.com>
02d6ba5 to
eada9e2
Compare
Add NettyChannelBuilder.neverIndexMetadataKey() and neverIndexMetadataKeys() so callers can mark selected outbound metadata keys for HPACK's never-indexed literal representation.
High-cardinality metadata values provide little compression benefit and can churn the server's dynamic HPACK table. Keeping them out of the table avoids unnecessary insertion and eviction work while preserving dynamic indexing for other headers.
Propagate an immutable set of normalized metadata names through the client transport and use it in Netty's HPACK sensitivity detector. Add unit and interoperability coverage.
Generated with AI using OpenAI Codex (GPT-5).