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

Yes, isolatedModules are good when you know you are not messing about with imports. However, you lose the checks against other files if you do change imports. My point is it should be possible in to keep track of which imports changed and then only check those.

Hard problem though, especially when combining TS with Webpack.

On Jan 12, 2017 07:17, "Aleksandar Milošević" [email protected] wrote:

@hansl https://github.com/hansl @hccampos https://github.com/hccampos compilerOptions.isolatedModules is the one flag that can impact rebuild times in a huge way. I'm using custom gulp tasks for building (on top of CLI project) and if I set "isolatedModules": false rebuild times for just touching one file are 3.39s, 3.33s, 3.29s. with "isolatedModules": true I get 186ms, 73ms, 82ms. I'm not familiar with inner workings of webpack, so I'm not sure where/how this would affect other stuff, but I hope it helps (;

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/1980#issuecomment-272085546, or mute the thread https://github.com/notifications/unsubscribe-auth/ADlcCt6N92TzYrtLLdmJllmbr5PlB97Sks5rRcVrgaJpZM4J07P9 .

hccampos avatar Jan 12 '17 06:01 hccampos

@hccampos Question is do we really need that strict checking all the time? IDEs do most of this already. I've been working on an app for past 3 months with 2-3 major architectural changes and quite large refactoring each time. After all that, building the same app with isolatedModules turned off this morning I got only one import error in obscure DevComponent I rarely use.

I think it would be good idea to turn on isolatedModules flag with ng serve and off for ng build and other stuff...

sasxa avatar Jan 12 '17 10:01 sasxa

@sasxa Good point indeed! Still would be nice if TS and Webpack could optimize further since it would be a gain for everyone, both those who use TS aware editors and those who don't. In Webpack's case, it would be great also for people using React and other non-ts stuff.

hccampos avatar Jan 12 '17 11:01 hccampos

Not sure if this is helpful at all but I noticed that build and rebuild of the exact same project are an order of magnitude faster on my machine when running osx rather than windows 10. I'm on a new macbook pro (i7-6820 / 16gb) and build/rebuild is around 8,000ms / 2,500ms under osx, but 45,000/10,000ms under Windows 10 (bootcamp, not virtualized). I'm on beta.24 currently, and this is a real application, not huge, but significantly more than hello world. 2,5s rebuild is acceptable for workflow IMO, 10s is painful.

Any further information I can provide that might be useful?

mrlund avatar Jan 12 '17 12:01 mrlund

@mrlund can you try adding your project folder as an exclusion to Windows Defender, to see if it helps?

https://support.microsoft.com/en-ie/instantanswers/64495205-6ddb-4da1-8534-1aeaf64c0af8/add-an-exclusion-to-windows-defender

filipesilva avatar Jan 12 '17 12:01 filipesilva

OS X is an outlier in this case, and we have file system events to thank for that. No constant check of modification dates, just an event that gets emitted whenever a file changes that the driver can act on. Don't be fooled by the time difference.

On Thu, Jan 12, 2017 at 7:38 AM Filipe Silva [email protected] wrote:

@mrlund https://github.com/mrlund can you try adding your project folder as an exclusion to Windows Defender, to see if it helps?

https://support.microsoft.com/en-ie/instantanswers/64495205-6ddb-4da1-8534-1aeaf64c0af8/add-an-exclusion-to-windows-defender

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/1980#issuecomment-272153139, or mute the thread https://github.com/notifications/unsubscribe-auth/ADajDVajAsG8Tb9HIHRo8Y40yn3SkQunks5rRh7WgaJpZM4J07P9 .

celliott181 avatar Jan 12 '17 14:01 celliott181

@filipesilva No discernible difference with project folder excluded in Windows Defender.

mrlund avatar Jan 12 '17 15:01 mrlund

@gelliott181 @mrlund I don't notice a difference in my system either but wanted to double check. It seems to help for Ember projects but we've since moved away from brocolli.

filipesilva avatar Jan 12 '17 15:01 filipesilva

Have you experimented with this before? parallel-webpack.

I just learned about it from here in this awesome deck Addy Osmani recommended about Webpack.

Meligy avatar Jan 14 '17 09:01 Meligy

I think that one would be tricky to add. There is also Happypack, but it doesn't (and likely never will) play well wit h typescript.

Hopefully we can make some more profiles with the new profiling options and then find places where the cli, webpack and TS can improve. I haven't had the time to dig more into it, but hopefully will soon.

hccampos avatar Jan 14 '17 09:01 hccampos

Here you go @hansl and @TheLarkInn , a profile of 3 rebuilds without any changes to any files (only pressing cmd+s in VSCode to trigger a rebuild).

CPU-20170116T224647.cpuprofile.zip

This thing here looks suspicious, the Angular compiler doing a LOT of stuff there. But I am not familiar with it at all.

screen shot 2017-01-16 at 22 57 03

hccampos avatar Jan 16 '17 21:01 hccampos

Just to add another experience Report: I've switched to working on my Project on a Windows machine recently (from OS X) and even though my new machine is significantly faster running our full AOT builds (120s down to 75s), rebuilds are taking much longer (2.5s to 16s).

I can thus certainly confirm what @mrlund reported.

JohannesRudolph avatar Jan 20 '17 09:01 JohannesRudolph

@mrlund @JohannesRudolph I work on a windows machine but don't get that massive slowness. Mine is win10, and I have an admin account.

Can you give me your system specs and whether or not you have admin? Maybe I can figure out how to repro it on my machine.

filipesilva avatar Jan 20 '17 10:01 filipesilva

@filipesilva: it's a fresh install of win10 pro, I'm admin (local user account) and it's a [email protected], SSD, 16GB RAM....

The slowdown on Windows compared to OS X (exact same repo etc.) is very interesting indeed. Let me know if there's anything I can help you with to get to the bottom of this.

JohannesRudolph avatar Jan 20 '17 10:01 JohannesRudolph

From looking at the Task Manager during a live rebuild I get the impression that it's not an i/o bound issue, thus pointing away from fsevents and friends. Though that may be misleading due to fs caching in the OS.

Disk active time stays below 2% while one CPU core is fully loaded (indicating webpack is single-threaded at the moment). So whatever it is, the Windows rebuild appears does a lot more work than a rebuild on OS X.

Edit: One more Thing, I'm using SCSS with this Project and I think a previous commenter here has pointed this out as a possible cause as well.

JohannesRudolph avatar Jan 20 '17 10:01 JohannesRudolph

@filipesilva My experience is the same as @JohannesRudolph I'm on a new touchbar MacBook Pro 15", a i7-6820HQ @ 2.7GHz with 16GB RAM, and the super-fast SSD.

I'm NOT using SCSS, but plain CSS, and I get similar numbers, that indicate the hardware is by no means stressed (8-9% CPU, 0-5% Disk) during both build and rebuild. One notable thing, however is that the node process reaches almost 1GB of RAM consumption, which seems excessive?

Windows 10 (x64), recent install, node 6.9.4. (was previously running node 7), local admin user. I've also run ng serve from an elevated command prompt as the actual admin user with no discernable difference.

mrlund avatar Jan 20 '17 11:01 mrlund

@JohannesRudolph can you try making a new project using plain CSS and another with SCSS on your machine to see if the rebuild differences are noticeable?

filipesilva avatar Jan 20 '17 11:01 filipesilva

@mrlund could you check if you also get it on a new project? I'm wondering if it's project specific.

Also could you tell me the path your slow project is at? And if you have any symlinked node modules.

filipesilva avatar Jan 20 '17 11:01 filipesilva

@filipesilva we have the same experience in our company. Everyone.

Linux: 4sec Windows: 19sec.

Seems like NTFS (inodes) have serious performance issues with tons of small files

montella1507 avatar Jan 20 '17 11:01 montella1507

@montella1507 i experience the same issue. On ubuntu 16.04 rebuild time is ... managable, on windows 10 it is a real pain.

aegyed91 avatar Jan 20 '17 12:01 aegyed91