Extra array copy in Metadata
- Langage dominant
- Java
- Étoiles
- 12.1k
- Forks
- 4k
- Merge moyen
- 2 j 17 h
- PR mergées (30 j)
- 37
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.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par Metadata.storeAdd(), DecompressorRegistry et ClientCallImpl.prepareHeaders() afin de suivre la façon dont les valeurs mises en cache de grpc-accept-encoding et le identity codec sont ajoutés. Vérifiez le comportement d’allocation et de copie lors de la préparation des en-têtes RPC ; le travail est terminé lorsque la réallocation inutile du tableau décrite dans l’issue est évitée sans modifier les en-têtes résultants.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- grpc, java
- Domaine
- backend-api-design, performance
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100