grpc / grpc/grpc-java

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

オープン
#2,937 コメント 8 件 リアクション 0 件 担当者 0 名 GitHub で見る
performance
主要言語
Java
スター
12.1k
フォーク
4k
平均マージ
2日 17時間
マージ済み PR(30日)
37

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
backend, performance
issue の種類
リファクタリング
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。