Skip to content

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

@vaindil

Description

@vaindil

🐞 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: compilerIssues related to `ngc`, Angular's template compilerarea: performanceIssues related to performancestate: confirmedtype: bug/fix

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions