angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Rebuild extremely slow

Open asadsahi opened this issue 10 years ago • 226 comments

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?) Windows 10

  2. Versions. Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here: angular-cli: 1.0.0-beta.11-webpack.8 node: 6.3.0 os: win32 x64

  3. Repro steps. Was this an app that wasn't created using the CLI? What change did you do on your code? etc. app created with 1.0.0-beta.11-webpack.2 and later on upgraded to 1.0.0-beta.11-webpack.8 with appropriate changes.

  4. The log given by the failure. Normally this include a stack trace and some more information. The slow behavious is observed when upgraded from 1.0.0-beta.11-webpack.2 to 1.0.0-beta.11-webpack.8

  5. Mention any other details that might be useful. Slow behavious reproduceable in following repo: https://github.com/asadsahi/ng2fb-bootstrap


I have experience this on two operating systems, windows 7 and windows 10. Has anyone else experieced this? For me rebuilds are dramatically slow, taking roughly 7-8 seconds which on same machine with cli version webpack.2 was taking rougly 2-3 seconds.

asadsahi avatar Sep 05 '16 10:09 asadsahi

@asadsahi @clydin that seems to be a very relevant improvement. I'll add ts-loader to the list of scenarios I'm benchmarking as well.

filipesilva avatar Nov 17 '16 13:11 filipesilva

@filipesilva @clydin I recently discovered issues with ts-loader regarding packages such as rxjs that have .js and .d.ts files next to each other (see https://github.com/TypeStrong/ts-loader/issues/347). Additionally it seems that there are no plans for ts-loader to support Webpack 2 (see https://github.com/TypeStrong/ts-loader/issues/283#issuecomment-248432016). As such it seems to me that awesome-typescript-loader is the best option currently. IMHO it's a shame that there is no officially supported, de facto TypeScript loader out there, but awesome-typescript-loader seems like the closest thing atm (and will become even more so once Webpack 2 is released).

mischkl avatar Nov 22 '16 15:11 mischkl

@mischkl there has been a large amount of activity on ts-loader in the last 2-3 weeks. the ts2.0 situation has changed and I noticed no rxjs issues when using it with fairly large project. There are still the issues I mentioned in my previous comment however.

clydin avatar Nov 22 '16 16:11 clydin

@mischkl I didn't notice any issues using ts-loader in my playground project using Angular 2 (and RXJS obviously). It was a straight replacement with ATL.

asadsahi avatar Nov 22 '16 17:11 asadsahi

How does one replace ATL with ts-loader? What should I be modifying in webpack-build-typescript.js?

maximedupre avatar Nov 22 '16 23:11 maximedupre

Even ng help also slow in my machine! ubuntu 14.04 86_64

ambross avatar Nov 27 '16 13:11 ambross

Sadly, I'm considering buying a Mac Pro in order to be productive until this is fixed.

rightisleft avatar Nov 28 '16 15:11 rightisleft

@rightisleft Mac pro won't solve this problem. Rather try to switch to the webpack version with no cli, what I did

albandaft avatar Nov 28 '16 16:11 albandaft

All, new stats show ATL (3.0.0-beta.9) taking lead again:

With ts-loader:

image

With awesome-typescript-loader:

image

Means, ATL is taking lead in 3.beta9 again.

asadsahi avatar Nov 29 '16 15:11 asadsahi

@asadsahi do you know what was done in 3.0.0 to speed things up?

Sorry, i thought it's the next version of angular-cli that shows this performance improvement, but apparently your numbers are without using angular-cli?

anton-107 avatar Nov 29 '16 19:11 anton-107

@anton-107 Yes, its a non-cli project, but experiences presented here are of same nature.

asadsahi avatar Nov 29 '16 20:11 asadsahi

Same problem here (x86_64 GNU/Linux system). I get a much faster rebuild time with the quickstart official repo I guess I have to stick to that for now.

sangimed avatar Dec 01 '16 06:12 sangimed

Hey all, I've been running some benchmarks with recently added features in the CLI master branch.

  • https://github.com/angular/angular-cli/pull/3181 @ngtools/webpack as the TS loader for both AoT and non-AoT builds, across the board improvement.
  • https://github.com/angular/angular-cli/pull/3113 --sourcemap flag (defaults to true): uses sourcemaps on builds. Disabling it improves performance.
  • https://github.com/angular/angular-cli/pull/3117 --vendor-chunk flag (defaults to true): separates all non source files into vendor.bundle.js. Enabling it improves performance.

You can see them below:

  • using a new project (small project): https://gist.github.com/filipesilva/ede674667714a3497951b1d030f7e134#file-new-project-txt
  • using Ames (medium-sized project): https://gist.github.com/filipesilva/ede674667714a3497951b1d030f7e134#file-ames-txt

Baseline performance for ng serve, especially on rebuilds, should drastically improve across the board starting v1.0.0-beta.22.

Some users have also reported that turning off progress logging improved their build and rebuild times, but I could not verify that on my machine so I think it's setup dependant. https://github.com/angular/angular-cli/pull/2858 lets you turn it off via --no-progress.

P.S.: The medium project benchmark showed a performance regression for --aot builds, but we're working on fixing it.

filipesilva avatar Dec 01 '16 13:12 filipesilva

@filipesilva is --vendor-chunk same as generating DLL in webpack or different?

asadsahi avatar Dec 01 '16 13:12 asadsahi

@asadsahi no, it is not using DLL, but I still want to look into it and compare to the vendor chunk.

It essentially uses CommonChunksPlugin to syphon every requests module from node_modules into a new chunk: https://github.com/angular/angular-cli/blob/master/packages/angular-cli/models/webpack-build-common.ts#L42-L48

It turned out to be one of the major performance increases because the chunk asset optimization step seems to operates over the whole chunk on reloads, and if we limit the changes to a chunk containing source files then it's much faster.

filipesilva avatar Dec 01 '16 14:12 filipesilva

@filipesilva Can we have exact metrics for considering this issue fixed? Something like "rebuild ames in less than 1 seconds" or soemthing like that.

hansl avatar Dec 02 '16 18:12 hansl

I think there's a large performance regression in beta 22 in regards to SCSS compilation.

I did each of these in a single run and recorded times with $ ng serve

Saved SCSS: 11341, 10034, 10377, 9118, 10538 Saved HTML: 11820, 3224, 2820, 3002, 3983 Saved TS: 3982, 2701, 2561 Saved SCSS: 8856, 9551, 8793 Saved TS: 9505, 3888, 2961

As you can see, going from saving a SCSS to saving another file type (html or TS) causes that reload to also be slow once. If I look at the output, it spends a lot of time on SCSS files. I'm not doing anything intensive there.

I just built my project and it took this time: 204798ms

Another thing which is probably caused by @angularclass/hmr is that eventually the whole chrome tab crashes and I need to re-open that

intellix avatar Dec 03 '16 16:12 intellix

Maybe this symlink improvement by Microsoft could bring performance enhancements soon.

mzvast avatar Dec 03 '16 17:12 mzvast

Enabling hot module replacement for sass gives a huge performance boost. As you don't have to wait for the page to reload every time which can add another 3-4 secs or so. Would be cool to see that in place even if we can't get js HMR currently.

scottwio avatar Dec 03 '16 17:12 scottwio

@mzvast I don't think the symlink improvement means anything for performance, it's just easier to do. @scottwio HMR is in beta.22, you can use it by providing the --hmr flag and following this project as an example: https://github.com/jschwarty/angularcli-hmr-example/ (just a few changes required)

intellix avatar Dec 03 '16 18:12 intellix