No-remote dependency chain

84 views
Skip to first unread message

perra N

unread,
Aug 30, 2023, 9:33:43 AM8/30/23
to bazel-discuss
Hi!

I've got a scenarios regarding dependency chains that has target with tags = no-remote and have trouble figuring those scenarios out.

scenario:
say that you have a target A built remotely, which then depend on target B, which is built locally (due to the tags = no-remote), which in turn depend on target C that is built remotely and cached. e.g

target A <-- target B (no-remote) <-- target C.

Im confused, since bazel does not complain that target B does not exists or at least the objects produced does not exists. I've look at the trace log of some builds. I seems like Targets A and C are downloading results from the cache although i cant see that Target B is uploading all the time. Im a bit uncertain how it works.

outcome:
1. Will this force all targets to be built locally?
2. Will target B force target C to be built locally?
3. Will the "state of chained targets" be lost since 2 is remote and 1 is local?
  •   Like Target A and Target C is built on machine X and Target B is on machine Y, how does bazel string the dependencies together?
3. Lets say the target B is cached from another run where "no-remote" is disabled. Will target B be built and upload but target A will only use the cached version first?



Thanks in advanced.
//Per






Tiago Quelhas

unread,
Aug 31, 2023, 4:59:46 PM8/31/23
to perra N, bazel-discuss
To answer your questions directly: the local action in the middle will *not* prevent actions either before or after it from running remotely. However, the inputs (outputs) of the local action have to be downloaded from (uploaded to) the remote cache, which can slow things down compared to the fully remote scenario.

In addition, the cache is content-addressed, so files already present in the cache don't have to be re-uploaded, and files already present locally don't have to be re-downloaded if the command line and inputs of the action that produced them didn't change. So toggling an action between remote and no-remote (without modifying the source files, nor deleting the output tree) doesn't re-upload nor re-download any files.

https://bazel.build/remote/caching#overview has some more detail on how it all works.


--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/f56922f2-d8fc-42f2-98c7-7c1479cb5240n%40googlegroups.com.

perra N

unread,
Sep 1, 2023, 2:17:21 AM9/1/23
to bazel-discuss
Cool, thanks for the response :)

I though of in the link you gave  it says:
"""
When you run a Bazel build that can read and write to the remote cache, the build follows these steps:
  1. Bazel creates the graph of targets that need to be built, and then creates a list of required actions. Each of these actions has declared inputs and output filenames.
  2. Bazel checks your local machine for existing build outputs and reuses any that it finds.
  3. Bazel checks the cache for existing build outputs. If the output is found, Bazel retrieves the output. This is a cache hit.
  4. For required actions where the outputs were not found, Bazel executes the actions locally and creates the required build outputs.
  5. New build outputs are uploaded to the remote cache.
"""
If the "middle" action were to exists in the remote cache. Then would it build it locally or would it be "caught" in step 4 (the remote cache), even though the the "no-remote" tag is set?

perra N

unread,
Sep 1, 2023, 3:12:49 AM9/1/23
to bazel-discuss

Also, when looking at the profile trace log for this scenario, it seems like the local build is not uploading/downloading anything and target A (top) is just downloading from the remote cache (not taking the local built into account)? is that possible?
Reply all
Reply to author
Forward
0 new messages