grpc / grpc/grpc-java

Use CodedInputStream.newInstance(ByteBuffer) for non-segmented messages

Aperta
#2,937 8 commenti 0 reazioni 0 assegnatari Vedi su GitHub
performance
Lingua principale
Java
Stelle
12.1k
Fork
4k
Merge medio
2g 17h
PR unite (30g)
37

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.