angular: serve rebuild speed problem between 9rc.1 and 9rc.2 and 9rc.3

🐞 Bug report

Command (mark with an x)

  • serve

Is this a regression?

Yes, in 9rc1, our app (on serve ivy+aot) each rebuild is <2seconds In 9rc2 app rebuild ~6seconds Now with rc3, if I trigger rebuild by adding one character in file+save (5 times) rebuild always take >15seconds

1.I was on 9rc2 then use ng update to go to 9rc3 for all packages (cli and core …) 2. After that I run --migrate-only --from=8 --to=9 3. ng s ( ivy and aot is enabled)

🔥 Exception or Error

rebuilt speed problem

See Environment after update/migration
Angular CLI: 9.0.0-rc.3
Node: 13.1.0
OS: win32 x64
Angular: 9.0.0-rc.3
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.0-rc.3
@angular-devkit/build-angular     0.900.0-rc.3
@angular-devkit/build-optimizer   0.900.0-rc.3
@angular-devkit/build-webpack     0.900.0-rc.3
@angular-devkit/core              9.0.0-rc.3
@angular-devkit/schematics        9.0.0-rc.3
@angular/cdk                      9.0.0-rc.2
@angular/material                 9.0.0-rc.2
@ngtools/webpack                  9.0.0-rc.3
@schematics/angular               9.0.0-rc.3
@schematics/update                0.900.0-rc.3
rxjs                              6.5.3
typescript                        3.7.2
webpack                           4.41.2

Anything else relevant? cc @filipesilva

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 21 (20 by maintainers)

Most upvoted comments

I think you speak about these changes #33862 if yes I’m aware of that but I believed this would not cause a lot of perf issue (like here), after reading @alxhub 's commit messages:

Correct. The reproduction repo you provided contains some 400 components, which is large enough for the analysis phase to become really noticeable.

Will this issue continue to have v9-blockers flag ? (due to this ivy+aot is not activable on our project, 15-20s rebuild agains 2s before theses changes using ng s)

Yes, it is still considered blocking.

@elvisbegovic it actually doesn’t make any sense why ngc numbers would be worse the the ng/cli numbers. And btw you are correct, not tsconfig(.app).json chance are needed to build the project with ngc.

Any chance you could share a project with us that reproduces this behavior? Do you see it on just one particular project or on multiple projects?

We are struggling to understand under what circumstances the rebuild times are this bad, so if you can provide us with any information that would help us reproduce this issue, we’d really appreciate it. thanks!

I used https://github.com/elvisbegovic/ng-speed-rebuild and updated CLI, Material, and Framework to rc.4. Here’s the result of ng version:

Angular CLI: 9.0.0-rc.4
Node: 10.16.0
OS: win32 x64

Angular: 9.0.0-rc.4
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, localize, material
... platform-browser, platform-browser-dynamic, router        
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------   
@angular-devkit/architect         0.900.0-rc.4
@angular-devkit/build-angular     0.900.0-rc.4
@angular-devkit/build-optimizer   0.900.0-rc.4
@angular-devkit/build-webpack     0.900.0-rc.4
@angular-devkit/core              9.0.0-rc.4
@angular-devkit/schematics        9.0.0-rc.4
@ngtools/webpack                  9.0.0-rc.4
@schematics/angular               9.0.0-rc.4
@schematics/update                0.900.0-rc.4
rxjs                              6.5.3
typescript                        3.6.4
webpack                           4.41.2

I took rebuilds numbers by adding console.log(1) to projects/one/src/main.ts after the first build, but discarted the first few rebuilds because they usually take longer.

These were the scripts I used. CLI has increased maximum memory since it was very close to the 1.4gb limit.

    "serve": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng serve",
    "ngc": "ngc -p projects/one/tsconfig.app.json --watch --diagnostics",
  • yarn serve
Date: 2019-11-28T13:28:08.859Z - Hash: e555cdd1fc0e2b739545
416 unchanged chunks
chunk {main} main.94dbeec8d3d436066257.js, main.94dbeec8d3d436066257.js.map (main) 22.2 kB [initial] [rendered]
Time: 12264ms
: Compiled successfully.

Date: 2019-11-28T13:28:26.239Z - Hash: 2f438b91a43922280de4
416 unchanged chunks
chunk {main} main.320f9a9f0d7b9713058c.js, main.320f9a9f0d7b9713058c.js.map (main) 22.2 kB [initial] [rendered]
Time: 12676ms
: Compiled successfully.

Date: 2019-11-28T13:28:47.331Z - Hash: 0515d72f70e2ff94dec2
416 unchanged chunks
chunk {main} main.34fce1e7ee699c7fe0d5.js, main.34fce1e7ee699c7fe0d5.js.map (main) 22.2 kB [initial] [rendered]
Time: 12991ms
: Compiled successfully.

Date: 2019-11-28T13:29:11.449Z - Hash: e298ceaf378a1b726a57
416 unchanged chunks
chunk {main} main.f2d314fb9f947d2a30b1.js, main.f2d314fb9f947d2a30b1.js.map (main) 22.2 kB [initial] [rendered]
Time: 13214ms
: Compiled successfully.

Date: 2019-11-28T13:29:32.371Z - Hash: 69e3d04e95f70677125a
416 unchanged chunks
chunk {main} main.95ae29d0d5556be5f564.js, main.95ae29d0d5556be5f564.js.map (main) 22.2 kB [initial] [rendered]
Time: 14240ms
: Compiled successfully.
  • yarn ngc
File change detected. Starting incremental compilation.


Time for diagnostics: 15368ms.


Total time: 15s


Compilation complete. Watching for file changes.


File change detected. Starting incremental compilation.


Time for diagnostics: 15372ms.


Total time: 15s


Compilation complete. Watching for file changes.


File change detected. Starting incremental compilation.


Time for diagnostics: 14997ms.


Total time: 15s


Compilation complete. Watching for file changes.


File change detected. Starting incremental compilation.


Time for diagnostics: 15618ms.


Total time: 16s


Compilation complete. Watching for file changes.


File change detected. Starting incremental compilation.


Time for diagnostics: 15579ms.


Total time: 16s


Compilation complete. Watching for file changes.

We can turn on timing numbers for CLI by editing node_modules/@ngtools/webpack/src/benchmark.js to have const _benchmark = true;. When doing so, it’s better to turn off progress reporting via ng serve --progress false too so that the progress messages don’t get in the way of the benchmark logging.

I added --- rebuild triggered --- markers so it’s clearer what the boundary between rebuilds is.

--- rebuild triggered ---

TypeChecker._update: 0.343ms
TypeChecker._createOrUpdateProgram.ng.createProgram: 52.555ms
AngularCompilerPlugin._createOrUpdateProgram.ng.createProgram: 80.348ms
TypeChecker.gatherDiagnostics.ng.getTsSemanticDiagnostics: 3857.724ms
AngularCompilerPlugin._createOrUpdateProgram.ng.loadNgStructureAsync: 10061.059ms
AngularCompilerPlugin._listLazyRoutesFromProgram.listLazyRoutes: 104.514ms
AngularCompilerPlugin._emit.ng.getNgStructuralDiagnostics: 0.012ms
AngularCompilerPlugin._emit.ng.gatherDiagnostics.ng.getTsSyntacticDiagnostics: 1.229ms
AngularCompilerPlugin._emit.ng.emit: 20.384ms
AngularCompilerPlugin._emit: 24.852ms
AngularCompilerPlugin._update._emit: 25.200ms
AngularCompilerPlugin._update: 11952.635ms
AngularCompilerPlugin._make: 11952.920ms
ngcLoader+D:\sandbox\ng-speed-rebuild\projects\one\src\main.ts+.ngcLoader.AngularCompilerPlugin: 9294.860ms
ngcLoader+D:\sandbox\ng-speed-rebuild\projects\one\src\main.ts+: 9296.197ms

Date: 2019-11-28T13:41:04.897Z - Hash: 7dbc1378c72bc8e3ff86
416 unchanged chunks
chunk {main} main.dc1adbc6e623e9d8eadd.js, main.dc1adbc6e623e9d8eadd.js.map (main) 21.9 kB [initial] [rendered]
Time: 14615ms
: Compiled successfully.
TypeChecker.gatherDiagnostics.ng.getNgSemanticDiagnostics: 24351.017ms
TypeChecker.message: 28265.766ms

--- rebuild triggered ---

TypeChecker._update: 0.383ms
AngularCompilerPlugin._createOrUpdateProgram.ng.createProgram: 71.203ms
TypeChecker._createOrUpdateProgram.ng.createProgram: 73.470ms
TypeChecker.gatherDiagnostics.ng.getTsSemanticDiagnostics: 2422.554ms
AngularCompilerPlugin._createOrUpdateProgram.ng.loadNgStructureAsync: 6871.843ms
AngularCompilerPlugin._listLazyRoutesFromProgram.listLazyRoutes: 61.944ms
AngularCompilerPlugin._emit.ng.getNgStructuralDiagnostics: 0.006ms
AngularCompilerPlugin._emit.ng.gatherDiagnostics.ng.getTsSyntacticDiagnostics: 0.490ms
AngularCompilerPlugin._emit.ng.emit: 17.314ms
AngularCompilerPlugin._emit: 19.427ms
AngularCompilerPlugin._update._emit: 20.485ms
AngularCompilerPlugin._update: 8307.138ms
AngularCompilerPlugin._make: 8307.520ms
ngcLoader+D:\sandbox\ng-speed-rebuild\projects\one\src\main.ts+.ngcLoader.AngularCompilerPlugin: 6187.952ms
ngcLoader+D:\sandbox\ng-speed-rebuild\projects\one\src\main.ts+: 6188.982ms

Date: 2019-11-28T13:41:40.866Z - Hash: d70d2d34ada515321b33
416 unchanged chunks
chunk {main} main.2dac69d6ef5fc0cedcd4.js, main.2dac69d6ef5fc0cedcd4.js.map (main) 21.9 kB [initial] [rendered]
Time: 10686ms
: Compiled successfully.
TypeChecker.gatherDiagnostics.ng.getNgSemanticDiagnostics: 21908.382ms
TypeChecker.message: 24407.330ms

--- rebuild triggered ---

TypeChecker._update: 0.363ms
AngularCompilerPlugin._createOrUpdateProgram.ng.createProgram: 40.950ms
TypeChecker._createOrUpdateProgram.ng.createProgram: 47.259ms
TypeChecker.gatherDiagnostics.ng.getTsSemanticDiagnostics: 2457.850ms
AngularCompilerPlugin._createOrUpdateProgram.ng.loadNgStructureAsync: 8022.959ms
AngularCompilerPlugin._listLazyRoutesFromProgram.listLazyRoutes: 58.367ms
AngularCompilerPlugin._emit.ng.getNgStructuralDiagnostics: 0.006ms
AngularCompilerPlugin._emit.ng.gatherDiagnostics.ng.getTsSyntacticDiagnostics: 0.500ms
AngularCompilerPlugin._emit.ng.emit: 13.597ms
AngularCompilerPlugin._emit: 15.753ms
AngularCompilerPlugin._update._emit: 16.310ms
AngularCompilerPlugin._update: 9298.439ms
AngularCompilerPlugin._make: 9298.928ms
ngcLoader+D:\sandbox\ng-speed-rebuild\projects\one\src\main.ts+.ngcLoader.AngularCompilerPlugin: 6369.165ms
ngcLoader+D:\sandbox\ng-speed-rebuild\projects\one\src\main.ts+: 6370.161ms

Date: 2019-11-28T13:42:15.529Z - Hash: 7dbc1378c72bc8e3ff86
416 unchanged chunks
chunk {main} main.dc1adbc6e623e9d8eadd.js, main.dc1adbc6e623e9d8eadd.js.map (main) 21.9 kB [initial] [rendered]
Time: 12646ms
: Compiled successfully.
TypeChecker.gatherDiagnostics.ng.getNgSemanticDiagnostics: 22063.839ms
TypeChecker.message: 24571.433ms

--- rebuild triggered ---

TypeChecker._update: 0.764ms
TypeChecker._createOrUpdateProgram.ng.createProgram: 87.314ms
AngularCompilerPlugin._createOrUpdateProgram.ng.createProgram: 110.327ms
TypeChecker.gatherDiagnostics.ng.getTsSemanticDiagnostics: 2536.284ms
AngularCompilerPlugin._createOrUpdateProgram.ng.loadNgStructureAsync: 7549.050ms
AngularCompilerPlugin._listLazyRoutesFromProgram.listLazyRoutes: 54.213ms
AngularCompilerPlugin._emit.ng.getNgStructuralDiagnostics: 0.006ms
AngularCompilerPlugin._emit.ng.gatherDiagnostics.ng.getTsSyntacticDiagnostics: 0.522ms
AngularCompilerPlugin._emit.ng.emit: 19.721ms
AngularCompilerPlugin._emit: 21.927ms
AngularCompilerPlugin._update._emit: 22.492ms
AngularCompilerPlugin._update: 8957.187ms
AngularCompilerPlugin._make: 8957.415ms
ngcLoader+D:\sandbox\ng-speed-rebuild\projects\one\src\main.ts+.ngcLoader.AngularCompilerPlugin: 6847.521ms
ngcLoader+D:\sandbox\ng-speed-rebuild\projects\one\src\main.ts+: 6848.556ms

Date: 2019-11-28T13:43:21.502Z - Hash: 3830fcaab5bfaa7757f9
416 unchanged chunks
chunk {main} main.be5aa6b3cb6013238bcd.js, main.be5aa6b3cb6013238bcd.js.map (main) 21.9 kB [initial] [rendered]
Time: 11093ms
: Compiled successfully.
TypeChecker.gatherDiagnostics.ng.getNgSemanticDiagnostics: 21490.057ms
TypeChecker.message: 24117.227ms

--- rebuild triggered ---

TypeChecker._update: 0.302ms
AngularCompilerPlugin._createOrUpdateProgram.ng.createProgram: 33.755ms
TypeChecker._createOrUpdateProgram.ng.createProgram: 40.212ms
TypeChecker.gatherDiagnostics.ng.getTsSemanticDiagnostics: 2303.238ms
AngularCompilerPlugin._createOrUpdateProgram.ng.loadNgStructureAsync: 8121.846ms
AngularCompilerPlugin._listLazyRoutesFromProgram.listLazyRoutes: 71.627ms
AngularCompilerPlugin._emit.ng.getNgStructuralDiagnostics: 0.008ms
AngularCompilerPlugin._emit.ng.gatherDiagnostics.ng.getTsSyntacticDiagnostics: 0.727ms
AngularCompilerPlugin._emit.ng.emit: 20.587ms
AngularCompilerPlugin._emit: 22.402ms
AngularCompilerPlugin._update._emit: 22.714ms
AngularCompilerPlugin._update: 9410.339ms
AngularCompilerPlugin._make: 9410.673ms
ngcLoader+D:\sandbox\ng-speed-rebuild\projects\one\src\main.ts+.ngcLoader.AngularCompilerPlugin: 6585.910ms
ngcLoader+D:\sandbox\ng-speed-rebuild\projects\one\src\main.ts+: 6587.171ms

Date: 2019-11-28T13:43:53.432Z - Hash: b68597cdc628a6b6d240
416 unchanged chunks
chunk {main} main.110acf07b999c5995e7a.js, main.110acf07b999c5995e7a.js.map (main) 22 kB [initial] [rendered]
Time: 12609ms
: Compiled successfully.
TypeChecker.gatherDiagnostics.ng.getNgSemanticDiagnostics: 21980.041ms
TypeChecker.message: 24325.882ms

The main thread messages are the ones starting with AngularCompilerPlugin.. Most time seems to be spent in loadNgStructureAsync (~8s).

The type checker thread messages are the ones starting with TypeChecker.. Most of the time here is spent in getNgSemanticDiagnostics (~21s).

Comparing these detailed timings from CLI with ngc it looks like the CLI has added inneficiencies on type checking since the forked type checker always takes longer than the whole ngc compilation. It is unclear what contributes to the Time for diagnostics section in ngc though.

I can’t share our project. After a lot of work 🥱😫 , I think, I succeed to repro with fresh new project and a lot of duplicates tempaltes (due to i18n in our project) and sometimes a lot of weird templates (I know…) :

In branch master is rc3 which rebuild in ~8.5s (check this readme to see measures on this branch) https://github.com/elvisbegovic/ng-speed-rebuild#9-rc3-rebuild-85s

In branch rc2 is rc2 which rebuild in ~2.9s (check this readme to see measures on this branch) https://github.com/elvisbegovic/ng-speed-rebuild/tree/rc2#9-rc2-rebuild-29s

@IgorMinar I didn’t try rc1 but I guess it is even faster to rebuild, I’ll let you do it plz (rc1 in our project it is quick to rebuild).

I hope this is enough to repro.