`Path` object creation and operations dominate CPU time on large resource trees
メンテナーはふだん 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 の本文から書いたものです。
説明
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
- Skip backslash conversion on non-Windows platforms:
Path(String)unconditionally callsbackslashToForward()which doespath.replace('\\', '/'). Since this build is running on a specific OS, the conversion could be skipped whenFile.separatorChar == '/'. (Note: The source already has aforWindowsparameter in the internal constructor, but the publicPath(String)usesConstants.RUNNING_ON_WINDOWS. Verify this is correctly set.) - 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.
- Lazy segment computation:
computeSegments()andcomputeSegmentCount()are called in the constructor. If manyPathobjects are created only for equality checks ortoString(), lazy computation would save work. - Use
IPath.of()factory method: If a canonicalIPath.of()exists (or should be added), it could return cached instances for common paths.
- 主要言語
- Java
- スター
- 165
- フォーク
- 174
- 平均マージ
- 3日 6時間
- マージ済み PR(30日)
- 44
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
eclipse-platform/eclipse.platform のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
eclipse-platform/eclipse.platform#3019 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
eclipse-platform/eclipse.platform#2940 ·
メンテナーはふだん 1 日以内に返信
-
Terminal views all show same name 'Terminal' in Ctrl+F7 view switcher popup対応中かも @ravnskjaer が 7 日前に担当しました。 オープンbug good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
eclipse-platform/eclipse.platform#2774 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
eclipse-platform/eclipse.platform#2593 · コメント 7 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
eclipse-platform/eclipse.platform#3027 ·
メンテナーはふだん 1 日以内に返信
eclipse-platform/eclipse.platform の issue をすべて見る
似ている issue
-
jules
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
open-learning-exchange/myplanet#18199 · コメント 1 件 ·
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
Scheme-less stream URLs throw NullPointerException instead of URISyntaxException対応中かも @blihio が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
pedroSG94/RootEncoder#2218 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
apache/rocketmq-dashboard#6872 ·
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ADORSYS-GIS/token-status-link#168 ·
メンテナーはふだん 2 日以内に返信