Use CodedInputStream.newInstance(ByteBuffer) for non-segmented messages
- Lenguaje dominante
- Java
- Estrellas
- 12.1k
- Forks
- 4k
- Merge medio
- 2 d 17 h
- PR fusionados (30 d)
- 37
Descripción
This is to improve the decode performance of small messages (<16 KB) to avoid a message-sized allocation and copy.
Protobuf already has an optimized code path for [decoding a direct `ByteBuffer`](https://github.com/google/protobuf/blob/v3.2.0/java/core/src/main/java/com/google/protobuf/CodedInputStream.java#L141). We currently [copy to a `byte[]`](https://github.com/grpc/grpc-java/blob/v1.2.0/protobuf-lite/src/main/java/io/grpc/protobuf/lite/ProtoLiteUtils.java#L139), but that could be avoided because small messages will commonly be in a single `ByteBuffer`.
This will require adding a new interface for retrieving the `ByteBuffer` from the `InputStream`. I'm uncertain whether the interface should support returning multiple `ByteBuffer`s.
Guía de contribución
Línea de trabajo
Read protobuf-lite/src/main/java/io/grpc/protobuf/lite/ProtoLiteUtils.java around the current byte[] copy, then compare it with CodedInputStream.java's direct ByteBuffer path. Determine how the InputStream interface should expose ByteBuffer data, including the stated question about multiple buffers; done means non-segmented small messages can use the optimized path without the message-sized allocation and copy.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- backend, performance
- Tipo de issue
- Refactorización
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100