Open
Description
In Metadata.storeAdd()
, the code optimistically tries to allocate a single element array under the premise that most headers will only have a single value.
In DecompressorRegistry
, it tries too to cache the "grpc-accept-encoding" header and builds it ahead of time. In theory, there should only be one such header.
Sadly, ClientCallImpl.prepareHeaders()
always adds the "identity" codec before adding the raw, cached encodings, which makes the Arraylist in Meta data be too small, and have to reallocate larger, which copies the tiny array. This happens on every single RPC and was noticed during profiling.