Skip to content

Idea: Can we cache the result of typeToTypeNode? #44043

Description

@amcasey

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Domain: PerformanceReports of unusually slow behaviorRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions