-
Notifications
You must be signed in to change notification settings - Fork 12k
[RFC] Persistent build cache by default #21545
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
Notes:
I feel like this would reduce usage of the technology you're introducing. Wouldn't it be better to provide good documentation on this point? Would you propose defaulting to using persistent build caches in CI if only, you could assume the build pipelines would make good use of your technology? In my (admittedly little) experience, when Angular team provides good documentation, the community follows. The community will either be using this directly, or requesting from other teams (e.g. a "devops team"). In both cases, they can be guided by documentation. Practically, I think it's worth considering:
If this works, you would have placed a default successfully that is a net positive for cloud costs (= reduced time + no negative impact), instead of (i) too easily letting people opt out of a potentially cost reducing technology or (ii) people potentially incorrectly using the build settings and not opting out, and neither using the tecnology, therefore experience cost increases. |
I love to see this turned on by default.
By adding those as commands to the CLI it becomes much easier to control for people not versed in DevOps. |
I vote for making it turned on by default but with the setting in angular.json to turn it off (similar to “buildOptimization: true”). This way, “production” and “ci” configurations could turn it off if needed, while dev builds will run significantly faster (and it's where it matters the most). |
I love this idea and definitely echo what @e-oz and @SanderElias mentioned. Having support for tools and configuration would be the only hurdle I see in enabling it by default. Also have clear documentation on how it works and how to configure it. |
@alan-agius4 Is a faster build work with Github Actions when I use |
It depends how your Github action is configured and which paths are being cached and restored between each run. |
I'm currently using effectively |
If you turn this on by default, please add a config option in angular.json (build-angular schema) instead of a CLI parameter, it's much easier to use, especially when we call the CLI api programmatically, and it's easier to know that this option exists with the schema autocomplete. |
not sure if changing the default behaviour is a good option, someone using the default config can get in trouble without knowing, i'd like more to have an hint when using the "ng serve/test/build" command |
We've been using
This normally seems to be triggered by massive refactors of lots of files being moved around at once (in that example above the file it cannot find was moved to another directory). If you know to just clear the cache to fix it, then it's a simple solution, but if it's on by default it may cause some confusion to users and end up with a lot of issues reported to the CLI team. Maybe logging a hint or something at the end to try clearing the cache first could help with that. Another minor issue we ran into was when npm hoisting issues cause the main webpack version in node_modules not to match the webpack version used by the angular CLI (for example by having @storybook/angular installed). When this happens you get lots cryptic of warnings from webpack like this:
This could be solved with a simple check comparing the webpack version in p.s. all these perf changes to the CLI have made an enormous difference to our CI times and productivity. When we first upgraded to 11.0 our build times were around ~20 minutes, and now with the latest 12.2 we're close to ~5 minutes. So thank you so much for making this a priority, it really does make a huge difference 😄 |
This RFC is now closed, thank you all for participating. We'll review all the comments in the coming days, Overall though it seems that the community saw good improvements when turning persistent build cache including on CI environments. |
Author: Alan Agius (@alan-agius4)
Status: Open
Closing Date: 2021-08-24
Summary
In Angular CLI version 12.1, we introduced an experimental opt-in feature to persist build information to disk. This under the hood uses Webpack’s persistent cache feature.
Users can opt-in to the experimental build persistent cache using the
NG_PERSISTENT_BUILD_CACHE=1
environment variable.When opting to use this feature, information of the current build is persisted on disk, and reused in the subsequent reinitialization of the build pipeline via
ng build
,ng serve
and otherng
commands. The improvement in cold build times we've seen in the real applications is up to 68%. This does come at the cost of an increase in memory usage.Proposal
We are proposing that in version 13, we enable persistent build cache by default, whilst still providing an option to opt-out. We also intend to introduce a new command
ng cache
which would facilitate enabling, disabling and purging the cache.The persistent build cache typically speeds up local development workflows, because these workflows often depend on performing full, non-incremental builds.
However we found the impact negatively in CI environments because of the increase in memory usage and the cache which is located in
node_modules/.cache/angular
is typically not stored after each build and restored before each one. For this reason we propose that persistent build cache is disabled when the build is running in a CI environment. We can determine this by checking for the presence of the CI environment variable.Community feedback
We’d like the community to weigh in and provide feedback on a number of points.
How
NG_PERSISTENT_BUILD_CACHE
affects the development when building, serving and testing an application.If any, what is the observed memory increase.
Non Windows users can run the below to gather this data:
node_modues/.cache
is currently used as cache location.The text was updated successfully, but these errors were encountered: