microsoft / microsoft/TypeScript

Rewrite `getAccessibleSymbolChain` for performance

Aperta
#33,624 2 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Domain: Declaration Emit Domain: Performance Experience Enhancement
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

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.

Direzione di ricerca

Inizia individuando getAccessibleSymbolChain nel compilatore e seguendo i suoi chiamanti durante il declaration emit. Esamina l'attraversamento dei simboli esistente e le tracce delle prestazioni menzionate nell'issue, quindi determina come verificare che l'attraversamento ripetuto venga ridotto senza modificare i risultati della accessible symbol chain.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
compilers, performance
Tipo di issue
Refactoring
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.