Extra allocations in `*TextFormatWriter` because of Java 8 target

オープン
#2,075 コメント 10 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
静か
技術スタック
java

調査の方向性

リンク先の行にある OpenMetricsTextFormatWriter.java から始め、プロジェクトが Java 8 をどのようにターゲットとしているかを確認してください。次に、issue に記載されている artifact の公開と multi-release JAR の選択肢を調査してください。関連する TextFormatWriter コード全体でこれらのアロケーションを削減するための、文書化され maintainer に承認されたアプローチが得られれば完了です。

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

説明

See this line of code:

https://github.com/prometheus/client_java/blob/fa68aa7789c53d54ea1783f120194a3feae7e7b8/prometheus-metrics-exposition-textformats/src/main/java/io/prometheus/metrics/expositionformats/OpenMetricsTextFormatWriter.java#L412

Because of the Java 8 target, the string concatenation gets compiled to something like new StringBuilder().append(name).append(suffix).toString(), which allocates the memory at least twice (for the buffer in the StringBuilder and for the resulting string).

If the code was compiled for at least Java 9, it would use StringConcatFactory, which in this case would allocate the memory only for the resulting string.

Would the maintainers consider publishing multiple artifacts for different Java targets, or using multi-release JARs for the purpose of this and similar optimizations?

主要言語
Java
スター
2.3k
フォーク
833
平均マージ
2日 16時間
マージ済み PR(30日)
86

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

prometheus/client_java のほかの issue

prometheus/client_java の issue をすべて見る

似ている issue

Java の issue をもっと見る

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

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