microsoft / microsoft/TypeScript
Rewrite `getAccessibleSymbolChain` for performance
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza localizando getAccessibleSymbolChain en el compilador y siguiendo sus llamadas durante el declaration emit. Revisa el recorrido de símbolos existente y las trazas de rendimiento mencionadas en el issue; después, determina cómo validar que se reduce el recorrido repetido sin cambiar los resultados de la accessible symbol chain.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- compilers, performance
- Tipo de issue
- Refactorización
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 30/100