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

Slow performance in incremental mode with no changes #46420

Closed
JelleZijlstra opened this issue Oct 19, 2021 · 3 comments
Closed

Slow performance in incremental mode with no changes #46420

JelleZijlstra opened this issue Oct 19, 2021 · 3 comments
Labels
Domain: Performance Reports of unusually slow behavior Needs Investigation This issue needs a team member to investigate its status. Needs More Info The issue still hasn't been fully clarified

Comments

@JelleZijlstra
Copy link

Bug Report

πŸ”Ž Search Terms

Performance

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about performance

⏯ Playground Link

n/a

πŸ’» Code

n/a

πŸ™ Actual behavior

I have a huge, closed-source TypeScript project (7600+ files, 2M+ lines of TypeScript).

Typechecking is slow, about 30 s even with incremental mode on. We'd like to get this faster and discovered that even with incremental mode on and with no changes in the code, TS visits and parses every single file in the project.

Here is a screenshot from the awesome perf tracing tool (from an incremental run with no changes since the previous run):
Screen Shot 2021-10-18 at 5 26 15 PM

This was from typescript@next (which seems a little faster than the current release, thanks for that!). Of 28 s total, 22 s was spent in findSourceFile.

πŸ™‚ Expected behavior

Incremental mode should cache enough information that it's not necessary to re-parse each file on the next run.

@DanielRosenwasser DanielRosenwasser added Domain: Performance Reports of unusually slow behavior Needs Investigation This issue needs a team member to investigate its status. labels Nov 4, 2021
@DanielRosenwasser
Copy link
Member

Do you have this issue with findSourceFile on non-incremental compiles?

@DanielRosenwasser DanielRosenwasser added the Needs More Info The issue still hasn't been fully clarified label Nov 4, 2021
@JelleZijlstra
Copy link
Author

Screen Shot 2021-11-17 at 2 55 25 PM

When I turn off incremental: true and tsBuildInfoFile in my tsconfig, I get the above trace. findSourceFile is still equally slow, but in addition it spends a lot of time actually type checking the code.

@samuliasmala
Copy link

I'm experiencing the same. I was expecting the incremental flag to reduce the compilation time to watch mode incremental compilation time, but the reality is different. I have smaller codebase so npx tsc with incremental: false takes 8 seconds. First incremental: true run takes the same 8 seconds but after that it's reduced to 4 seconds.

However, if I run npx tsc --watch it takes the same amount of time to start as without the --watch flag (8 s or 4 s) but after that the compilation takes less than a second.

[10:37:59 PM] Starting compilation in watch mode...

[10:38:03 PM] Found 0 errors. Watching for file changes.

[10:38:31 PM] File change detected. Starting incremental compilation...

[10:38:31 PM] Found 0 errors. Watching for file changes.

Steps to reproduce

Some output removed for clarity.

$ node -v
v16.10.0

$ npm -v
7.24.0

$ git clone [email protected]:microsoft/TypeScript-Node-Starter.git
$ cd TypeScript-Node-Starter/
$ npm install

$ time npx tsc
real    0m6.447s

$ time npx tsc
real    0m6.365s

$ time npx tsc --incremental
real    0m6.444s

$ time npx tsc --incremental
real    0m2.441s

$ time npx tsc --incremental --watch

Again the first compilation of the watch command takes that 2 s but after that it is less than a second.

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 Needs Investigation This issue needs a team member to investigate its status. Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

4 participants