-
Notifications
You must be signed in to change notification settings - Fork 12k
Rebuild is way slower and stop working after several rebuilds #20235
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
Some screenshots from profilling + profiling profile: |
Hi @montella1507, thanks for the report. We have landed a large change in 11.2.5 with respect to incremental rebuilds, however the outcome should be that it's now faster than before, not slower. It could be that you're hitting a case where the compiler is unable to prove that work can be reused, in which case it may request more code to be regenerated than before. I'll have a look at the profile dump, thanks for sharing 👍 |
Thank you very much. I am here to help if possible. |
Ah, gotcha. You're using JIT compilation and the new Ivy Webpack integration that shipped in 11.1 is incorrectly using the AOT compiler's judgement on which files need to be emitted. But since AOT output is never requested, the AOT compiler will continue to indicate that everything needs to be emitted. If you can enable AOT, then I suggest you do! Otherwise, I'd suggest to disable the new Ivy Webpack plugin in the CLI for now by setting environment variable I'll transfer this to the CLI repo for now. |
Cool :-) I will try with AOT and will come back with report :-) |
vscode-profile-2021-03-10-21-36-15-deep-component-change.zip Rebuild propably will not stop working, however rebuild times still super slow :-( |
Ok, thanks for the additional profile. I do indeed see a lot more emit activity than I'd expect, but I can't tell why that would be the case. Another observation is that the cyclic import check takes 17s, so you may want to disable that in devbuilds (there's a setting in |
@montella1507 Could you also try with |
@JoostK i can confirm JIT mode stop working after few rebuilds. AOT keep working. "showCircularDependencies": false, changes nothing i think (not sure if it is not just disabling warnings to console) , however. When i monkeypatch isCyklic method to return directly FALSE. Rebuild times are little bit better (IVY all, AOT all, cyclic off): I will try to explain our portal to provide you more information what may be the cause. It is big CRM where you need cross references between 2 modules, for example: OrderDetailComponent from OrderModule (lazy loaded) We need to show OrderDetail in CustomerDetail and vice-versa CustomerDetail in OrderDetail component. // Customer-detail.html and vice-versa This is NOT possible when components are not declared in same module and you cannot Import module B in module A and vice versa. And -> we want to have both modules lazy loaded. So we usually use our custom DynamicComponent (lazy load module, compile, use component factory and attack to viewcontainerref). So there are dependencies between modules: I can imagine this may be big problem for modules buildign dependency tree because it is "lazy" cyklic dependency. |
Thanks for the additional information. I suspect that it's just Webpack's dependency graph that makes it believe that everything needs to be reemitted, which is introducing a huge bottleneck as emit is the slowest of all phases. The improvements to 11.2.5 are only concerning Angular's involvement in the process, which used to be suboptimal, but given that your JIT recompiles were also slow means that this is not the relevant here (my initial comment about JIT mode being affected by the AOT compiler turned out to be inaccurate). So that leaves a new problem to be investigated with respect to the dependency graph that Webpack is using to drive recompiles. |
mode: JIT rebuild stiill like 5-6 times slower than in previous NG version (but it works atleast even after 10th change/rebuild). However i am not able to profile (profiller / debugging and entire build will crash) |
vscode-profile-2021-03-10-23-09-20.zip Ah finaly: So most time takes source map generation i think. |
Thanks. Yeah profiling a long session will take down the Chrome Inspector at some point, it's not uncommon for me to see Chrome take 10GB of memory to show a profiling session. The last profile you shared does appear to still use the new Ivy pipeline, not the legacy one. Not sure why that would be the case, your In the meantime we have an idea of what is happening; it's indeed on the CLI side where we can do some experiments to see if things can be improved. I'm calling it a day now 👋 |
@JoostK hi, btw i have made additional benchmarks on 11.0.9 to measure circular-dependency-plugin + sourcmap plugin effects on build time.. here are the results: When circular-dependency detection is enabled, build and rebuild takes 5-8x more time. I think it has serious issues with async circular dependencies or something... And yes, "showCircularDependencies": false is enough. Will do the same benchmarks on current version of angular / compiler later (when this issue is closed or requested by anyone explicitely) |
@montella1507 We think to have found the culprit, it was fixed on master in #20236 and will be ported to patch so should be part of next week's release. I'll share a snapshot build for patch once that's available. |
Thank you very much. :-) I have realized rebuild is affected by assets too - created this issue - maybe it is duplicit to this one - feel free to close please if neccessary. |
Snapshot build is here: https://github.com/angular/ngtools-webpack-builds/tree/11.2.x (see top of readme) |
That snapshot build includes fixes for the repeat JIT build crash issue (fix via #20237) and the rebuild performance (fix via #20247). If you have the opportunity, please give the snapshot build a try and let us know if you are still encountering issues. Also, the asset issue is due to a third-party dependency used by the Angular CLI so a separate issue is appropriate. Some more details regarding the asset performance in serve can be found in a comment in that issue. |
Fortunately, i have jus got enabled 4H of Zack Snyder's Justice League CUT so i have enough time to profile on second display :-) TS. is 4.1.5 Profiles will provide soon. |
nosm-nocirc-aot-multiple-components.zip EDIT: those are JIT profiles. |
Thanks, those are all JIT though. A single variant would do, they should be similar enough. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I have uploaded AOT.zip with aot profiles, let me know if i can help you with anything else. If you think it is already solved - and you okay with results, i can close the issue (from my POV) |
This comment has been minimized.
This comment has been minimized.
@montella1507 Thanks for the profile. It's mostly what I was expecting from the earlier profiles and the changes that have been made since. If you feel like it, can you run another experiment for me? Based on your profiling output I have been experimenting with cycle analysis (not the expensive step that you can disable, but an internal Angular compiler analysis step needed for proper output) and I'd like to know what the impact of that would be. The build artifacts are here. In particular, you'll need Using those build artifacts you should get slightly better AOT times (I estimate ~400ms less). Next, I'm interested in a more extensive optimization of which I have no idea how effective it is. This is hidden behind the Instructions for installing the build artifacts can be found here. Unrelated to the above, the CLI is ramping up for the adoption of Webpack 5 in v12. Your project is a gem in terms of the insights it provides, so if you could have a go at Webpack 5 with the CLI's latest |
Will do at weekend. |
Oh and one more thing that we noticed in the profile that deserves further research: in AOT mode the Angular compiler does template type-checking by feeding the Angular templates into TypeScript. This is done by injecting additional source files into a temporary TypeScript program. Creating that temporary program should be efficient as it's mostly identical to the original. In your profile however, we're seeing a codepath that indicates that TypeScript has determined that it can't reuse everything from the original program, which incurs an extra cost (circa 500ms as taken from your profiles.). So to verify: are the edits you're making entirely redundant, such as whitespace only changes? They probably are, in which case we'd need to do some experimenting to figure out if we can avoid that extra cost (we have tests that tell us this should work, but perhaps it's missing a case). |
Hi everyone! Thank you all for sorting these issues out, our team is currently switching from 9 => 11 and are holding off for these performance improvements at present. Do we know roughly what compile times are, comparable to Angular 9/10, rather than just earlier Angular 11 versions? I'll be doing some experimentations next week profiling our codebase with the lastest angular version. |
i do everytime the same - editing string / number value. eg. return "george"; >> return "georgedcjwekwejkfk"; etc. :-) I can do bigger changes, if you wish. But NO, not at all, my changes are NOT redundant. |
as far as i know... Angular rebuild times went worse and worse from 8 -> 11 in all projects i participate to... HOWEVER... latest version is deal breaker + we have realised how BAD is circular detection in our bigger projects (rebuild times dropped by 80% by disabling that check) |
@JoostK BTW i am not changing HTML templates (split from TS file) so maybe you are right, my changes are redundant from POV of template compiling... Do you wish CPU profiles, when i change template (html) files? Let me know. |
Nope, the current profiles are sufficient. My question was to ensure that you're indeed only making trivial changes. TypeScript has some logic in |
Look, we have 2 options...
I have no problem to spend several hours to it :-)) |
Let's keep it offline :-) I am on Angular's Discord as |
Discussed on discord. Will let this issue open, @JoostK close when you think all is solved :D |
Hi I have a similar issue our build went from in angular 11.0.3 ng serve started in around 1 min is a big project after migrating to 11.2.9 the ng serves takes 3mins to start, I started downgrading libs to understand what libs was causing the issue, in the end the problem seems to be related to @angular-devkit/build-angular, I manage to run the project with everything updated to 11.2.9 except to that library which I set to version 0.1100.7 and runs again in 1 min, if I change to any version after that one the time is 3mins again. I college tried with 12 and said that was faster but still slower than before. |
TBH i think i should have closed this issue, because it was resolved. |
@montella1507 sorry I think is fine to close it, nx just released a new release , and it seems to be working fine with it , build is back again in 1 min using latest angular-build, I think they have a custom builder that wraps yours and not sure exactly what went wrong there, in their change log looks like they fixed a bug were ngcc was been called on incremental builds, I though it was related to this because like I said the issue seem to be related to angular-build in my test. Anyway sorry to bother you, I spend so many hours investigating this , thanks anyway. |
In the meantime we have also addressed another slow path that became clear from @montella1507's profile, albeit only for v12. Closing this issue as not further actionable. |
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. |
Affected Package
Propably compiler 11.2.5
We have migrated from:
TO
Is this a regression?
YES
Description
We have migrated from angular 11.0.9 to 11.2.5. Our application is pretty big 1300components, 170 NgModules, 70 lazy loaded chunks.
After migrations almost all rebuild times took 6-10x more time and what is worse..
I am willling to help with debug (profile node process / generate and send any log, however it may be imposible to prepare minimal repro :-/ )
The text was updated successfully, but these errors were encountered: