Angular-cli: NG Builds takes 5 minutes on Build Server (build agent)

Created on 14 Aug 2017  路  11Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

My build agent is building the project ng build on a build server (windows) which has 32 cores. The problem is when building the project it only runs 1 core to 100% and all other cores are doing nothing.
Is there a option or can we change that somehow in a setting?
Now it takes 5 minutes and I think if it uses more cores it will be seconds...

Versions.

CLI 1.4.0-beta-0
NPM 5.3.0
Node 8.3.0

Repro steps.

ng build --prod

### The log given by the failure.
-

Desired functionality.

Needs to be faster, is there a option to use all cores?

Mention any other details that might be useful.

Windows Server with 32 cores.

RFC / discussion / question

Most helpful comment

I also fully encourage the use of multiple cores. My CPU utilization is only 16-20% throughout the entire build process, and it takes 3 minutes for me. Memory is at 2gb. Disk usage is 0%.

I'm upgrading to an i7-8700k soon - and that's going to have 6 cores. Yes, the cores will run at a higher clock speed, but my current CPU is already running at 4.2ghz so I'm not expecting as big of a jump as I would like.

It would be amazing if my 3 minute build time could go down to 30 seconds. Like omg I would give you a million hugs.

All 11 comments

Not sure if it's related or not, but I'm seeing a similar performance issue when running ng build on my AWS nodes on 1.1.3. It's taking almost a full minute to build, when it succeeds, I updated from 1.0.1 as it was crashing out.

Well we don't do anything in parallel (node itself is single threaded) so there isn't a single switch to make it use more cores. There's some Webpack plugins to split the load through more threads but it's not really a silver bullet since the really expensive operations are not parallelizable anyway.

Did it take roughly the same time in 1.3.x though? Maybe something happened which decreased the performance.

Im not sure, did not had 1.3 at that time when doing builds on build server.

But its such a long time hehe

I'd also highly appreciate if angular cli would try to actively use parallelization of build steps where this is achievable. We have a medium-sized project with over 200 components and around 20 modules. We have seen compile times increase a lot with every module that we add, so we're currently at around 80s with AOT for a build on a Core i7-7700k (pretty much the fastest single thread desktop CPU you can get).

We're building three variants of our app in parallel, so we can make up a bit for it but since each build needs ~2GB of RAM that's not a nice load pattern for our CI servers, which therefore build sequential. We'd get a huge productivity boost from faster local builds running ng serve as well, which takes roughly 45s without AOT for initial display.

Have you seen this article here? https://medium.com/webpack/typescript-webpack-super-pursuit-mode-83cc568dea79 For sure it would speed up typescript compilation and then there's still AOT, but I think it's worth giving it a shot.

On a related note, the angular AOT compiler could theoretically build modules in parallel, couldn't it? On first sight, that sounds like a plausible idea anyway.

I also fully encourage the use of multiple cores. My CPU utilization is only 16-20% throughout the entire build process, and it takes 3 minutes for me. Memory is at 2gb. Disk usage is 0%.

I'm upgrading to an i7-8700k soon - and that's going to have 6 cores. Yes, the cores will run at a higher clock speed, but my current CPU is already running at 4.2ghz so I'm not expecting as big of a jump as I would like.

It would be amazing if my 3 minute build time could go down to 30 seconds. Like omg I would give you a million hugs.

Angular production build really takes a long time to build, compare similar projects build with other frameworks. My company have a medium size project and it now takes about 10min to build. What's worse is it also eat 4GB memory and it exceeded node default settings, so I have to do --max-old-space-size=4096 to overcome this.

I think nowadays the CPUs usually have more cores but the same performance for single thread apps. It would be really beneficial to have the compiler take advantage of multi-cores.

right now, my only solution is upgrade samsung evo ssd pro version. disk load from 500mb/s to 3.5gb/s. If you using some kind of ram cache. it could load to 7gb/s. save alot of time.

But... I still hope that angular cli can take full advantage of my the 6 core 12 thread cpu. 馃槩 sad

Well we don't do anything in parallel (node itself is single threaded) so there isn't a single switch to make it use more cores. There's some Webpack plugins to split the load through more threads but it's not really a silver bullet since the really expensive operations are not parallelizable anyway.

Did it take roughly the same time in 1.3.x though? Maybe something happened which decreased the performance.

Well we don't do anything in parallel (node itself is single threaded) so there isn't a single switch to make it use more cores. There's some Webpack plugins to split the load through more threads but it's not really a silver bullet since the really expensive operations are not parallelizable anyway.

Did it take roughly the same time in 1.3.x though? Maybe something happened which decreased the performance.

Hi filipesilva,
by default node is a 'single-threaded', but for heavy computational needs -such as build, this is not performance sufficient. BUT - exactly for such cases node has built-in models 'Child Process' & 'Process'.
They allow the node user to spawn new processes, thus utilizing more CPU core.
Read about these models at : https://nodejs.org/docs/latest/api/child_process.html,
https://nodejs.org/docs/latest/api/process.html

This issue is now out of date. It's for version 1.4-beta and since then we reworked all the internals.

Is it being handled 1.4-beta or not ?

NodeJS "cluster" module or new "worker_threads" module with SharedArrayBuffer can be used for parallel processing

Cluster - https://nodejs.org/docs/latest/api/cluster.html
Worker Threads - https://nodejs.org/docs/latest/api/worker_threads.html

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IngvarKofoed picture IngvarKofoed  路  3Comments

gotschmarcel picture gotschmarcel  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments

naveedahmed1 picture naveedahmed1  路  3Comments

MateenKadwaikar picture MateenKadwaikar  路  3Comments