You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by to...@apache.org on 2016/09/07 00:22:01 UTC

[2/8] kudu git commit: KUDU-1590. Fix cache-test failure on some machines

KUDU-1590. Fix cache-test failure on some machines

CacheTest.TestEviction was failing on some machines, depending on the
number of cores. This is due to bfb6f2338cd57a1c7f8405c97b66c3050c8920ff
which changed the cache to determine the number of cache shards based on
the core count.

The number of shards changed the eviction behavior because the sharded
cache is actually only *approximately* LRU. Each shard itself is LRU,
but entries in different shards will not evict each other. So, with more
shards, the test wasn't evicting the element as expected.

The fix simply increases the amount of cache churn caused by the test so
that the eviction proceeds as expected.

Change-Id: I77362fc67ab5ba8420c21d1e3fb5c28ff9bfab1b
Reviewed-on: http://gerrit.cloudera.org:8080/4321
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/15671a12
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/15671a12
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/15671a12

Branch: refs/heads/master
Commit: 15671a12abe4cbaa984a587dce5e20106923ee49
Parents: 5516761
Author: Todd Lipcon <to...@apache.org>
Authored: Tue Sep 6 13:26:10 2016 -0700
Committer: Todd Lipcon <to...@apache.org>
Committed: Tue Sep 6 21:28:18 2016 +0000

----------------------------------------------------------------------
 src/kudu/util/cache-test.cc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/15671a12/src/kudu/util/cache-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/cache-test.cc b/src/kudu/util/cache-test.cc
index c49d077..7319cf9 100644
--- a/src/kudu/util/cache-test.cc
+++ b/src/kudu/util/cache-test.cc
@@ -185,13 +185,16 @@ TEST_P(CacheTest, EvictionPolicy) {
   const int kNumElems = 1000;
   const int kSizePerElem = kCacheSize / kNumElems;
 
-  // Frequently used entry must be kept around
-  for (int i = 0; i < kNumElems + 100; i++) {
+  // Loop adding and looking up new entries, but repeatedly accessing key 101. This
+  // frequently-used entry should not be evicted.
+  for (int i = 0; i < kNumElems + 1000; i++) {
     Insert(1000+i, 2000+i, kSizePerElem);
     ASSERT_EQ(2000+i, Lookup(1000+i));
     ASSERT_EQ(101, Lookup(100));
   }
   ASSERT_EQ(101, Lookup(100));
+  // Since '200' wasn't accessed in the loop above, it should have
+  // been evicted.
   ASSERT_EQ(-1, Lookup(200));
 }