microsoft / microsoft/TypeScript

Idea: Can we cache the result of `typeToTypeNode`?

Offen
#44,043 3 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@weswigham arbeitet bereits daran.

Seit 03.11.2021.

Domain: Performance Rescheduled
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

A large percentage of declaration emit time (and a small percentage of check time) is spent in typeToTypeNode and tracing indicates that it is called on some types many times (hundreds or thousands in a sufficiently large project). I suspect, but have been able to demonstrate, that those requiring a import() qualification are particularly expensive. Could we cache the result? Two clear obstacles:

  1. Nodes are mutated during emit, so we'd need to clone anything retrieved from the cache. I'm reasonably confident that cloning will be cheaper than recomputing.
  2. typeToTypeNode takes a complex context argument. Possible workarounds include including the context hash in the cache key and storing the cached value on the context.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.