Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
amcasey opened this issue May 11, 2021 · 3 comments
Open

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

amcasey opened this issue May 11, 2021 · 3 comments
Assignees
Labels
Domain: Performance Reports of unusually slow behavior Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@amcasey
Copy link
Member

amcasey commented May 11, 2021

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.
@amcasey amcasey added the Domain: Performance Reports of unusually slow behavior label May 11, 2021
@amcasey
Copy link
Member Author

amcasey commented May 19, 2021

Fixed by #43973?

@DanielRosenwasser
Copy link
Member

Would we consider this fixed @weswigham?

@weswigham
Copy link
Member

Maybe? The caching isn't probably as general as the OP was thinking about, but it's probably what we can get without some fairly complex (and potentially expensive) cache key manufacturing and tracking.

@RyanCavanaugh RyanCavanaugh added the Rescheduled This issue was previously scheduled to an earlier milestone label Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Performance Reports of unusually slow behavior Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

No branches or pull requests

4 participants