-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
2x compilation slowdown when upgrading from TS1.8 => TS2.0 #10018
Comments
We have a ~400 file TS project (without counting imported libs), and it will take some time to create a repro case. My question is a high level question before I try to make that repro case: given that TS2's compiler does more than TS1.8's compiler, from your guys' tests, what kind of slowdown in cold and incremental compilation should I expect to see as a user? Is it 0? 10%? 50%? With 1.8, our incremental build time (using gulp + browserify + tsify) was ~5-10s. Now, it is 10-20s. |
2x slowdown is not something we'd expect; 10-15% is more representative from the codebases we've seen. It's possible you're using some particular patterns that we don't have similar benchmarks for. |
Ok, will try to put together a repro case. |
I wasn't able to distill our codebase down to a repro case; maybe we can leave this issue open, in case someone runs into the same thing. At a high level, our structure is not typical - for historical reasons, instead of a well formed dependency graph, our code is a shallow graph - we have 400+ entrypoints, which we build into a single bundle with browserify + tsify. The dependency graph looks something like this: Have you tried benchmarking a project structure like this? |
We would love to get access to the project to investigate more. we would be happy to sign any NDA's required. We do have a set of bench marks for large projects, any where between 200 KLOC to 1 MLOC. we have not see such increase. |
@mhegazy Unfortunately I don't think it will be possible to share our code. We had a few contributing factors that slowed down our build a lot already (both before and after upgrading to TS2): we were building 3 separate JS bundles from TS, with 3 gulp watchers running in parallel, often triple-watching the same file, and hogging the same thread. Additionally:
The fix in our case was to dynamically generate an index.js that requires every file. So before, we had 400 entry points, some of which imported each other; now, we have a single entry point that requires each of those 400 original entry points (the visualization in my comment above is accurate). Our incremental build time dropped from ~4-5s to ~500ms. Hope that's helpful. |
@mhegazy I see massive slow down in incremental compilation (tsc --watch). Change in one file takes 9-10 (or even more) seconds to compile, in 1.8 was much much faster. Our project is Angular2/Ionic2 app. We made a switch to newest release of Ionic, which uses latest Angular2. I just made a simple test. Created new file (test.ts), with class declaration class A {prop: number} and added to my project. I run tsc --watch --traceResolution and after initial compilation I made a change in test.ts - thanks to trace resolution I've noticed, that compiler is checking all the files in my project and trying to resolve modules, that are used in those files. Obviously that takes time - I don't know whether that should work like this and if that didn't change from 1.8 (maybe is related to @types instead of typings). |
There has been no changes to |
Diagnostics typescript 2.0.3:
Diagnostics 1.8.10:
Just looking at the numbers - 2.0 compilation is at least 7 seconds slower than 1.8 and all because "check" process. Isn't that because of the switch from typings to npm ? |
@lleevvyy is it possible to get your repro code so we can find the crux of the problem? We can sign NDA if necessary |
@vladima Sure, how to send the code? |
you can send it to vladima |
@vladima I've analyzed my code and I found, that typescript 2.0 is processing/checking much longer files, that are huge - in my app I have a few autogenerated files, and those are between 40-250KB. Each file contains few methods and inside each method there is big switch statement with hundreds of cases and each case returns new instance of some objects. Small sample below:
When I clear the biggest file (240KB) check time drops from 9sec to 3sec. Note, that typescript 1.8 check time is 2sec, no difference whether that big file is empty or filled. |
@lleevvyy can you try to build compiler from this branch to check if it addresses your problem? |
@vladima Yes, I confirm - much better now:
@vladima Thanks for your time and work! |
Is this expected? Are there ways to mitigate this?
If this is not expected, I will try to post a synthetic test case.
The text was updated successfully, but these errors were encountered: