Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`Path` object creation and operations dominate CPU time on large resource trees

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

メンテナーはふだん 1 日以内に返信

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
30/100
issue の種類
リファクタリング
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
java
領域
performance

調査の方向性

まず、Path(String) コンストラクター、backslashToForward()、computeSegmentCount()、computeSegments()、equals()、Constants.RUNNING_ON_WINDOWS の場所を特定してください。issue ではソースファイルもテストも指定されていません。プラットフォーム固有の変換、キャッシュ、遅延計算のいずれを選ぶか決める前に、リンクされている heapdump データと既存の IPath.of() API を確認してください。完了の条件は、パスの動作を変更せずに、Path 関連の CPU 時間を測定可能な形で削減することです。

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

説明

enhancement

During analysis of two heapdumps shared here the following issue was discovered as a hotspot that can benefit from optimization:

Performance Data
Metric WITH transitive WITHOUT transitive Ratio
Path.<init>() (µs) 24,933,686 12,598,757 2.0×
Path.computeSegmentCount() (µs) 12,651,521 3,382,879 3.7×
Path.append() (µs) 14,264,596 5,157,314 2.8×
Path.equals() (µs) 6,327,370 1,207,964 5.2×
StringLatin1.replace() (µs) 32,550,291 9,422,718 3.5×
Description

Path objects are created extensively throughout the JDT and Platform. The constructor calls backslashToForward() (which calls String.replace('\\', '/') — accounting for the StringLatin1.replace() overhead) and computeSegmentCount() (which scans the entire path string). The equals() method compares segments array-by-array.

With transitive dependencies, the number of classpath entries, package fragment roots, and resource lookups increases substantially, causing proportionally more Path creation and comparison. The 3.5× increase in StringLatin1.replace() (32.5 seconds total!) is particularly notable — this is pure overhead from the backslashToForward() conversion that happens in every Path constructor, even on Linux where no backslashes exist.

Suggested Fix
  1. Skip backslash conversion on non-Windows platforms: Path(String) unconditionally calls backslashToForward() which does path.replace('\\', '/'). Since this build is running on a specific OS, the conversion could be skipped when File.separatorChar == '/'. (Note: The source already has a forWindows parameter in the internal constructor, but the public Path(String) uses Constants.RUNNING_ON_WINDOWS. Verify this is correctly set.)
  2. Intern or cache frequently used paths: Classpath entry paths, project paths, and source folder paths are created repeatedly. An interning mechanism or flyweight pattern would reduce object creation.
  3. Lazy segment computation: computeSegments() and computeSegmentCount() are called in the constructor. If many Path objects are created only for equality checks or toString(), lazy computation would save work.
  4. Use IPath.of() factory method: If a canonical IPath.of() exists (or should be added), it could return cached instances for common paths.
主要言語
Java
スター
165
フォーク
174
平均マージ
3日 6時間
マージ済み PR(30日)
44

環境構築

はじめの一歩

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

eclipse-platform/eclipse.platform のほかの issue

eclipse-platform/eclipse.platform の issue をすべて見る

似ている issue

Java の issue をもっと見る

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

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