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

[Question]: Sharing remote cache between MacOS and Linux #687

Open
gregjacobs opened this issue Dec 7, 2022 · 7 comments
Open

[Question]: Sharing remote cache between MacOS and Linux #687

gregjacobs opened this issue Dec 7, 2022 · 7 comments
Labels
blocked Blocked by another issue question This issue is a question. Close the loop with documentation?

Comments

@gregjacobs
Copy link
Contributor

gregjacobs commented Dec 7, 2022

What is the current behavior?

Hey guys, I'm hoping you can help me with this. I'm using a remote cache that I was hoping to share outputs between Mac and Linux (CI).

However, currently building everything on my Mac still causes my CI machine (on Linux) to rebuild everything. I'm guessing this has something to do with the platform somehow? (even though JS outputs are platform-independent?)

Do you know of a way to make this work?

@gregjacobs gregjacobs added the enhancement New feature or request label Dec 7, 2022
@alexeagle
Copy link
Member

This isn't JS-specific, Bazel generally treats action inputs as opaque, checksummed files, and so if one action has a linux nodejs interpreter as an input, it will have a different cache key than the same action with a mac nodejs interpreter.

My understanding is that bazelbuild/bazel#15542 gets us closer, fixing the case where an output .js file is the same between linux and mac, so that subsequent actions that use that .js file could be cache hits between different platforms. However the nodejs interpreter would still make the cache keys different.

@fmeum is there an issue on Bazel that expresses the general "cross-platform cache hits" feature request?

@alexeagle alexeagle added the question This issue is a question. Close the loop with documentation? label Dec 7, 2022
@fmeum
Copy link
Contributor

fmeum commented Dec 7, 2022

#6526 is the most fitting one. @tjgq is also working on solving the "multiple interpreters/SDKs" issue.

@gregjacobs
Copy link
Contributor Author

Hey @alexeagle, @fmeum, thanks for the replies. I'll be following bazelbuild/bazel#6526 and hoping for this soon! This would be a huge win for our developers developing our monorepo on Mac but building/testing on Linux CIs. Being able to share the cache artifacts and test outputs back and forth should save a lot of time.

@alexeagle Feel free to close this issue if you like, unless you want to track this here.

Thanks again,
Greg

@gregmagolan gregmagolan added blocked Blocked by another issue and removed enhancement New feature or request labels Feb 4, 2023
@gregmagolan gregmagolan moved this to 📋 Backlog in Open Source Feb 4, 2023
@gregmagolan gregmagolan moved this from 📋 Backlog to 🛑 Blocked in Open Source Feb 15, 2023
@alexeagle
Copy link
Member

I discussed this with @tjgq and there's an approach which is easy for us to try, I think of it as a "multiplex toolchain". Interpreter for all platforms are inputs, which is a bit wasteful, then when execution begins you pick the one for the exec platform. That way the cache inputs appear the same on all platforms.

@gregjacobs
Copy link
Contributor Author

Well that's definitely an interesting idea!

I'm just realizing though: scripts could in theory do something different based on os.platform(), so maybe the per-platform requirement makes sense 😶 Although on the other hand, for web outputs, that wouldn't matter. This is a tough one.

@gregjacobs
Copy link
Contributor Author

After working with the rules for a while now, I'm having difficulty imagining a case where the outputs of a JS program would be different based on exec platform. Are you guys able to think of any?

If not, I think the above solution might be a worthy tradeoff. I'd rather have the shared cache and have a little longer download time for the Node binaries (which happens only once every so often). And in the event that someone ever comes up with a reason to not follow this anymore (i.e. they've found a case where Node outputs are different based on exec platform), could revert.

What do you guys think?

@alexeagle
Copy link
Member

This came up at BazelCon this year in a talk on performance: https://static.sched.com/hosted_files/bazelcon2024/d0/TB-137%20Sharmila%20BazelCon%202024%20-%20Performant%20Bazel%20Builds%20for%20Web%20Monorepos%20at%20Scale.pdf

I think it's time to implement this. Since it's breaking in theory when a program senses the os.platform, we should just have a flagged rollout. In rules_js 2.x it would be off by default with a TODO to flip default to true in rules_js 3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked by another issue question This issue is a question. Close the loop with documentation?
Projects
No open projects
Status: 🛑 Blocked
Development

No branches or pull requests

4 participants