question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AOT Dev builds in Angular v9+ are much slower than JIT

See original GitHub issue

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, not present in 8.2.

Description

Dev builds in Angular 9 are very slow. Builds of 8.2 took on average 30 seconds or so, and recompiles took 2-5 seconds. This same app in Angular 9, however, takes ~45-60 seconds to build initially, and recompiles take ~15-25 seconds even if nothing changes at all. Production builds are roughly 5-10 seconds faster in 9, so those are better at least. (Note that none of these times include ngcc, that’s taken care of before I attempt to build.) Additionally, the speed is slow regardless of whether Ivy is used or not.

The Angular 9 build always seems to freeze for a bit at a certain point. It frequently lists the same file, but it’s not always the same file that it seems to get stuck on. There’s nothing special about the file it usually lists, it’s actually quite small and has no advanced Angular or TypeScript features.

I found #34699 (and #33532 by extension), but those are unrelated. I’m using TS 3.8 and it happens regardless of the value of that option in tsconfig.json.

Is there a way I can audit what’s causing it to take so long? I tried ng build --watch --verbose, but it provides way more information than I can feasibly parse (and also doesn’t include timings from what I can tell).

🔬 Minimal Reproduction

This repo has a reproduction. Instructions are in the readme.

🔥 Exception or Error

N/A

🌍 Your Environment

Angular CLI: 9.1.3
Node: 13.12.0
OS: win32 x64

Angular: 9.1.3
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.901.3
@angular-devkit/build-angular      0.901.3
@angular-devkit/build-ng-packagr   0.901.3
@angular-devkit/build-optimizer    0.901.3
@angular-devkit/build-webpack      0.901.3
@angular-devkit/core               9.1.3
@angular-devkit/schematics         9.1.3
@ngtools/webpack                   9.1.3
@schematics/angular                9.1.3
@schematics/update                 0.901.3
ng-packagr                         9.0.3
rxjs                               6.5.4
typescript                         3.8.3
webpack                            4.42.0

Anything else relevant? N/A

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:123
  • Comments:90 (31 by maintainers)

github_iconTop GitHub Comments

27reactions
bhanna1693commented, Jul 22, 2020

While the idea of AOT compilation is great, this issue is too much to ignore (if you ask me). Development times have skyrocketed for our team:

  • ng serve (avg time)
    • w/o aot: 55s
    • w/ aot: 1m 45s
  • ng build --prod (avg time)
    • w/o aot: 1m 26s
    • w/ aot: 3m 13s

This has to be a higher priority for the Angular team

17reactions
alan-agius4commented, Apr 24, 2020

In version 9, AOT and JIT compilations time should be similar.

Unfortunately, since you cannot provide a reproduction not even privately. I don’t see how we can investigate this any further.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ahead-of-time (AOT) compilation - Angular
The Angular ahead-of-time (AOT) compiler converts your Angular HTML and TypeScript code into efficient JavaScript code during the build phase before the browser ......
Read more >
After upgrading to Angular 9, compile time has increased ...
Compile Time Issue. FIX. Turn off AOT in the angular.json -> search the first occurrence (default build config) of aot and change from...
Read more >
How to speed up your Angular builds - Bitovi
Slow builds stop developers' productivity cold. ... Builds will take slightly longer than just-in-time (JIT) compilation, but the page will ...
Read more >
Angular 9: What's New? - John Papa
It seems that AOT compilation would have made the dev builds too slow to be a good experience, so the Angular team opted...
Read more >
What is IVY In Angular - Oodles Technologies
As we can see in the past section the AOT compilation was slower than JIT compilation so JIT was used for development. From...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found