Skip to content
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

Should allow_cache_upload be available on more rules? #478

Open
cormacrelf opened this issue Nov 5, 2023 · 4 comments
Open

Should allow_cache_upload be available on more rules? #478

cormacrelf opened this issue Nov 5, 2023 · 4 comments

Comments

@cormacrelf
Copy link
Contributor

cormacrelf commented Nov 5, 2023

As far as I can tell, the allow_cache_upload flag is available only on 3 specific binary rules, and nowhere else. allow_cache_upload is also default False on every actions.run() call, so there are probably a hundred places in prelude that have yet to get it threaded through. If that was ever the goal.

Available:

  • python_binary
  • cxx_binary
  • rust_binary

Not available, for example:

  • cxx_library
  • rust_library
  • rust_test

There's obviously some rhyme to this, in that somebody committed those three | buck.allow_cache_upload_arg() attributes only on binary rules, but I can't find a rationale. I have a few guesses:

  • Cache uploads have just not been used much, given they do not work yet in OSS (pending Implement missing parts of OSS RE caching #477). Don't know what happens at Meta. Maybe it's RE all the way, and never keep a local build.
  • Maybe RE backends are always able to push and pull from the cache no matter what local buckd instances do, so nobody cares about local builds?
  • Conservatively enabling for only binary builds papers over any issues with uploading local action results that might not work on other machines. Binaries are more likely to be portable if you used a slightly different compiler or linked to a different shared library version. We just don't trust local execution or the exhaustiveness of hidden dependency inclusion (to cache-bust different configurations) enough to enable it.

I just quickly patched prelude to enable it on rust_library and supply it in the macro reindeer calls for all crates.io targets, and it seems to work great. You can launch another buckd on a separate isolation dir on a big crate graph that reindeer made, and it eats it for breakfast.

@cormacrelf
Copy link
Contributor Author

Ah, I think I see what's going on. allow_cache_upload is getting slowly rolled out to more rules as the responsible team becomes sure they've dealt with the issues. 211d555

@krallin
Copy link
Contributor

krallin commented Nov 5, 2023 via email

@cormacrelf
Copy link
Contributor Author

Outside of an RE-majority context, choosing to allow cache uploads seems to be more a function of the hermeticity of toolchains, rather than something you'd want to be forced to enable and disable on individual rules. I agree the default should probably be off on the system_*/demo toolchains that are probably not going to cache well. But other toolchains can default to true.

Then I could configure my rust toolchain to allow cache uploads, and the full crate graph would start flowing into the cache.

Rust_library et al would read the toolchain's value for allow_cache_upload. You can keep a flag on those individual rules as an override, treating it as an optional bool with the default value as None. Whatever works.

@ndmitchell
Copy link
Contributor

I wonder if the more pragmatic thing is to have allow_cache_upload default to None, where True means yes, False means no, and None means you consult some config. We'd leave it off at Meta, but if someone outside Meta wants to cause everything to upload I see no reason not to make that easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants