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

Building performance is slowdown #28025

Closed
thekiba opened this issue Oct 21, 2018 · 8 comments · Fixed by #28028
Closed

Building performance is slowdown #28025

thekiba opened this issue Oct 21, 2018 · 8 comments · Fixed by #28028
Labels
Bug A bug in TypeScript Domain: Performance Reports of unusually slow behavior Fixed A PR has been merged for this issue

Comments

@thekiba
Copy link

thekiba commented Oct 21, 2018

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.

screenshot 2018-10-21 at 16 19 02

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’t 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:
#26192

@ajafff
Copy link
Contributor

ajafff commented Oct 21, 2018

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.

@thekiba
Copy link
Author

thekiba commented Oct 21, 2018

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.

@ajafff
Copy link
Contributor

ajafff commented Oct 21, 2018

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.

@thekiba
Copy link
Author

thekiba commented Oct 21, 2018

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.

@zorrme
Copy link

zorrme commented Oct 26, 2018

Can we release this please ?

ajafff added a commit to ajafff/TypeScript that referenced this issue Nov 1, 2018
@DanielRosenwasser DanielRosenwasser added the Fixed A PR has been merged for this issue label Nov 1, 2018
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 3.1.6 milestone Nov 1, 2018
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Nov 1, 2018

This should be available in TypeScript 3.1.6. Thanks @ajafff!

@Manish3177
Copy link

Could we get updated VS installer for 3.1.6: https://www.microsoft.com/en-us/download/details.aspx?id=55258?

@Manish3177
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Performance Reports of unusually slow behavior Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants