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

Running ng test is excruciatingly slow. It takes quite some time to detect there are changes and then re-run them.

New project with 79 tests:

Single/first run: ~90s Changes:: ~12s Changes after using for some time before it crashes:: ~20s

As @guiomie said, the numbers don't add up for serving either: 638+10+1+3+200+1+17+121+149+3+6+18+78+83+3+6+1047 = 2384ms but says 6080ms so seems to be 3696ms going somewhere else.

intellix avatar Oct 20 '16 07:10 intellix

Just using the default ng new app takes about 3 seconds to reload. Is there a way to limit the munging wepback is doing to speed this up? Even if just for live reload scenarios.

cetra3 avatar Oct 20 '16 22:10 cetra3

5269 ms to reload on simple changes on OS X El Capitan with clean ng new

screen shot 2016-10-21 at 5 31 55 am

ihorskyi avatar Oct 21 '16 09:10 ihorskyi

Same here. Just write to subscribe to the thread. Environment: Intel i7, SSD Disk, Windows 10 => Initial Hello World compilation 15 seconds aprox. Recompilation after minimum changes: 6 seconds what makes it unpractial for agile development.

Using angular quickstart project from github without webpack gives me times of 300 ms for live-reloading. There must to be a way to choose not compiling during development and use bundling and minification only for production in my opinion.

YagoLopez avatar Oct 22 '16 18:10 YagoLopez

@YagoLopez , if I look in the models/webpack-build-developement.js , it looks like minification is disabled:

plugins: [
            new webpack.LoaderOptionsPlugin({
                options: {
                    minimize: false,
                    tslint: {
                        emitErrors: false,
                        failOnHint: false,
                        resourcePath: path.resolve(projectRoot, appConfig.root)
                    },
                }
            })
        ],

guiomie avatar Oct 22 '16 21:10 guiomie

@guiomie we reserve critical for stuff like release bugs, or wholly broken commands. Stuff that usually needs a new release ASAP or no one can do anything.

We recognise that the slowness is crippling and are looking to solutions for it. It's one of the things we want to address before RC1.

filipesilva avatar Oct 22 '16 22:10 filipesilva

Also thanks to all that are posting their numbers, it's very useful to get a benchmark. @intellix's report is specially worrying imho.

filipesilva avatar Oct 22 '16 22:10 filipesilva

@filipesilva thanks for your work, i undertand the complexities of the problem. I guess it is question of time.

@guiomie thanks for the info, but then, source map files should't be created in the process of compilation. If I'm not wrong they do are created. Anyway with minification or not its too much time in my opinion. I guess this problems will be solved in future versions. Cheers.

YagoLopez avatar Oct 22 '16 22:10 YagoLopez

@intellix https://github.com/angular/angular-cli/pull/2840 should help with ng test. It makes code coverage and linting optional. On a test project with 100 component tests, total time went down from 90s to 30s.

filipesilva avatar Oct 23 '16 13:10 filipesilva

@filipesilva that sounds useful, at least as it makes a lot of sense to (optionally) skip coverage reporting when running ng test --watch=true

I'm still not sure though why webpack spends so much time in "chunk assets optimization". Might be a webpack related issue after all.

JohannesRudolph avatar Oct 23 '16 13:10 JohannesRudolph

@filipesilva Brand new to all-things Angular. I just installed the Angular CLI and am going through the free introductory Angular 2 course on egghead.io. I've literally made 1 change to a component file, and the rebuilds are slow (not to be too redundant from everything in this thread):

angular-cli: 1.0.0-beta.18
node: 6.5.0
os: darwin x64

Bootingup ng serve I get...
Time: 8973ms

If I save index.html, I get...
Time: 3329ms 

Which isn't necessarily bad, but I haven't actually done anything with files yet:) 

I know this is still in beta, so please don't take this negatively, but coming from Ember and React, I've never seen builds/reloads this slow. Should I hold off on using CLI for learning NG 2 until the process is a bit faster? I'm looking more for guidance than I am trying to criticize the project. Thanks!

rdwatters avatar Oct 23 '16 23:10 rdwatters

Excuse me if this is not the right place to post this, but does webpack use hot module reloading with "ng serve" on Windows? I've seen videos on youtube about angular 2 where only the file edited is reloaded instead of rebuilding all files, (in a Mac computer).

@rdwatters you could try this https://github.com/angular/quickstart. It's a bit faster in my experience. It does not use angular-cli but could be appropiated for testing purposes

Also this could be of interest for anyone reading this:

Working with editors/IDEs supporting “safe write”

Note that many editors support “safe write” feature and have it enabled by default, which makes dev server unable to watch files correctly. “Safe write” means changes are not written directly to original file but to temporary one instead, which is renamed and replaces original file when save operation is completed successfully. This behaviour causes file watcher to lose the track because the original file is removed. In order to prevent this issue, you have to disable “safe write” feature in your editor.

VIM - set :set backupcopy=yes (see documentation) IntelliJ - Settings ▶︎ System Settings ▶︎ Synchronization ▶︎ disable safe write (may differ in various IntelliJ IDEs, but you can still use the search feature)

SOURCE: https://webpack.github.io/docs/webpack-dev-server.html

YagoLopez avatar Oct 25 '16 13:10 YagoLopez

Some additional info from me. Updating takes 20 seconds for me.

webpack: bundle is now INVALID.
 50% building modules 2/3 modules 1 active ...sers\user-edit\user-edit.component.tsweb
pack: wait until bundle finished: /settings
1339ms building modules
1457ms sealing
0ms optimizing
1ms basic module optimization
100ms module optimization
3269ms advanced module optimization
24ms basic chunk optimization
0ms chunk optimization
0ms advanced chunk optimization
530ms module and chunk tree optimization
384ms module reviving
3ms module order optimization
48ms module id optimization
129ms chunk reviving
1ms chunk order optimization
503ms chunk id optimization
110ms hashing
1ms module assets processing
142ms chunk assets processing
12ms additional chunk assets processing
0ms recording
1ms additional asset processing
6849ms chunk asset optimization
1570ms asset optimization
397ms emitting
Hash: 9db8a41caee5835af84d
Version: webpack 2.1.0-beta.25
Time: 20520ms
           Asset     Size  Chunks             Chunk Names
           0.map   117 kB   0, 30
      0.chunk.js  95.5 kB   0, 30
      2.chunk.js   210 kB   2, 30
      3.chunk.js  1.16 MB   3, 30
      4.chunk.js  18.4 kB   4, 30
      5.chunk.js  20.6 kB   5, 30
      6.chunk.js   115 kB   6, 30
      7.chunk.js  70.6 kB   7, 30
      8.chunk.js  96.1 kB   8, 30
      9.chunk.js    13 kB   9, 30
     10.chunk.js  54.2 kB  10, 30
     11.chunk.js  40.1 kB  11, 30
     12.chunk.js   177 kB  12, 30
     13.chunk.js  15.8 kB  13, 30
     14.chunk.js  11.8 kB  14, 30
     15.chunk.js  19.4 kB  15, 30
     16.chunk.js  9.67 kB  16, 30
     17.chunk.js  34.8 kB  17, 30
     18.chunk.js  16.7 kB  18, 30
     19.chunk.js  18.9 kB  19, 30
     20.chunk.js  66.2 kB  20, 30
     21.chunk.js  11.4 kB  21, 30
     22.chunk.js  56.3 kB  22, 30
     23.chunk.js   410 kB  23, 30
     24.chunk.js  64.7 kB  24, 30
     25.chunk.js  2.44 kB  25, 30
     26.chunk.js  33.2 kB  26, 30
     27.chunk.js   238 kB  27, 30
  main.bundle.js  6.75 MB  28, 30  [emitted]  main
styles.bundle.js  12.9 kB  29, 30             styles
       inline.js  5.53 kB      30             inline
      1.chunk.js   315 kB   1, 30
           1.map   415 kB   1, 30
           2.map   248 kB   2, 30
           3.map  1.26 MB   3, 30
           4.map  22.3 kB   4, 30
           5.map  24.6 kB   5, 30
           6.map   146 kB   6, 30
           7.map  91.1 kB   7, 30
           8.map   118 kB   8, 30
           9.map  18.4 kB   9, 30
          10.map  69.8 kB  10, 30
          11.map  46.3 kB  11, 30
          12.map   217 kB  12, 30
          13.map  20.5 kB  13, 30
          14.map  14.8 kB  14, 30
          15.map  23.3 kB  15, 30
          16.map  12.6 kB  16, 30
          17.map  40.4 kB  17, 30
          18.map    20 kB  18, 30
          19.map  22.1 kB  19, 30
          20.map  79.1 kB  20, 30
          21.map  13.8 kB  21, 30
          22.map  66.7 kB  22, 30
          23.map   494 kB  23, 30
          24.map  77.2 kB  24, 30
          25.map  3.16 kB  25, 30
          26.map  41.5 kB  26, 30
          27.map   295 kB  27, 30
      styles.map  17.6 kB  29, 30             styles
      inline.map  5.59 kB      30             inline
        main.map  7.31 MB  28, 30  [emitted]  main
Child html-webpack-plugin for "index.html":
         Asset     Size  Chunks       Chunk Names
    index.html  6.11 kB       0
webpack: bundle is now VALID.

sharok avatar Oct 27 '16 08:10 sharok

Just wanna add some information to help others with testing: fdescribe, fit, xdescribe, xit are your friends for only running particular tests :) http://jasmine.github.io/2.1/focused_specs.html

intellix avatar Oct 27 '16 09:10 intellix

First of all, thanks for the great work all. Was hoping Node 7 upgrade might help, but it was only marginal. Would love to see this sped up as well. For example, the following similar project is on the React side, but rebuilds in about 1/4 the time. https://github.com/davezuko/react-redux-starter-kit

jmlivingston avatar Oct 27 '16 17:10 jmlivingston

I experience the same Problems on my mac with OSX 10.11.6. Updates take 13secs for me. What is your idea on solving this? With plain webpack I'd probably try to improve performance by separating the build of the libraries and the build of my own files using the dll approach.

My numbers are btw. the following:

webpack: bundle is now INVALID.
354ms building modules                                                             
5ms sealing 
0ms optimizing 
0ms basic module optimization 
119ms module optimization
0ms advanced module optimization 
13ms basic chunk optimization       
0ms chunk optimization 
0ms advanced chunk optimization 
38ms module and chunk tree optimization
172ms module reviving
1ms module order optimization 
3ms module id optimization 
7ms chunk reviving 
0ms chunk order optimization 
47ms chunk id optimization
67ms hashing
1ms module assets processing 
98ms chunk assets processing
4ms additional chunk assets processing 
1ms recording 
0ms additional asset processing 
3092ms chunk asset optimization
7742ms asset optimization
69ms emitting
Hash: 8065f4ec0d2feed80685
Version: webpack 2.1.0-beta.25
Time: 13361ms
                                 Asset     Size  Chunks             Chunk Names
  f24134ff542a345f5af1c3e616872d8b.svg  12.8 kB                     
  f4769f9bdb7466be65088239c12046d1.eot  20.1 kB                     
  c3572dbbb07e826429824fe22f049c73.eot    48 kB                     
  55ed4dcca47c6b224f2ed1536524f6ed.svg  71.7 kB                     
 78bb38012b6093e39a98a8a5270f81f6.woff  55.2 kB                     
  89889688147bd7575d6327160d64e760.svg   109 kB                     
  e18bbf611f2a2e43afc071aa2f4e1512.ttf  45.4 kB                     
 fa2772327f55d8198301fdb8bcfc8158.woff  23.4 kB                     
  ff22e7b0d9516041df8efa602e806bfc.eot  3.62 kB                     
448c34a56d699c29117adc64c43affeb.woff2    18 kB                     
                        main.bundle.js  4.97 MB    0, 2  [emitted]  main
                      styles.bundle.js   228 kB    1, 2             styles
                             inline.js  5.53 kB       2             inline
                            styles.map   289 kB    1, 2             styles
                            inline.map  5.59 kB       2             inline
                              main.map  5.28 MB    0, 2  [emitted]  main
Child html-webpack-plugin for "index.html":
         Asset     Size  Chunks       Chunk Names
    index.html  3.83 kB       0       
webpack: bundle is now VALID.

paweloque avatar Oct 29 '16 21:10 paweloque

Not sure how it would be implemented, or if it's already possible? but If I could exclude rebuilding all node_modules/* from the 'ng-build' command, and just 'compile' my changed partials/js/css files I think that would reduce my build-time considerably. It's not often I'd need to rebuild the node_modules.

samthomson avatar Oct 30 '16 14:10 samthomson

Hi! I have implemented the dll option for faster rebuilds. Check my fork to try it: https://github.com/kondi/angular-cli I have more than two times faster rebuild for the default empty project.

kondi avatar Nov 02 '16 16:11 kondi

@kondi tried linking your repo to one of playground project, but cannot see reasonable difference of rebuilds, here are the stats:

Before:

Version: webpack 2.1.0-beta.25
Time: 4127ms
                                 Asset     Size  Chunks             Chunk Names
                      styles.bundle.js   183 kB    7, 9             styles
  25a32416abee198dd821b0b17a198a8f.eot  76.5 kB                     
  1dc35d25e61d819a9c357074014867ab.ttf   153 kB                     
 c8ddf1e5e5bf3682bc7bebf30f394148.woff  90.4 kB                     
e6cf7c6ec7c2d6f670ae9d762604cb0b.woff2  71.9 kB                     
                            0.chunk.js   456 kB    0, 9             
                            1.chunk.js  36.4 kB    1, 9             
                            2.chunk.js  21.9 kB    2, 9             
                            3.chunk.js  9.89 kB    3, 9  [emitted]  
                            4.chunk.js  14.5 kB    4, 9             
                            5.chunk.js  11.9 kB    5, 9             
                        main.bundle.js  3.81 MB    6, 9             main
  d7c639084f684d66a1bc66855d193ed8.svg   392 kB                     
                     scripts.bundle.js   461 kB    8, 9             scripts
                             inline.js  5.53 kB       9             inline
                                 0.map   570 kB    0, 9             
                                 1.map  31.4 kB    1, 9             
                                 2.map  18.8 kB    2, 9             
                                 4.map  13.3 kB    4, 9             
                                 5.map  9.82 kB    5, 9             
                              main.map  3.97 MB    6, 9             main
                            styles.map   248 kB    7, 9             styles
                           scripts.map   570 kB    8, 9             scripts
                            inline.map  5.59 kB       9             inline
                                 3.map  7.45 kB    3, 9  [emitted]  
Child html-webpack-plugin for "index.html":
         Asset    Size  Chunks       Chunk Names
    index.html  3.8 kB       0       
webpack: bundle is now VALID.


After:

ersion: webpack 2.1.0-beta.25                                                                                                                        
Time: 3508ms                                                                                                                                          
                                 Asset     Size  Chunks             Chunk Names                                                                       
                      styles.bundle.js   186 kB    7, 9             styles                                                                            
  25a32416abee198dd821b0b17a198a8f.eot  76.5 kB                                                                                                       
  1dc35d25e61d819a9c357074014867ab.ttf   153 kB                                                                                                       
e6cf7c6ec7c2d6f670ae9d762604cb0b.woff2  71.9 kB                                                                                                       
 c8ddf1e5e5bf3682bc7bebf30f394148.woff  90.4 kB                                                                                                       
                            0.chunk.js   458 kB    0, 9                                                                                               
                            1.chunk.js  36.3 kB    1, 9                                                                                               
                            2.chunk.js  21.7 kB    2, 9                                                                                               
                            3.chunk.js  9.84 kB    3, 9  [emitted]                                                                                    
                            4.chunk.js  14.4 kB    4, 9                                                                                               
                            5.chunk.js  11.8 kB    5, 9                                                                                               
                        main.bundle.js  1.06 MB    6, 9             main                                                                              
  d7c639084f684d66a1bc66855d193ed8.svg   392 kB                                                                                                       
                     scripts.bundle.js   461 kB    8, 9             scripts                                                                           
                      inline.bundle.js  5.53 kB       9             inline                                                                            
                                 0.map   577 kB    0, 9                                                                                               
                                 1.map  31.6 kB    1, 9                                                                                               
                                 2.map    19 kB    2, 9                                                                                               
                                 4.map  13.4 kB    4, 9                                                                                               
                                 5.map  9.95 kB    5, 9                                                                                               
                              main.map   1.2 MB    6, 9             main                                                                              
                            styles.map   252 kB    7, 9             styles                                                                            
                           scripts.map   570 kB    8, 9             scripts                                                                           
                            inline.map   5.6 kB       9             inline                                                                            
                                 3.map  7.57 kB    3, 9  [emitted]                                                                                    
Child html-webpack-plugin for "index.html":                                                                                                           
         Asset    Size  Chunks       Chunk Names                                                                                                      
    index.html  3.8 kB       0                                                                                                                        
webpack: bundle is now VALID.        

Time is lesser after linking, but sometimes with original angular-cli its roughly same.

asadsahi avatar Nov 02 '16 17:11 asadsahi

For me in a freshly created ng new project the rebuild time is around 5000 ms without dll, 2000 ms using dll.

@asadsahi I checked your repository on my laptop. Without dll the rebuild time is around 11500 ms, with dll I am getting 6600 ms. I can get 5200 ms if I move more libraries to the dll (angularfire2, ng-bootstrap, ng2-translate). Your numbers look much better by default already. Maybe because I am testing on windows? Or slow computer?

kondi avatar Nov 03 '16 13:11 kondi