-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Buildtime increased by 50% in v12 #20792
Comments
I am having little luck with loading the profiling events into @kemsky if you are able to run with a debugger and then record a profiling session, that would be very helpful. |
@JoostK, I was not able to load it either. I tried recording on node 14.17 but it crashes at the very beginning. Ok, will try to do it using a debugger. |
After some debugging of Chrome's tracing tool, it appears that the +600MB of tracing data exceeds the maximum string length π€£ v8/v8@ea56bf5. Importing the file itself just results in an empty string, whereas loading the zip crashes during decompression when all uncompressed bytes are converted into a single string. |
@JoostK, JSON contains a simple array, so you can cut it if necessary into two parts. |
With some Unfortunately I can't make a comparison with 11 as I don't have a trace for that run, but Webpack processing itself is now longer than the full build took before. The pruned trace |
I am not sure how to proceed here. We'd likely still need some runnable reproduction in order to establish what can be done to improve the situation here. If anyone can share a repro privately that would be super helpful. |
@JoostK - Mine is a fairly large monorepo, I'll get to work on a repo you can access that is a bit more focused. Give me a hour or two |
Thanks. Also take your time as it's almost 2 AM for me so I'm calling it a day! |
@JoostK, this is v11 profile: https://link.nithins.me/9NfVUS9T I'm not sure if these are comparable... Devtools are crashing also, I can only take a partial profile. |
@kemsky - You can either give v8 more memory globally or chrome itself. Globally ( imo the useful way ): NODE_OPTIONS=--max_old_space_size=8192 |
@JoostK - I threw a new v11 CLI app up, added material and a basic component so it imports some styles. It's super minimal but should work for a reproduction, if not i'll just get you collab access to my work repo to poke around. Main branch is cli v11.2.13 (~6000ms --prod) and upgrade-v12 is that branch upgraded. (~13200ms --prod). |
Not sure how to interpret those results. The angular-compiler block stays the same across v11 vs v12 which is to be expected, but what follows is so vastly different that I can't say what the real problem is. Terser is reported surprisingly differently in a way that in v12 it spans 60s vs just 10s in v11, but that may just be because the profiling events are generated differently. Additionally, the v11 trace spans almost 6 minutes vs 3.5 minutes in the v12 trace, so that's suspicious as well (especially because the angular-compiler trace has stayed consistent) |
Okay so I tried this and I'm actually getting similar times for v11 and v12, however in v11 the Terser processing is cached whereas in v12 it doesn't appear to be. This results in inconsistent results for v11, as cold runs are ~12s vs ~7s for cached runs; unlike v12 which always takes ~12s. |
I am currently experimenting with this and hoping to enable webpacksβ file system caching in the CLI in the near future. Webpack 4, code path Webpack 5, code path |
Is it possible to turn off caching in v11? |
Yeah, you can use the Ex: |
If I don't cache my v11 builds in my big monorepo, the build times are almost identical. tl&dr here is CLI v12 is using Webpack 5, terser-webpack-plugin isn't caching like it does in CLI v11 using Webpack v4 and it just sort of "is what it is" for the moment. |
Same here. For a pretty small project. (2 pages with a couple of components) Might be related to: nrwl/nx#5370 |
@JoostK, @alan-agius4, I removed all scss files and set v11.2.13
v12.0.0
After several runs +/- the same time. Styles processing is slightly slower on v12. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
For me it's even worse! Build time for our example repo (available for public, but stripped of most content) is up almost 500%. I replaced AngularCompilerPlugin with AngularWebpackPlugin when switching to v12. I have not yet succeeded to build our real project since I've given up after a few minutes. But based on the time above I will probably take about 8-10 minutes. Will try it out now. Edit: |
@JonWallsten Can you share that repo, as you mention it's public? |
@JoostK: Yeah, sorry, I forgot to make it public after I wrote that: Just open an issue in the repo if something doesn't work. I just updated it from Webpack v4 to v5, so I lot had changed in out real repo that it's based on. Profile:
|
Unfortunately, we do not see much improvement with
* initial watch always immediately triggers a recompile for whatever reason angular.json:
System info:
I could send the cpu profiles if needed, but I am not allowed to share them (or the repo) publicly. Just let me know where I should send them :) |
@mrucelum, you are using builders which are not supported by the Angular tooling team. This causes a migration that adjusts the options to provide equivalent behavior from prior to the update not to run. Ideally these 3rd party builders should provide their own migration. You need to adjust the options by hand to retain the existing behavior. For more information, see the breaking changes section within the release notes: https://github.com/angular/angular-cli/releases/tag/v12.0.0 |
@alan-agius4 Thanks for link! I checked the breaking changes and if I understand them correctly, with this addition to the
I have the old default values (we had Thanks again :) |
In the above table, you mentioned You can send the CPU profiles to alan.agius4[at]gmail.com. |
It seems to be indeed the
btw this is the custom webpack config:
Conclusion:
However... we need the custom webpack config as we do not want to have all the unnecessary moment locales in our bundle and also need to be able to specify 'fabric' as external for some legacy lib we are using. |
Success! I found steps to get good performance when using TLDR; before upgrading angular, remove all traces of Here is what worked for me, starting with an Angular 11 project:
I confirmed that the migrations in angular.json (that were getting skipped) make the difference (2x slower ng serve build time) Benchmarking gives similar results as with angular 11 and markedly better results when I use NG_PERSISTENT_BUILD_CACHE=1 Like @mrucelum our project uses @angular-builders/custom-webpack to specify several packages as externals (legacy code needs the package as well, so don't want to double load them) Is there any chance ng update could do migrations when custom-webpack is in use? Or the ability to specify external packages without using custom-webpack? Thanks everyone for the info that lead me to this solution! |
@mrucelum Thanks for all the stats. I'm actually using However... as I was writing this though I saw you managed to get them working..... But, could you confirm that running the migrations did not in fact disable AOT compilation in your angular.json file. Depending upon your exact version of the CLI it's possible to end up disabling it when running migrations (due to a change in what was considered the default). If you in fact did disable AOT then that would explain the much faster compilation. Again though I'm using the same builder and wasn't seeing any noticeable difference between them. (Also version 12.1.0 of the custom builder was just published today - not sure if there were changes or just a version bump) |
Thanks @alan-agius4 for the explanation and sorry you'll probably end up marking this "off topic", but maybe not since it is about I reviewed #20756 to confirm I understood and I wasn't taking a corner case that was unexpected. I use angular-cli/packages/angular_devkit/build_angular/src/utils/environment-options.ts Lines 70 to 81 in 736a5f8
NG_PERSISTENT_BUILD_CACHE in order to persist the webpack cache? I noticed this was said to be experimental, but any reason I might not want to turn it on in this context? It looks like the cache key is pretty comprehensive and I would think the serialized build options should probably be good π€
Edit: After thinking about it more I definitely have places I can enable |
This actually looks to really help a lot for my build time π , but I've found a few errors and I'm reporting them (and fixing the one I can fix simply) |
After upgrading from Angular 11 to Angular 12 the build time went up from ~1 second to 22 seconds π€― |
@whyboris It doesn't for me: Is there a particular change I should be making? |
@JoostK thank you for testing! I was so frustrated I quit for the day, but thanks to your message I had new hope π I ran
update: π€¦ turns out it still takes ~22 seconds when you just add |
@whyboris Thanks for getting back. Good to hear it's fast again, hopefully it stays that way. If you do run into it again please report back so we can have another look. |
@JoostK π€¦ sorry -- the reload was fast because I simply saved the file with no changes ... but when I add
It seems to hang on the |
@whyboris Oh, it's just a misconfiguration. In Angular 12 some builder defaults have changed in support of the new production builds by default for |
@JoostK thank you very much for the suggestion! |
@whyboris it seems like you set |
Just wanted to let you know that I did the migration again the way @DavidBowdoin suggested (remove custom builder before ng update). Not sure what the issue was, maybe it was actually fixed with the newest version of the custom webpack builder (as @simeyla suggested). My But anyway, I am happy that we can update now! |
Maybe this can solve this problem https://dev.to/brandontroberts/speeding-up-the-development-serve-after-upgrading-to-angular-v12-5db5 |
It appears that the root cause of the problem is misconfigurations and not an issue in the Angular CLI. If you are still experiencing slow production builds please open a new issue with a production. |
Removing |
This solved my issue! Thanks :) |
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. |
π Bug report
Command (mark with an
x
)Description
This is v11.2.13:
Verbose log (logging itself causes slowdown, unfortunately...):
angular11.txt
This is v12 with yarn.lock and node_modules removed and reinstalled:
Verbose log (logging itself causes slowdown, unfortunately...):
angular12.txt
We have a single small *.scss file (overriding some material colors) and it was updated by migration. The application has only one module. I tried removing scss and css from angular.json, but it is still slower than v11.
On average it is 50% slower.
Recorded profile using node 12:
https://link.nithins.me/s2Uca0Ti
The text was updated successfully, but these errors were encountered: