aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar Eric Fellheimer <felly@google.com>2016-01-21 19:17:19 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-01-22 15:53:27 +0000
commit1a34a248b05c9e64e2db0d76f3ad8e93cf755f99 (patch)
tree700009696af0f00536e6880394af4b00dfae95c1 /src/test/java/com/google/devtools
parent0bf232e1bdf711012899298d9aa9734a40636861 (diff)
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
Diffstat (limited to 'src/test/java/com/google/devtools')
-rw-r--r--src/test/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCacheTest.java29
-rw-r--r--src/test/java/com/google/devtools/build/lib/actions/util/ActionCacheTestHelper.java4
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java4
3 files changed, 26 insertions, 11 deletions
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() {