Performance improvements #95
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I spent a bit of time profiling with Glint open in a non-toy-sized project and found a few pieces of low-hanging fruit for speeding things up:
Keep Babel from doing unnecessary work:
@babel/core
'sparseSync
was doing a file system crawl looking for configuration files for every single parse. Even assuming the OS was smart about caching those results, we were spending a lot of time in there. That behavior is now disabled (and is something we can consider doing once ourselves in the future if we have the need to support more exotic.js
syntaxes).Cache negative transform results: we now cache the result of transforming a file even if that result is "we didn't need to transform it", since just doing the analysis to see if we might need to check is more expensive than the quick document version comparison we can do if the result is cached.
Don't thwart TypeScript's own bookkeeping: in order to account for newly-created files that may be open in the editor but not exist on disk yet, the
rootFileNames
we supply can change over time. Since adding a new file can change module resolution results, changingrootFileNames
causes TypeScript to discard all its internal program state. This is the correct behavior, but we were previously triggering it any time a file was opened.In a codebase with ~15k
.ts
and ~6k.hbs
lines of code, this makes a night-and-day difference to editor feedback: