Extra array copy in Metadata
- Lingua principale
- Java
- Stelle
- 12.1k
- Fork
- 4k
- Merge medio
- 2g 17h
- PR unite (30g)
- 37
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Start with Metadata.storeAdd(), DecompressorRegistry, and ClientCallImpl.prepareHeaders() to trace how the cached grpc-accept-encoding values and the identity codec are added. Confirm the allocation and copy behavior during RPC header preparation; done means avoiding the unnecessary array reallocation described in the issue without changing the resulting headers.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- grpc, java
- Ambito
- backend-api-design, performance
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100