-
Notifications
You must be signed in to change notification settings - Fork 12k
Build Optimizer increasing build time excessively #12153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
From @changLiuUNSW on December 1, 2017 4:19 Thanks @filipesilva. I will have a test tonight and get back to you ASAP. |
From @changLiuUNSW on December 1, 2017 11:41
Only around 2 minutes difference now !Thanks for your hard work @filipesilva. |
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. |
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 |
From @filipesilva on December 18, 2017 8:37 @caroline-church is your project open source or available for me to see somewhere? |
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 |
From @pjmolina on December 22, 2017 16:57 Hi everyone! This hangs forever (it is not a memory problem, uses around 400Mb) but keeps consuming CPU and do not finish. This other one, disabling the build optimizer, works: 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. Versions used:
The project is not open source, cannot share it as is. But I can prepare a private repro sample if requested. |
From @filipesilva on December 22, 2017 17:9 @pjmolina that's pretty interesting, the big file. Is the file itself something you can share? |
From @pjmolina on December 22, 2017 17:11 @filipesilva Yes, in a private way (not for public disclosure). |
From @pjmolina on December 22, 2017 19:8 @filipesilva I just created a shared full repro sample. |
From @filipesilva on December 28, 2017 17:28 @pjmolina thanks a bunch for putting that repro up! I'll have a look to see if there's a specific build optimizer optimization that's causing problems. /cc @clydin |
From @filipesilva on December 28, 2017 18:0 I ran some tests disabling each individual optimization that Build Optimizer does and the culprit seems to be https://github.com/angular/devkit/blob/master/packages/angular_devkit/build_optimizer/src/transforms/prefix-classes.ts. We're probably doing something horribly inefficient there and it takes a long time on big files. |
From @pjmolina on December 28, 2017 18:14 Just in case, if the TypeScript compiler/lib is involved, as an hypothesis: Could it be related to this other bug: TypeScript #17033 I reported on the TS compiler? |
From @filipesilva on December 28, 2017 18:29 Unsure... but something odd is happening here. I tried using the node inspector to get a CPU profile, and... it crashes. I set a breakpoint right before Build Optimizer starts processing I might be related to that TS issue yes. Build Optimizer processes input files as JS files with So yeah, I think it boils down to microsoft/TypeScript#17033. |
From @filipesilva on December 28, 2017 20:15 I think #346 is a great improvement, but worry about the sourcemap limitation. It means there are situations where having sourcemaps in production might mean extremely lengthy build. But that's the case now anyways. |
Is there any course of action to fix this issue? |
@dhilgarth are you seeing some disproportionate build time increase? Overall Build Optimizer is expected to take make builds take longer, as it adds another step to the build pipeline. In the past we have found bugs caused a disproportionate increase in build time however. To the best of my knowledge all those are currently fixed. But there might be unknown ones. If you're in such a situation can you open a new issue with a reproduction please? This issue itself should be closed though, in the year since it was open we have fixed all outstanding Build Optimizer performance bugs. |
Thanks for the amazingly fast response. I am not sure if I can provide a repro as it is a rather big project. But, with the info that it should work, I will try to find the root cause and report it in a new issue. |
Can you show me your 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. |
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:
With optimizer:
So a bit over 300kb |
BTW, we already encountered issues with the node memory limit, so we are using this command to run our build: with (So we actually already applied the hints from the linked issue) |
I'd also update 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 |
1.4gb is just at the memory limit. I'd say that's the reason. |
OK, but we are using |
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 |
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. |
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: |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
From @filipesilva on November 30, 2017 14:47
In #5618 (comment), @changLiuUNSW reported a 3x increase in build time (from ~3 to ~9 minutes) when using
--build-optimizer
:Angular CLI 1.5.2 with Angular 5.0.1
angular/devkit#304 has possibly improved this, but needs to be verified.
@changLiuUNSW can you try with Angular CLI 1.5.5 and let us know what's the current build time please?
Likely related to angular/devkit#240.
Copied from original issue: angular/devkit#305
The text was updated successfully, but these errors were encountered: