diff options
author | 2017-10-10 08:31:32 +0200 | |
---|---|---|
committer | 2017-10-10 11:24:46 +0200 | |
commit | d8a5753a8ce1d9cb6604c325836683f3325e42eb (patch) | |
tree | fa0823c7a89cfbf0850feecf6aa91efab0ff6575 /src/main/java/com/google/devtools/build/lib/skyframe | |
parent | ceb1013c1ca0238188e2714442fcfb2efb16bc6a (diff) |
In PerActionFileCache, tolerate requests for Artifacts that are not in the cache if we're doing input discovery: input discovery may find new artifacts we don't yet know about. Similarly, in SingleBuildFileCache, use the Artifact's path if it's available, rather than the poor man's route of the execRoot.
PiperOrigin-RevId: 171635892
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skyframe')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java | 10 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skyframe/PerActionFileCache.java | 11 |
2 files changed, 16 insertions, 5 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 a92e809800..46238c4e8b 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 @@ -388,7 +388,9 @@ public class ActionExecutionFunction implements SkyFunction, CompletionReceiver metadataHandler.discardOutputMetadata(); // This may be recreated if we discover inputs. - PerActionFileCache perActionFileCache = new PerActionFileCache(state.inputArtifactData); + PerActionFileCache perActionFileCache = + new PerActionFileCache( + state.inputArtifactData, /*missingArtifactsAllowed=*/ action.discoversInputs()); if (action.discoversInputs()) { if (state.discoveredInputs == null) { try { @@ -406,7 +408,8 @@ public class ActionExecutionFunction implements SkyFunction, CompletionReceiver if (env.valuesMissing()) { return null; } - perActionFileCache = new PerActionFileCache(state.inputArtifactData); + perActionFileCache = + new PerActionFileCache(state.inputArtifactData, /*missingArtifactsAllowed=*/ false); // Stage 1 finished, let's do stage 2. The stage 1 of input discovery will have added some // files with addDiscoveredInputs() and then have waited for those files to be available @@ -422,7 +425,8 @@ public class ActionExecutionFunction implements SkyFunction, CompletionReceiver if (env.valuesMissing()) { return null; } - perActionFileCache = new PerActionFileCache(state.inputArtifactData); + perActionFileCache = + new PerActionFileCache(state.inputArtifactData, /*missingArtifactsAllowed=*/ false); } metadataHandler = new ActionMetadataHandler(state.inputArtifactData, action.getOutputs(), tsgm.get()); diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/PerActionFileCache.java b/src/main/java/com/google/devtools/build/lib/skyframe/PerActionFileCache.java index 619e0b302b..1511c4c385 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/PerActionFileCache.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/PerActionFileCache.java @@ -35,14 +35,19 @@ import javax.annotation.Nullable; */ class PerActionFileCache implements ActionInputFileCache { private final Map<Artifact, FileArtifactValue> inputArtifactData; + private final boolean missingArtifactsAllowed; // null until first call to getInputFromDigest() private volatile HashMap<ByteString, Artifact> reverseMap; /** * @param inputArtifactData Map from artifact to metadata, used to return metadata upon request. + * @param missingArtifactsAllowed whether to tolerate missing artifacts: can happen during input + * discovery. */ - PerActionFileCache(Map<Artifact, FileArtifactValue> inputArtifactData) { + PerActionFileCache( + Map<Artifact, FileArtifactValue> inputArtifactData, boolean missingArtifactsAllowed) { this.inputArtifactData = Preconditions.checkNotNull(inputArtifactData); + this.missingArtifactsAllowed = missingArtifactsAllowed; } @Nullable @@ -51,7 +56,9 @@ class PerActionFileCache implements ActionInputFileCache { if (!(input instanceof Artifact)) { return null; } - return Preconditions.checkNotNull(inputArtifactData.get(input), input); + Metadata result = inputArtifactData.get(input); + Preconditions.checkState(missingArtifactsAllowed || result != null, "null for %s", input); + return result; } @Override |