Skip to content

Performance improvements #95

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

Merged
merged 3 commits into from
Mar 30, 2021
Merged

Performance improvements #95

merged 3 commits into from
Mar 30, 2021

Conversation

dfreeman
Copy link
Member

@dfreeman dfreeman commented Mar 30, 2021

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:

  1. Keep Babel from doing unnecessary work: @babel/core's parseSync 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).

  2. 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.

  3. 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, changing rootFileNames 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:

Before After
before after

@dfreeman dfreeman added the enhancement New feature or request label Mar 30, 2021
documents
.all()
.map((doc) => uriToFilePath(doc.uri))
.filter((path) => path.endsWith('.ts') && !baseProjectRoots.has(path))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@dfreeman dfreeman linked an issue Mar 30, 2021 that may be closed by this pull request
@dfreeman dfreeman merged commit 7d331a1 into master Mar 30, 2021
@dfreeman dfreeman deleted the performance-improvements branch March 30, 2021 19:40
@dfreeman dfreeman mentioned this pull request Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Seems to Hang in VSCode
2 participants