From fecdc4c32cc18abd786199f056829c6005d077d1 Mon Sep 17 00:00:00 2001 From: Ola Rozenfeld Date: Fri, 24 Mar 2017 17:20:19 +0000 Subject: Deja-vu: Using an ActionInputFileCache for SHA1 digests used with remote execution. If you're feeling like you've already seen this, that's correct, these were the exact contents of commit e860316559eac366d47923a8eb4b5489a661aa35... and then, on Nov 15, something unclear happened and the code disappeared! Perhaps it was the result of a faulty sync. In any case, nobody noticed, and the CL went in. It was later rolloed back and resubmitted, but the crucial code changes were gone. TESTED=local server with profiling for SHA1 specifically RELNOTES: n/a -- PiperOrigin-RevId: 151139685 MOS_MIGRATED_REVID=151139685 --- .../build/lib/remote/TreeNodeRepository.java | 41 ++++++++++------------ 1 file changed, 18 insertions(+), 23 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/remote/TreeNodeRepository.java') diff --git a/src/main/java/com/google/devtools/build/lib/remote/TreeNodeRepository.java b/src/main/java/com/google/devtools/build/lib/remote/TreeNodeRepository.java index 8f66301986..89c61c26e3 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/TreeNodeRepository.java +++ b/src/main/java/com/google/devtools/build/lib/remote/TreeNodeRepository.java @@ -23,6 +23,7 @@ import com.google.common.collect.Interner; import com.google.common.collect.Iterables; import com.google.common.collect.TreeTraverser; import com.google.devtools.build.lib.actions.ActionInput; +import com.google.devtools.build.lib.actions.ActionInputFileCache; import com.google.devtools.build.lib.concurrent.BlazeInterners; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.concurrent.ThreadSafety.ThreadSafe; @@ -31,6 +32,7 @@ import com.google.devtools.build.lib.remote.RemoteProtocol.FileNode; import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; +import com.google.protobuf.ByteString; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -177,14 +179,18 @@ public final class TreeNodeRepository extends TreeTraverser fileContentsDigestCache = new HashMap<>(); - private final Map digestFileContentsCache = new HashMap<>(); + private final ActionInputFileCache inputFileCache; private final Map treeNodeDigestCache = new HashMap<>(); private final Map digestTreeNodeCache = new HashMap<>(); private final Map fileNodeCache = new HashMap<>(); - public TreeNodeRepository(Path execRoot) { + public TreeNodeRepository(Path execRoot, ActionInputFileCache inputFileCache) { this.execRoot = execRoot; + this.inputFileCache = inputFileCache; + } + + public ActionInputFileCache getInputFileCache() { + return inputFileCache; } @Override @@ -272,29 +278,16 @@ public final class TreeNodeRepository extends TreeTraverser getAllDigests(TreeNode root) { + public ImmutableCollection getAllDigests(TreeNode root) throws IOException { ImmutableSet.Builder digests = ImmutableSet.builder(); for (TreeNode node : descendants(root)) { digests.add(Preconditions.checkNotNull(treeNodeDigestCache.get(node))); if (node.isLeaf()) { - digests.add(Preconditions.checkNotNull(fileContentsDigestCache.get(node.getActionInput()))); + digests.add(ContentDigests.getDigestFromInputCache(node.getActionInput(), inputFileCache)); } } return digests.build(); @@ -379,7 +373,8 @@ public final class TreeNodeRepository extends TreeTraverser