You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Build Optimizer increasing build time excessively #12153
Only around 2 minutes difference now !Thanks for your hard work @filipesilva.
If we can make the difference within 1 minute , so much the better :)
Thanks again.
Hi i am also having this issue but am not using angular-cli, any recomendations what i can do to make my build work with build-optimizer turned on. In my case it gets to around 50% then hangs forever
@filipesilva here is my branch https://github.com/caroline-church/fabric-composer/tree/improve-performance-2. Its a mono-repo so you have to run npm install in the top level directory. The package you want to look at is composer-playground. If you run npm run buikd:prod you will see the problem. I narrowed it down to that the problem was the composer-common dependency, but wasn't sure why it would cause a problem.
Hi everyone!
I have a case when building for production an ng app:
This hangs forever (it is not a memory problem, uses around 400Mb) but keeps consuming CPU and do not finish. ng build -e prod -prod -aot --base-href x
This other one, disabling the build optimizer, works: ng build -e prod -prod -aot --base-href x --build-optimizer=false
One particularity on the ng project is that it contains one big/medium file (a generated parser) of 108 Kb in size and this looks to be the hanging point.
Can you show me your ng version output? I'd also be curious to know what the difference in bundle size is with and without Build Optimizer.
Although at this point if I had to bet on the root cause, it might be memory. If your builds are already close to the memory limit, anything that moves them closer will disproportionately increase build time due to GC churn. #5618 (comment) contains instructions on how to increase this limit.
BTW, we already encountered issues with the node memory limit, so we are using this command to run our build: npm run ng-high-memory -- build --base-href=/XYZ/ --configuration=production
with ng-high-memory being defined as: "ng-high-memory": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng"
(So we actually already applied the hints from the linked issue)
I'd also update @angular-devkit/build-angular to the latest version btw. That's the actual build system. Memory is limited by NodeJS itself btw, so even on a machine with a lot of memory you won't be using it by default unless you use those scripts.
Also your total bundle might get quite smaller if you don't have the vendor bundle in production. Maybe try it if you're curious.
At the end of the day you do have over 8mb of code post optimizations... that's a lot of code. And it looks like the benefits from Build Optimizer might be marginal at for your code base. It is a reasonable option to turn it off if it's not worth the extra build time.
Thanks for the hints. We actually did experiment without the vendor chunk and the differences in size were marginal, even more marginal than the difference with the build optimizer.
Regarding the overall size: You are correct, it's a lot. We are currently in the process of optimizing our dependencies, which hopefully shaves off some megabytes
Now I do have such a hanging build again, after I updated @angular-devkit/build-angular. And the strange thing is that the node process uses about 1.4GB but no CPU at all. It just sits there, and idles. What could cause such behaviour? Is there some verbose logging that I could enable to troubleshoot this?
It should indeed. I'm not sure what's happening in your project :/
I know some older versions of node had memory issues as well, so maybe node 10 helps but... being stuck at 1.4 makes it really look like the node memory flag isn't being applied. I've also seen it referenced as --max-old-space-size (dashes instead of underscore) but I'd be surprised if that was it.
It's so strange. I just saw the memory go well over that limit, so the option is working. And now, the build worked again. But at times, it just doesn't.
Thanks for your help. If I will ever find out what's going on I will let you know.
Are you using Windows with WSL? I saw something similar once with WSL, where it really looked like the linux kernel just decided to kill off all the Terser child processes or something and it just hung there, doing nothing.
Yes, I am currently on Windows 7, so there should be WSL there. And it matches what I saw:
When it worked, there was a child process that has been started and the main process had long stretches where it was idle.
When it didn't work, there was no child process, so it could very well be that it was killed. I will keep an eye on that.
angular-automatic-lock-bot commented on Sep 9, 2019
Activity
alexeagle commentedon Sep 4, 2018
From @changLiuUNSW on December 1, 2017 4:19
Thanks @filipesilva. I will have a test tonight and get back to you ASAP.
alexeagle commentedon Sep 4, 2018
From @changLiuUNSW on December 1, 2017 11:41
Only around 2 minutes difference now !Thanks for your hard work @filipesilva.
If we can make the difference within 1 minute , so much the better :)
Thanks again.
alexeagle commentedon Sep 4, 2018
From @filipesilva on December 1, 2017 11:49
All credit goes to @clydin, he's the one working on reducing Build Optimizer run time and memory usage.
alexeagle commentedon Sep 4, 2018
From @caroline-church on December 14, 2017 16:17
Hi i am also having this issue but am not using angular-cli, any recomendations what i can do to make my build work with build-optimizer turned on. In my case it gets to around 50% then hangs forever
alexeagle commentedon Sep 4, 2018
From @filipesilva on December 18, 2017 8:37
@caroline-church is your project open source or available for me to see somewhere?
alexeagle commentedon Sep 4, 2018
From @caroline-church on December 18, 2017 9:16
@filipesilva here is my branch https://github.com/caroline-church/fabric-composer/tree/improve-performance-2. Its a mono-repo so you have to run npm install in the top level directory. The package you want to look at is composer-playground. If you run
npm run buikd:prodyou will see the problem. I narrowed it down to that the problem was the composer-common dependency, but wasn't sure why it would cause a problem.alexeagle commentedon Sep 4, 2018
From @pjmolina on December 22, 2017 16:57
Hi everyone!
I have a case when building for production an ng app:
This hangs forever (it is not a memory problem, uses around 400Mb) but keeps consuming CPU and do not finish.
ng build -e prod -prod -aot --base-href xThis other one, disabling the build optimizer, works:
ng build -e prod -prod -aot --base-href x --build-optimizer=falseOne particularity on the ng project is that it contains one big/medium file (a generated parser) of 108 Kb in size and this looks to be the hanging point.
Versions used:
The project is not open source, cannot share it as is. But I can prepare a private repro sample if requested.
alexeagle commentedon Sep 4, 2018
From @filipesilva on December 22, 2017 17:9
@pjmolina that's pretty interesting, the big file. Is the file itself something you can share?
alexeagle commentedon Sep 4, 2018
From @pjmolina on December 22, 2017 17:11
@filipesilva Yes, in a private way (not for public disclosure).
I can sent it to you by e-mail.
17 remaining items
filipesilva commentedon Feb 14, 2019
Can you show me your
ng versionoutput? I'd also be curious to know what the difference in bundle size is with and without Build Optimizer.Although at this point if I had to bet on the root cause, it might be memory. If your builds are already close to the memory limit, anything that moves them closer will disproportionately increase build time due to GC churn. #5618 (comment) contains instructions on how to increase this limit.
dhilgarth commentedon Feb 14, 2019
ng versionon my developer machine:Build Agent, I currently have no way of getting that info, but it should be very similar as I am not aware that we installed angular-cli globally.
Thanks for the hint with memory. It might very well be the cause as our build agents are notoriously low on memory.
Regarding the difference in size:
Without optimizer:
With optimizer:
So a bit over 300kb
dhilgarth commentedon Feb 14, 2019
BTW, we already encountered issues with the node memory limit, so we are using this command to run our build:
npm run ng-high-memory -- build --base-href=/XYZ/ --configuration=productionwith
ng-high-memorybeing defined as:"ng-high-memory": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng"(So we actually already applied the hints from the linked issue)
filipesilva commentedon Feb 14, 2019
I'd also update
@angular-devkit/build-angularto the latest version btw. That's the actual build system. Memory is limited by NodeJS itself btw, so even on a machine with a lot of memory you won't be using it by default unless you use those scripts.Also your total bundle might get quite smaller if you don't have the vendor bundle in production. Maybe try it if you're curious.
At the end of the day you do have over 8mb of code post optimizations... that's a lot of code. And it looks like the benefits from Build Optimizer might be marginal at for your code base. It is a reasonable option to turn it off if it's not worth the extra build time.
dhilgarth commentedon Feb 14, 2019
Thanks for the hints. We actually did experiment without the vendor chunk and the differences in size were marginal, even more marginal than the difference with the build optimizer.
Regarding the overall size: You are correct, it's a lot. We are currently in the process of optimizing our dependencies, which hopefully shaves off some megabytes
dhilgarth commentedon Feb 14, 2019
Now I do have such a hanging build again, after I updated
@angular-devkit/build-angular. And the strange thing is that the node process uses about 1.4GB but no CPU at all. It just sits there, and idles. What could cause such behaviour? Is there some verbose logging that I could enable to troubleshoot this?filipesilva commentedon Feb 14, 2019
1.4gb is just at the memory limit. I'd say that's the reason.
dhilgarth commentedon Feb 14, 2019
OK, but we are using
ng-high-memory. Shouldn't this solve those kinds of problems?filipesilva commentedon Feb 14, 2019
It should indeed. I'm not sure what's happening in your project :/
I know some older versions of node had memory issues as well, so maybe node 10 helps but... being stuck at 1.4 makes it really look like the node memory flag isn't being applied. I've also seen it referenced as
--max-old-space-size(dashes instead of underscore) but I'd be surprised if that was it.dhilgarth commentedon Feb 14, 2019
It's so strange. I just saw the memory go well over that limit, so the option is working. And now, the build worked again. But at times, it just doesn't.
Thanks for your help. If I will ever find out what's going on I will let you know.
filipesilva commentedon Feb 14, 2019
Are you using Windows with WSL? I saw something similar once with WSL, where it really looked like the linux kernel just decided to kill off all the Terser child processes or something and it just hung there, doing nothing.
dhilgarth commentedon Feb 14, 2019
Yes, I am currently on Windows 7, so there should be WSL there. And it matches what I saw:
When it worked, there was a child process that has been started and the main process had long stretches where it was idle.
When it didn't work, there was no child process, so it could very well be that it was killed. I will keep an eye on that.
angular-automatic-lock-bot commentedon Sep 9, 2019
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.