microsoft / microsoft/TypeScript
Rewrite `getAccessibleSymbolChain` for performance
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
getAccessibleSymbolChain is one of the oldest parts of the compiler - remaining today mostly unchanged (barring support for new features) from when it was used in the old text-based declaration emitter. getAccessibleSymbolChain is used to, given a [symbol, scope] pair, find a series of symbols whose exports can be accessed to lookup the symbol. Today, this is by and large uncached, so the fail case, when a symbol is not accessible, causes a traversal of every publicly reachable symbol in a program - this process is then repeated for every symbol that needs to be named, which means you end up spending a very long time traversing symbol structures. On normal typescript code, the inefficiency is less outsized, as we only need to invoke this code when we generate inferred types in declaration emit, which is more rare in TS output than in JS output, however you can still find projects where its' influence is large (some of @AnyhowStep 's samples bad performance in declaration emit trace back to this).
As far as the direction of the fix goes - I have some ideas. Today, we enumerate all possibilities and just backtrack to see what works - instead, I imagine using a (cacheable) set-like structure to check if the symbol is even accessible from a given symbol, and then use a hierarchy of these sets to guide chain creation.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie damit, getAccessibleSymbolChain im Compiler zu finden und seine Aufrufer während des declaration emit nachzuverfolgen. Überprüfen Sie die bestehende Symboltraversierung und die im Issue erwähnten Performance-Traces und bestimmen Sie anschließend, wie sich validieren lässt, dass wiederholte Traversierung reduziert wird, ohne die Ergebnisse der accessible symbol chain zu verändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers, performance
- Issue-Typ
- Refactoring
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 30/100