`Path` object creation and operations dominate CPU time on large resource trees
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 30/100
- Tipo di issue
- Refactoring
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- java
- Ambito
- performance
Direzione di ricerca
Inizia individuando il costruttore Path(String), backslashToForward(), computeSegmentCount(), computeSegments(), equals() e Constants.RUNNING_ON_WINDOWS; nell’issue non sono indicati file sorgente né test. Esamina i dati heapdump collegati e le API IPath.of() esistenti prima di scegliere tra conversione specifica della piattaforma, caching o calcolo lazy. Il lavoro è concluso quando si ottiene una riduzione misurata del tempo CPU relativo a Path senza modificare il comportamento dei percorsi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Java
- Stelle
- 165
- Fork
- 174
- Merge medio
- 2g 17h
- PR unite (30g)
- 43
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di eclipse-platform/eclipse.platform
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
eclipse-platform/eclipse.platform#3019 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
eclipse-platform/eclipse.platform#2940 ·
I maintainer di solito rispondono entro 1 giorno
-
Terminal views all show same name 'Terminal' in Ctrl+F7 view switcher popupForse già presa @ravnskjaer l’ha presa 5 giorni fa. Apertabug good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
eclipse-platform/eclipse.platform#2774 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
eclipse-platform/eclipse.platform#2593 · 7 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug regression
Difficoltà 3/5 1-2 giorni Idoneità per principianti 56/100
eclipse-platform/eclipse.platform#3022 · 8 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di eclipse-platform/eclipse.platform
Issue simili
-
Flight SQL JDBC parses boolean properties case-sensitively, silently disabling TLS for useEncryption=TRUEForse già presa @Arawoof06 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
apache/arrow-java#1357 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
apache/rocketmq-dashboard#6610 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MetricsHub/metricshub-community#1396 ·
I maintainer di solito rispondono entro 1 giorno
-
L: java:gradle L: java:maven L: ruby:bundler T: bug 🐞
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
dependabot/dependabot-core#16547 ·
I maintainer di solito rispondono entro 1 giorno
-
Citationcount column sorts alphabetically instead of numericallyForse già presa @kpunia306 l’ha presa oggi. Apertastatus: needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
JabRef/jabref#17459 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno