Extra array copy in Metadata
- 主要言語
- Java
- スター
- 12.1k
- フォーク
- 4k
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 37
説明
In `Metadata.storeAdd()`, the code optimistically tries to allocate a single element array under the premise that most headers will only have a single value.
In `DecompressorRegistry`, it tries too to cache the "grpc-accept-encoding" header and builds it ahead of time. In theory, there should only be one such header.
Sadly, `ClientCallImpl.prepareHeaders()` always adds the "identity" codec before adding the raw, cached encodings, which makes the Arraylist in Meta data be too small, and have to reallocate larger, which copies the tiny array. This happens on every single RPC and was noticed during profiling.
コントリビューションガイド
調査の方向性
Metadata.storeAdd()、DecompressorRegistry、ClientCallImpl.prepareHeaders() から始めて、キャッシュされた grpc-accept-encoding の値と identity codec がどのように追加されるかを追跡します。RPC ヘッダーの準備中のアロケーションとコピーの動作を確認します。issue で説明されている不要な配列の再アロケーションを、結果のヘッダーを変更せずに回避できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- grpc, java
- 領域
- backend-api-design, performance
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100