From 1a34a248b05c9e64e2db0d76f3ad8e93cf755f99 Mon Sep 17 00:00:00 2001 From: Eric Fellheimer Date: Thu, 21 Jan 2016 19:17:19 +0000 Subject: Improve space efficiency of Blaze action cache: For actions that don't perform input discovery, there is no need to store the full set of edges in the action cache. This data is only used to formulate the set of input files for an action prior to checking the validity of a cache entry. For non-input-discovering actions, the set of input files is known statically and the action cache data is not used. -- MOS_MIGRATED_REVID=112704382 --- .../cache/CompactPersistentActionCacheTest.java | 29 ++++++++++++++++------ .../lib/actions/util/ActionCacheTestHelper.java | 4 ++- .../lib/skyframe/TimestampBuilderTestCase.java | 4 +-- 3 files changed, 26 insertions(+), 11 deletions(-) (limited to 'src/test/java/com/google/devtools') diff --git a/src/test/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCacheTest.java b/src/test/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCacheTest.java index bd69b0c1c9..ff0dca21d9 100644 --- a/src/test/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCacheTest.java +++ b/src/test/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCacheTest.java @@ -94,15 +94,24 @@ public class CompactPersistentActionCacheTest { } @Test - public void testSave() throws IOException { + public void testSaveDiscoverInputs() throws Exception { + assertSave(true); + } + + @Test + public void testSaveNoDiscoverInputs() throws Exception { + assertSave(false); + } + + private void assertSave(boolean discoverInputs) throws Exception { String key = "key"; - putKey(key); + putKey(key, discoverInputs); cache.save(); assertTrue(mapFile.exists()); assertFalse(journalFile.exists()); CompactPersistentActionCache newcache = - new CompactPersistentActionCache(dataRoot, clock); + new CompactPersistentActionCache(dataRoot, clock); ActionCache.Entry readentry = newcache.get(key); assertNotNull(readentry); assertEquals(cache.get(key).toString(), readentry.toString()); @@ -129,7 +138,7 @@ public class CompactPersistentActionCacheTest { } assertKeyEquals(cache, newcache, "abc"); assertKeyEquals(cache, newcache, "123"); - putKey("xyz", newcache); + putKey("xyz", newcache, true); assertIncrementalSave(newcache); // Make sure we can see previous journal values after a second incremental save. @@ -154,7 +163,7 @@ public class CompactPersistentActionCacheTest { // Mutations may result in IllegalStateException. @Test public void testEntryToStringIsIdempotent() throws Exception { - ActionCache.Entry entry = new ActionCache.Entry("actionKey"); + ActionCache.Entry entry = new ActionCache.Entry("actionKey", false); entry.toString(); entry.addFile(new PathFragment("foo/bar"), Metadata.CONSTANT_METADATA); entry.toString(); @@ -200,11 +209,15 @@ public class CompactPersistentActionCacheTest { } private void putKey(String key) { - putKey(key, cache); + putKey(key, cache, false); + } + + private void putKey(String key, boolean discoversInputs) { + putKey(key, cache, discoversInputs); } - private void putKey(String key, ActionCache ac) { - ActionCache.Entry entry = ac.createEntry(key); + private void putKey(String key, ActionCache ac, boolean discoversInputs) { + ActionCache.Entry entry = ac.createEntry(key, discoversInputs); entry.getFileDigest(); ac.put(key, entry); } diff --git a/src/test/java/com/google/devtools/build/lib/actions/util/ActionCacheTestHelper.java b/src/test/java/com/google/devtools/build/lib/actions/util/ActionCacheTestHelper.java index 9727b22aea..6b3b8a179a 100644 --- a/src/test/java/com/google/devtools/build/lib/actions/util/ActionCacheTestHelper.java +++ b/src/test/java/com/google/devtools/build/lib/actions/util/ActionCacheTestHelper.java @@ -33,7 +33,9 @@ public class ActionCacheTestHelper { @Override public void remove(String key) {} @Override - public Entry createEntry(String key) { return new ActionCache.Entry(key); } + public Entry createEntry(String key, boolean discoversInputs) { + return new ActionCache.Entry(key, discoversInputs); + } @Override public long save() { return -1; } @Override diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java index 668dfbd270..7f24a34cb0 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java @@ -352,8 +352,8 @@ public abstract class TimestampBuilderTestCase extends FoundationTestCase { } @Override - public Entry createEntry(String key) { - return new ActionCache.Entry(key); + public Entry createEntry(String key, boolean discoversInputs) { + return new ActionCache.Entry(key, discoversInputs); } public synchronized void reset() { -- cgit v1.2.3