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

Optimize import fixes for projects with many symlinks #42150

Merged
merged 8 commits into from
Jan 20, 2021

Conversation

andrewbranch
Copy link
Member

@andrewbranch andrewbranch commented Dec 29, 2020

This is a separate follow-up to #42095, incorporating and building on @walkerburgin’s investigations. The main difference between this PR and @walkerburgin’s experiment (besides the inclusion of #42095) is that this tries directories from the imported filename to key into the realpath->symlink map instead of iterating through all entries of the map.

Fixes #40584

Forgot to share perf numbers. Scenario: private repo shared here. Opened file shown in screenshot. Restart TS Server with that file open. Move cursor to OnInit to trigger getCodeFixes. From fixes menu, choose “Add all missing imports” to trigger getCombinedCodeFix.

updateOpen (ms) getCodeFixes (ms) getCombinedCodeFix (ms)
master pre-#42095 merge 5958 2235 70447
#42095 4796 890 24150
This PR 5865 258 5483

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Dec 29, 2020
@andrewbranch
Copy link
Member Author

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Dec 29, 2020

Heya @andrewbranch, I've started to run the tarball bundle task on this PR at f51e232. You can monitor the build here.

@andrewbranch
Copy link
Member Author

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Dec 29, 2020

Heya @andrewbranch, I've started to run the tarball bundle task on this PR at 4afb9cc. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Dec 29, 2020

Hey @andrewbranch, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/92194/artifacts?artifactName=tgz&fileId=66AE1B5B57F9EA3EAA6042EE64F8041A6F163B351E7651B0BD245476905B443002&fileName=/typescript-4.2.0-insiders.20201229.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@4.2.0-pr-42150-4".;

@andrewbranch andrewbranch marked this pull request as ready for review January 12, 2021 23:01
src/compiler/moduleSpecifiers.ts Show resolved Hide resolved
src/compiler/moduleSpecifiers.ts Outdated Show resolved Hide resolved
@sandersn
Copy link
Member

I don't know the code well enough to have detailed comments, but since this is a perf fix, any idea what the difference in memory usage is? Is the scale of the cache going to remain small enough not to matter?

@andrewbranch
Copy link
Member Author

@sandersn I didn’t measure it, partly because since it’s just path strings, it’s obviously dependent upon the length of the paths but you can do the estimation in your head, and it would take quite a lot of path strings to add up to anything appreciable. And since non-pnpm users tend not to have more than a handful of symlinks in the first place, the typical memory impact will be near-zero. Only users who are currently getting absolutely miserable time performance should see anything approaching a few kB.

@andrewbranch andrewbranch merged commit 0383b5c into microsoft:master Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Typescript: TSServer: Code Fixes: Import missing imports with a symlinked node_modules folder is very slow
4 participants