Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#2,568 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

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

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.
Lingua principale
Java
Stelle
165
Fork
174
Merge medio
2g 17h
PR unite (30g)
43

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di eclipse-platform/eclipse.platform

Tutte le issue di eclipse-platform/eclipse.platform

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.