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

Compilation quickly slows down with increasing codebase size #4287

Closed
IgorMinar opened this issue Aug 12, 2015 · 4 comments
Closed

Compilation quickly slows down with increasing codebase size #4287

IgorMinar opened this issue Aug 12, 2015 · 4 comments
Assignees
Labels
Bug A bug in TypeScript External Relates to another program, environment, or user action which we cannot control.

Comments

@IgorMinar
Copy link

This is a followup issue to #4282.

As our Angular2 codebase grows we noticed that the compilation time seems to be increasing non-linearly/exponentially with the code size growth.

In Angular repo we have several modules that we are compiling together and I noticed that simply removing some modules can significantly improve the performance. What's interesting is that it doesn't matter which modules I drop. Any of them can result in improvements more significant the size the removed modules contribute to the overall compilation unit.

To repro with tsc on the angular code base:

You might delete any modules except for the main angular2 module which other modules depend on. All these modules are leaves except for angular2_material which is being depended on by examples module.

Example numbers in ES6 mode (patched tsc v1.5.3 - see #4282 for more info about the patches) :

  • baseline (all modules) : ~21s (total LoC*=71308)
  • previous - benchpress: ~19s (total LoC=66902)
  • previous - examples:~16s (total LoC=63989)
  • previous - rtts_assert: ~16s (total LoC=63251)
  • previous - benchmarks: ~14s (total LoC=60294)
  • previous - benchmarks_external: ~14s (total LoC=59675)
  • previous - angular2_material: ~11s (total LoC=58221)
  • previous - angular2/test: ~5s (total LoC=31942)

Now interestingly if I remove angular2/test first, slimming the code base significantly I get different numbers:

  • baseline (all modules) : ~21s (total LoC=71308)
  • previous - angular2/test: ~7s (total LoC=45029)
  • previous - benchpress: ~6.5s (total LoC=40623)
  • previous - examples:~6s (total LoC=37710)
  • previous - rtts_assert: ~6s (total LoC=36972)
  • previous - benchmarks: ~5.8s (total LoC=34015)
  • previous - benchmarks_external: ~5.5s (total LoC=33396)
  • previous - angular2_material: ~5s (total LoC=31942)

This shows that removing the angular2/test folder which contributes significantly to the overall codebase size can speed up the compilation by either 14s or 6s depending on what other modules are we compiling (even though the angular2/test has no dependencies on these other modules (with the exception of the core angular2 module that all of the modules depend on.

My assumption is that since the angular2/test is a leaf, removing it first or last should yield in the same absolute perf improvement, but that's not the case. I'm using this to simulate code-base growth since what we see is that the compilation time is increasing faster than our code base.


  • I'm using LoC to as a lame approximation of the compilation unit size - if you have a better way to measure this please advise :).
@IgorMinar IgorMinar changed the title Compilation slows down with increasing codebase size Compilation quickly slows down with increasing codebase size Aug 12, 2015
@danquirk danquirk added the Bug A bug in TypeScript label Aug 12, 2015
@weswigham
Copy link
Member

Almost all the extra time is spent in the checker:
With angular2/tests:

Files:             573
Lines:          100440
Nodes:          455418
Identifiers:    147979
Symbols:         72168
Types:           66300
Memory used:   149830K
I/O read:        0.35s
I/O write:       2.83s
Parse time:      1.15s
Bind time:       0.57s
Check time:     17.87s
Emit time:       5.09s
Total time:     24.69s

When you remove tests:

Files:             447
Lines:           74035
Nodes:          311600
Identifiers:    103304
Symbols:         57243
Types:           37664
Memory used:   127146K
I/O read:        0.24s
I/O write:       1.92s
Parse time:      0.86s
Bind time:       0.53s
Check time:      6.29s
Emit time:       2.94s
Total time:     10.61s

Perhaps tellingly there are almost half as many types when compiling without tests. Despite only cutting ~25% LOC, you cut ~50% of the types!

@mhegazy mhegazy added this to the TypeScript 1.6 milestone Aug 12, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Aug 12, 2015

@sheetalkamat can you take a look..

@sheetalkamat
Copy link
Member

@IgorMinar : I ran this with node and the result was this:
Files: 573
Lines: 100438
Nodes: 455129
Identifiers: 147854
Symbols: 72082
Types: 67959
Memory used: 237189K
I/O read: 0.41s
I/O write: 0.00s
Parse time: 1.14s
Bind time: 0.66s
Check time: 23.41s
Emit time: 0.00s
Total time: 25.20s

Vs without test folder
Files: 447
Lines: 74033
Nodes: 311321
Identifiers: 103181
Symbols: 57157
Types: 36995
Memory used: 171307K
I/O read: 0.38s
I/O write: 0.00s
Parse time: 0.91s
Bind time: 0.53s
Check time: 5.61s
Emit time: 0.00s
Total time: 7.05s

But as @mhegazy suggested me, I ran this with iojs and the result was this indicating this to be node issue.
Files: 573
Lines: 100438
Nodes: 455129
Identifiers: 147854
Symbols: 72082
Types: 67959
Memory used: 280986K
I/O read: 0.36s
I/O write: 0.00s
Parse time: 1.09s
Bind time: 0.58s
Check time: 3.34s
Emit time: 0.00s
Total time: 5.01s

Vs

Files: 447
Lines: 74033
Nodes: 311321
Identifiers: 103181
Symbols: 57157
Types: 36995
Memory used: 173990K
I/O read: 0.25s
I/O write: 0.00s
Parse time: 0.88s
Bind time: 0.44s
Check time: 2.42s
Emit time: 0.00s
Total time: 3.73s

@sheetalkamat sheetalkamat added the External Relates to another program, environment, or user action which we cannot control. label Aug 14, 2015
@IgorMinar
Copy link
Author

Thanks! I'll try to play with different node versions

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript External Relates to another program, environment, or user action which we cannot control.
Projects
None yet
Development

No branches or pull requests

6 participants