diff options
author | Benjamin Peterson <bp@benjamin.pe> | 2018-05-28 08:37:15 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-28 08:39:17 -0700 |
commit | c868c47eaa14304fc223b93534c641c04d47d830 (patch) | |
tree | 356e0ddc647426520eb3eb13f1bb795e4602118b /src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java | |
parent | 0df597e5f920c605a0aae7e442b864bd5bf344d2 (diff) |
Treat runfiles middlemen as aggregating middlemen.
The goal is to, for an action execution, make only a single skyframe
edge to every required runfiles tree rather than an edge to every
runfiles artifact directly. We accomplish this by pulling the runfiles
artifacts' metadata for a particular runfiles tree through the
appropriate runfiles middlemen artifact in one batch. This CL fixes
https://github.com/bazelbuild/bazel/issues/3217.
This change makes runfiles middlemen more similar to aggregating
middlemen. We however continue to treat runfiles middlemen slightly
differently than true aggregating middlemen. Namely, we do not expand
runfiles middlemen into the final action inputs. The reasons for this
are:
1. It can make latent bugs like
https://github.com/bazelbuild/bazel/issues/4033 more severe.
2. The runfiles tree builder action's output MANIFEST contains
absolute paths, which interferes with remote execution if its metadata
is added to a cache hash.
3. In the sandbox, it causes the runfiles artifacts to be mounted at
their exec path locations in addition to within the runfiles
trees. This makes the sandbox less strict. (Perhaps tolerably?)
4. It saves a modicum of (transient) memory and time to not expand.
If the first two issues are fixed, it could be a nice simplification
to completely replace runfiles middlemen with aggregating middlemen.
Change-Id: I2d2148297f897af4c4c6dc055d87f8a6fad0061e
PiperOrigin-RevId: 198307109
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java index 5c7d633da8..f099d7635c 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java @@ -254,8 +254,7 @@ public class ActionExecutionFunction implements SkyFunction, CompletionReceiver */ @Nullable private AllInputs collectInputs(Action action, Environment env) throws InterruptedException { - Iterable<Artifact> allKnownInputs = Iterables.concat( - action.getInputs(), action.getRunfilesSupplier().getArtifacts()); + Iterable<Artifact> allKnownInputs = action.getInputs(); if (action.inputsDiscovered()) { return new AllInputs(allKnownInputs); } @@ -677,11 +676,15 @@ public class ActionExecutionFunction implements SkyFunction, CompletionReceiver // We have to cache the "digest" of the aggregating value itself, // because the action cache checker may want it. inputArtifactData.put(input, aggregatingValue.getSelfData()); - ImmutableList.Builder<Artifact> expansionBuilder = ImmutableList.builder(); - for (Pair<Artifact, FileArtifactValue> pair : aggregatingValue.getInputs()) { - expansionBuilder.add(pair.first); + // Runfiles artifacts are not expanded into the action's inputs but their metadata is + // available from the action file cache. + if (!(value instanceof RunfilesArtifactValue)) { + ImmutableList.Builder<Artifact> expansionBuilder = ImmutableList.builder(); + for (Pair<Artifact, FileArtifactValue> pair : aggregatingValue.getInputs()) { + expansionBuilder.add(pair.first); + } + expandedArtifacts.put(input, expansionBuilder.build()); } - expandedArtifacts.put(input, expansionBuilder.build()); } else if (value instanceof TreeArtifactValue) { TreeArtifactValue treeValue = (TreeArtifactValue) value; expandedArtifacts.put(input, ImmutableSet.<Artifact>copyOf(treeValue.getChildren())); @@ -706,7 +709,7 @@ public class ActionExecutionFunction implements SkyFunction, CompletionReceiver actionFailures++; // Prefer a catastrophic exception as the one we propagate. if (firstActionExecutionException == null - || !firstActionExecutionException.isCatastrophe() && e.isCatastrophe()) { + || (!firstActionExecutionException.isCatastrophe() && e.isCatastrophe())) { firstActionExecutionException = e; } rootCauses.addTransitive(e.getRootCauses()); |