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
NgccProcessor slowing down subsequent builds with AngularCompilerPlugin #15078
Comments
@crisbeto, which version of @angular/compiler-cli are you using? @petebacondarwin was your PR for improving NGCC performance merged and released? |
I'm using |
@crisbeto - thanks for the report. I did a big performance refactoring of ngcc in angular/angular#30525 but I believe that only landed in 8.2.0-next.1. This fixed a problem where ngcc was parsing the entire node_modules tree every time it was being run from the I see that angular/angular#31509 has not appeared in any release yet. But it should be released with 8.2.0-next.2. Can you take another look at the performance once that is released. If it is still a problem then we can prioritize work on it. |
@crisbeto, would you be able to use the compiler-cli build snapshots and give it a shot and see if the timings improve? Also, I suggest that you also update the PS: Thanks @petebacondarwin for your input. |
@alan-agius4 @petebacondarwin Looks like updating to
These numbers are from my local machine since I can't test it on our CI until @petebacondarwin do you know whether your refactor would help with some CI flakiness that was being caused by
What I think was going on is that when I was running 10 builds in parallel 10 different instances of |
Thanks for the update @crisbeto - hopefully that means that we are not in a dire situation regarding performance :-) Regarding the flakes, I am not surprised that this is happening. ngcc was never designed to be run multiple times in parallel, which is basically what is happening when running multiple builds on the same project at the same time, since the CLI+ngcc integration will trigger ngcc whenever it comes across a new import. I could imagine that at some point build A is writing to a So the natural solution, which you already mentioned, is to do a full ngcc compilation of the whole of the (By the way, this could become even more common if using Bazel to build projects since that naturally will try to parallelize compilations...) |
FYI, we've run into the same issue with the docs examples (which essentially share the same |
Actually I think that we don't need the flag... if the node_modules have already been compiled by ngcc then the CLI+ngcc should not need to write any files, so there should be no flakes........ |
Yeah, exactly, that's how we solved it in angular/angular#30593 for angular.io docs examples 😉 |
@crisbeto, seeing all the comments above. I don’t think there is anything to action. Feel free to ping me on slack if you feel otherwise. |
@petebacondarwin @alan-agius4 I'm still seeing the flaky behavior where |
@crisbeto, are you explicitly running |
I'm running it once up-front like this after I const ngcc = require('@angular/compiler-cli/ngcc');
ngcc.process({
basePath: path.join(projectRoot, 'node_modules'),
compileAllFormats: false,
propertiesToConsider: ['browser', 'module', 'main'],
createNewEntryPointFormats: true
}); Afterwards it gets run implicitly by the |
Could it be that those properties do not correspond to the es2015 format (which the cli wants to compile)? |
That call goes through fine. What I'm running into is that when I'm running 10 different Webpack builds in parallel, once every 10 or 15 times it flakes with |
I am not implying the call doesn't go through fine 😄 Here is what I mean: The Based on the above, the trick to avoid the error is to ensure that ngcc will not need to update any So, you need to ensure that ngcc will have processed all formats that the cli will request afterwards. |
That makes sense, although from looking at the logs it doesn't seem like it's doing any more compilation, because I'm not seeing any more of those |
It is worth taking a look at the package.json after the original ngcc run and then after the CLI compilation? We should note that multiple properties in So although you have built the |
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. |
I'm using the
AngularCompilerPlugin
for a medium-sized project and I've observed a slowdown in build times after enabling Ivy which appears to come fromngcc
. When Ivy is enabled theAngularCompilerPlugin
runs theNgccProcessor
which is supposed to compile thenode_modules
for Ivy on the first run, however in my case any subsequent builds are slowed down as well.I have a hacky way to disable the
NgccProcessor
which I've used to measure the differences in build times. Here's what it looks like:Here are the timings for 5 production builds on my own machine. Note that these times are after
ngcc
has been run once over thenode_modules
in apostinstall
script.The 15s slower build time for a production build isn't a big deal locally, however the difference becomes even larger when running it on our CI server. For our production builds we need to run about 30 Webpack builds (10 at a time in parallel), about 20 which go through the
AngularCompilerPlugin
. Disabling theNgccProcessor
on our CI server reduced our build time from around 10 minutes to about 6 minutes. Furthermore keeping theNgccProcessor
led to some flakiness in our builds, presumably because 10 differentngcc
processes were trying to access file at the same time. Our build script looks something like this:npm ci
.ngcc
programmatically as follows:webpack --mode=production
30 times by splitting them into chunks of 10 that are run concurrently. We have some logic that tries to make sure that we always run the maximum number of builds, but it stays the same no matter whetherngcc
is enabled so it shouldn't have an effect on the times.I can see a couple of ways to get around this:
AngularCompilerPlugin
config that allows users that know what they're doing to disable theNgccProcessor
.ngcc
orNgccProcessor
so that it doesn't have to spend time analyzing thenode_modules
after it has been run already.cc @filipesilva
The text was updated successfully, but these errors were encountered: