Skip computing digests when --use_action_cache=false.
Does this by delegating responsibility for constructing ActionCache.Entry
instances to the ActionCache, and having the StubActionCache return null.
Tests show a 1-2% elapsed-time reduction for clean builds: []
Doesn't use interface default methods, because we still need JDK7 for Mac.
--
PiperOrigin-RevId: 147722062
MOS_MIGRATED_REVID=147722062
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java b/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java
index 4f2a33c..7170836 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/ActionCacheChecker.java
@@ -267,7 +267,11 @@
}
Map<String, String> usedClientEnv = computeUsedClientEnv(action, clientEnv);
ActionCache.Entry entry =
- new ActionCache.Entry(action.getKey(), usedClientEnv, action.discoversInputs());
+ actionCache.newEntry(action.getKey(), usedClientEnv, action.discoversInputs());
+ if (entry == null) {
+ // Action cache is disabled, don't generate digests.
+ return;
+ }
for (Artifact output : action.getOutputs()) {
// Remove old records from the cache if they used different key.
String execPath = output.getExecPathString();
@@ -386,12 +390,19 @@
// Compute the aggregated middleman digest.
// Since we never validate action key for middlemen, we should not store
// it in the cache entry and just use empty string instead.
- entry = new ActionCache.Entry("", ImmutableMap.<String, String>of(), false);
- for (Artifact input : action.getInputs()) {
- entry.addFile(input.getExecPath(), metadataHandler.getMetadataMaybe(input));
+ entry = actionCache.newEntry("", ImmutableMap.<String, String>of(), false);
+ if (entry != null) {
+ for (Artifact input : action.getInputs()) {
+ entry.addFile(input.getExecPath(), metadataHandler.getMetadataMaybe(input));
+ }
}
}
+ // Action cache is disabled, skip the digest.
+ if (entry == null) {
+ return;
+ }
+
metadataHandler.setDigestForVirtualArtifact(middleman, entry.getFileDigest());
if (changed) {
actionCache.put(cacheKey, entry);