grpc / grpc/grpc-java

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

Ouverte
#2,937 8 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
performance
Langage dominant
Java
Étoiles
12.1k
Forks
4k
Merge moyen
2 j 17 h
PR mergées (30 j)
37

Description

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.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
java
Domaine
backend, performance
Type d'issue
Refactorisation
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.