Use CodedInputStream.newInstance(ByteBuffer) for non-segmented messages
- Vorherrschende Sprache
- Java
- Sterne
- 12.1k
- Forks
- 4k
- Ø Merge
- 2 T. 17 Std.
- Gemergte PRs (30 T.)
- 37
Beschreibung
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.
Beitragsleitfaden
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- backend, performance
- Issue-Typ
- Refactoring
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100