Extra array copy in Metadata
- Lenguaje dominante
- Java
- Estrellas
- 12.1k
- Forks
- 4k
- Merge medio
- 2 d 17 h
- PR fusionados (30 d)
- 37
Descripción
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.
Guía de contribución
Línea de trabajo
Comience con Metadata.storeAdd(), DecompressorRegistry y ClientCallImpl.prepareHeaders() para rastrear cómo se añaden los valores almacenados en caché de grpc-accept-encoding y el identity codec. Confirme el comportamiento de asignación y copia durante la preparación de las cabeceras RPC; se considera completado cuando se evita la reasignación innecesaria del array descrita en el issue sin cambiar las cabeceras resultantes.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- grpc, java
- Área
- backend-api-design, performance
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100