Skip to content

Rebuild should be shorter because the lazy chunks have not changed #15086

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

Closed
doggy8088 opened this issue Jul 15, 2019 · 11 comments
Closed

Rebuild should be shorter because the lazy chunks have not changed #15086

doggy8088 opened this issue Jul 15, 2019 · 11 comments

Comments

@doggy8088
Copy link
Contributor

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

No.

Description

There are 3500 components/modules in this app. Everything lazy-loaded. When I run ng serve and edit any one file. The rebuild should be shorter because the lazy chunks have not changed.

🔬 Minimal Reproduction

git clone https://github.com/doggy8088/ng-cli-800-3500-components.git
cd ng-cli-800-3500-components
npm install
ng serve

Edit the src/app/features/page0001/page0001.component.ts file, it will wait more than 40 seconds to complete. It should be shorter.

🔥 Exception or Error

No error. It just slower than expected.

🌍 Your Environment



     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 8.0.6
Node: 10.16.0
OS: win32 x64
Angular: 8.0.3
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.800.6
@angular-devkit/build-angular      0.800.6
@angular-devkit/build-ng-packagr   0.800.6
@angular-devkit/build-optimizer    0.800.6
@angular-devkit/build-webpack      0.800.6
@angular-devkit/core               8.0.6
@angular-devkit/schematics         8.0.6
@angular/cli                       8.0.6
@ngtools/json-schema               1.1.0
@ngtools/webpack                   8.0.6
@schematics/angular                8.0.6
@schematics/update                 0.800.6
ng-packagr                         5.3.0
rxjs                               6.4.0
typescript                         3.4.5
webpack                            4.30.0

Anything else relevant?

N/A

@filipesilva
Copy link
Contributor

Tried the repro, and could see ~40s rebuild time on my machine. Noticed that TS processing took very long, some processing that I wasn't expecting to happen with chunks did, and that there was some sort of hashing computation done for the lazy modules too.

Something else that I found interesting: rebuilding at still takes ~14s after removing AppRoutingModule import. Rebuilds get back to ~1s after I delete src/app/features and src/app/app-routing.module.ts. This points to TS compilation still building those TS files, likely because they are always included in tsconfig.app.json (which we want to change in #15030 and #15061).

@SanderElias also mentioned that he saw high CPU usage on this repo in between builds. He thought it was due to the file watchers.

@Dylan-Israel
Copy link

Having the same issue with similar dependencies.

@filipesilva
Copy link
Contributor

Been looking into this and there are two parts to the problem:

  • when you change just one file (like main.ts) all files are emitted by TS
  • there's something about webpack processing sourcemaps for lazy modules even though they didn't change

Together these two things make the rebuild for a console.log(1); in main.ts be ~25s instead of ~1s.

The first problem was actually reported in #14775 and already addressed in #14778. I tested your repro with @angular-devkit/[email protected] and saw build times go down to 13s.

The second part I'm still trying to identify.

@filipesilva
Copy link
Contributor

Opened an issue in Webpack: webpack/webpack#9460. I could reproduce that having many chunks slows down webpack compilations (without any CLI stuff) even when the lazy chunks don't change.

@filipesilva
Copy link
Contributor

Updating to webpack 4.38 (#15170) should fix it, as the Webpack folks just added some very impressive (2x to 5x) rebuild perf improvements for this case.

@sokra
Copy link

sokra commented Jul 31, 2019

Any real world metrics about the effect of the fix?

@filipesilva
Copy link
Contributor

@sokra I compared dev rebuilds using @angular-devkit/[email protected] (which uses [email protected]) versus @angular-devkit/[email protected] (which uses [email protected], the version with your fixes) in a few projects:

So no apparent improvement with 0 lazy chunks, and increasingly bigger improvement as more lazy chunks are present.

@filipesilva
Copy link
Contributor

Closing as the fix has been merged and released.

@doggy8088
Copy link
Contributor Author

@filipesilva I didn't see this issue on release notes. Which version been applied?

@filipesilva
Copy link
Contributor

@doggy8088 the PR that updated our version of webpack was #15170, released first in https://github.com/angular/angular-cli/releases/tag/v8.2.0-rc.0. You should get it by updating to @angular-devkit/[email protected] or higher.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants