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 compilation times when target=ES6 #4282

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

Slow compilation times when target=ES6 #4282

IgorMinar opened this issue Aug 12, 2015 · 8 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

On Angular2 we noticed that our ES6 builds are taking much longer than ES5 builds for almost identical code base.

  • target=es5: ~11s
  • target=es6: ~21s

To repro with tsc on the angular code base:

Please note that we are using custom build of typescript for Angular because of some minor patches that need to be applied on top of stock typescript (currently 1.5.3). These patches can be found here: alexeagle/TypeScript#1.5_error_is_class

To switch between ES5 and ES6 mode follow instructions in https://github.com/IgorMinar/angular/blob/tsc-perf-repro/modules/tsconfig.json.md

It is not clear to me why the two targets perform so differently. It would be great to get an explanation or even better improve performance of the ES6 target mode.

@IgorMinar
Copy link
Author

To add, we also noticed similar perf difference between the two modes when doing incremental compilation which can be tested with the -w flag passed into tsc.

@vladima
Copy link
Contributor

vladima commented Aug 12, 2015

Interesting, I would not expect significant differences when targeting different ES versions. Also I cannot reproduce this issue locally on Ubuntu box (there is some minor difference but it does not seem to be consistent)

v2m@v2m-ThinkPad-W520:~/sources/angular$ cp modules/tsconfig.json-es5 modules/tsconfig.json
v2m@v2m-ThinkPad-W520:~/sources/angular$ tsd reinstall --overwrite --config modules/angular2/tsd.json

-> running reinstall

>> written 9 files:

    - angular-protractor/angular-protractor.d.ts
    - es6-promise/es6-promise.d.ts
    - hammerjs/hammerjs.d.ts
    - jasmine/jasmine.d.ts
    - node/node.d.ts
    - rx/rx-lite.d.ts
    - rx/rx.d.ts
    - selenium-webdriver/selenium-webdriver.d.ts
    - zone/zone.d.ts
v2m@v2m-ThinkPad-W520:~/sources/angular$ git checkout modules/angular2/traceur-runtime.d.ts
v2m@v2m-ThinkPad-W520:~/sources/angular$ cat modules/tsconfig.json
{
    "compilerOptions": {
        "declaration": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "mapRoot": "",
        "module": "commonjs",
        "noEmitOnError": true,
        "outDir": "../dist/js/cjs",
        "rootDir": ".",
        "sourceMap": true,
        "sourceRoot": ".",
        "target": "es5"
    }
}
v2m@v2m-ThinkPad-W520:~/sources/angular$ ./node_modules/.bin/tsc -p modules --diagnostics
Files:             592
Lines:          100233
Nodes:          460296
Identifiers:    150153
Symbols:         73743
Types:           44161
Memory used:   225155K
I/O read:        0.13s
I/O write:       0.15s
Parse time:      1.30s
Bind time:       0.59s
Check time:      2.73s
Emit time:       1.77s
Total time:      6.39s
v2m@v2m-ThinkPad-W520:~/sources/angular$ cp modules/tsconfig.json-es6 modules/tsconfig.json
v2m@v2m-ThinkPad-W520:~/sources/angular$ rm modules/angular2/traceur-runtime.d.ts modules/angular2/typings/es6-promise/es6-promise.d.ts modules/angular2/typings/tsd.d.ts
v2m@v2m-ThinkPad-W520:~/sources/angular$ cat modules/tsconfig.json
{
    "compilerOptions": {
        "declaration": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "mapRoot": "",
        "noEmitOnError": true,
        "outDir": "../dist/js/dev/es6",
        "rootDir": ".",
        "sourceMap": true,
        "sourceRoot": ".",
        "target": "es6"
    }
}
v2m@v2m-ThinkPad-W520:~/sources/angular$ ./node_modules/.bin/tsc -p modules --diagnostics
Files:             589
Lines:          101437
Nodes:          462802
Identifiers:    151079
Symbols:         74396
Types:           67243
Memory used:   251728K
I/O read:        0.17s
I/O write:       0.15s
Parse time:      1.29s
Bind time:       0.61s
Check time:      3.34s
Emit time:       1.49s
Total time:      6.74s

I'll check the behavior on Windows box tomorrow, meanwhile can you please try to re-run the compiler for both ES5 and ES6 with --diagnostics key to see where we spent most of the time?

@vladima
Copy link
Contributor

vladima commented Aug 12, 2015

Ok, I guess I can see the problem. What version of Node do you use?

@vladima
Copy link
Contributor

vladima commented Aug 12, 2015

To elaborate, we've noticed before that the same version of typescript compiler shows better performance on older versions of node and performance goes down on more recent versions. I.e timings from my previous post are made using node v0.10.35 (v8 version 3.14.5.9). If I switch to node v.12.7 (v8 version 3.28.71.19) then timings become almost the same as yours (~11s and ~22s).

@vladima
Copy link
Contributor

vladima commented Aug 12, 2015

I've tried to install iojs-v3.0.0 (v8 version 4.4.63.26) from nvm and it seems to improve the situation. Compilation times for both ES6 and ES5 dropped to ~8s

@IgorMinar
Copy link
Author

Interesting! I'm on node v0.12.2. We can't use v0.10 because of some npm issues. We've also had problems with iojs in the past but I haven't tried v3.0.0 yet.

@vladima
Copy link
Contributor

vladima commented Aug 12, 2015

FYI: this is V8 issue that was filed back in Jan 2015 a to track these perf regressions: https://code.google.com/p/v8/issues/detail?id=3817

@weswigham
Copy link
Member

https://code.google.com/p/v8/issues/detail?id=3842 was created at roughly the same time, (found here) and reported perf regressions in escodegen. I can't imagine we're that different from their use case in terms of perf profile.

@mhegazy mhegazy added Bug A bug in TypeScript External Relates to another program, environment, or user action which we cannot control. labels Aug 17, 2015
@mhegazy mhegazy added this to the TypeScript 1.6 milestone Aug 17, 2015
@mhegazy mhegazy closed this as completed Aug 19, 2015
@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

5 participants