TypeScript Version: 3.2.0-dev.201xxxxx
Search Terms:
performance, slowdown, degradation
Code:
After upgrading to typescript 3.1.3, our application has been building for a very long time. The total time has increased tenfold. By profiling the build, I found the reason for the slowdown in performance.
The screenshot shows a call to this method:
https://github.com/Microsoft/TypeScript/pull/26192/files#diff-08a3cc4f1f9a51dbb468c2810f5229d3R968
oldProgramState.program.getSourceFiles().find(...)
When I rolled back the commit changes, the performance problem was solved. But I don鈥檛 know how to fix that and so that the PR assertion pass:
https://github.com/Microsoft/TypeScript/pull/26192/files#diff-6f2ace9c4058a2bb2afe0560f9990e33R402
Expected behavior:
Performance improvement
Actual behavior:
Performance is slowdown
Related Issues:
https://github.com/Microsoft/TypeScript/pull/26192
Looking at that code again, I don't know how it could cause a noticeable slowdown. That would probably require thousands or millions of files in your program.
How are you running tsc to hit that path of the code? tsc -w
or some custom build tool?
How many files are in your program? You can find out using --diagnostics
flag of tsc
.
The count of files in the project ~10k.
I am using @angular/cli. And I tried to set the compilerOptions.diagnostics
flag in tsconfig.json
, but I don't receive any information.
After investigating further, it turns out this code may be executed for each import (or type reference directive) in every file of the project (depending on the kind of change).
I have a fix up in #28028 to avoid iterating every file.
I build typescript from your pull request, and used it to build my application. Now the build time is the same as before.
馃憤Thanks for the quick response.
Can we release this please ?
This should be available in TypeScript 3.1.6. Thanks @ajafff!
Could we get updated VS installer for 3.1.6: https://www.microsoft.com/en-us/download/details.aspx?id=55258?
Pinging again. It's not obvious how to apply the contents of 3.1.6 source on top of the installer linked above. Is it just a matter of copying over and overriding tsc.js+tsc.exe? Is there anything else that needs to be copied over? At the very least, I'd like to hear from one of the devs that it won't break anything. A diff of tsc.js between the two version really lights up because the source contains comments.
Most helpful comment
This should be available in TypeScript 3.1.6. Thanks @ajafff!