hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1363468 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/io/hfile/ test/java/org/apache/hadoop/hbase/io/hfile/
Date Thu, 19 Jul 2012 18:38:52 GMT
Author: tedyu
Date: Thu Jul 19 18:38:52 2012
New Revision: 1363468

URL: http://svn.apache.org/viewvc?rev=1363468&view=rev
Log:
HBASE-6312 Make BlockCache eviction thresholds configurable (Jie Huang)


Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/DoubleBlockCache.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestLruBlockCache.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java?rev=1363468&r1=1363467&r2=1363468&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CacheConfig.java
Thu Jul 19 18:38:52 2012
@@ -351,7 +351,7 @@ public class CacheConfig {
       StringUtils.humanReadableInt(cacheSize));
     if (offHeapCacheSize <= 0) {
       globalBlockCache = new LruBlockCache(cacheSize,
-          StoreFile.DEFAULT_BLOCKSIZE_SMALL);
+          StoreFile.DEFAULT_BLOCKSIZE_SMALL, conf);
     } else {
       globalBlockCache = new DoubleBlockCache(cacheSize, offHeapCacheSize,
           StoreFile.DEFAULT_BLOCKSIZE_SMALL, blockSize, conf);

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/DoubleBlockCache.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/DoubleBlockCache.java?rev=1363468&r1=1363467&r2=1363468&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/DoubleBlockCache.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/DoubleBlockCache.java
Thu Jul 19 18:38:52 2012
@@ -67,7 +67,7 @@ public class DoubleBlockCache implements
         + StringUtils.humanReadableInt(onHeapSize)
         + "bytes with an average block size of "
         + StringUtils.humanReadableInt(onHeapBlockSize) + " bytes.");
-    onHeapCache = new LruBlockCache(onHeapSize, onHeapBlockSize);
+    onHeapCache = new LruBlockCache(onHeapSize, onHeapBlockSize, conf);
 
     LOG.info("Creating off-heap cache of size "
         + StringUtils.humanReadableInt(offHeapSize)

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java?rev=1363468&r1=1363467&r2=1363468&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
Thu Jul 19 18:38:52 2012
@@ -99,14 +99,15 @@ public class LruBlockCache implements Bl
   static final Log LOG = LogFactory.getLog(LruBlockCache.class);
 
   /** Default Configuration Parameters*/
-
+  static final String LRU_MIN_FACTOR = "hbase.lru.blockcache.min.factor";
+  
   /** Backing Concurrent Map Configuration */
   static final float DEFAULT_LOAD_FACTOR = 0.75f;
   static final int DEFAULT_CONCURRENCY_LEVEL = 16;
 
   /** Eviction thresholds */
-  static final float DEFAULT_MIN_FACTOR = 0.75f;
-  static final float DEFAULT_ACCEPTABLE_FACTOR = 0.85f;
+  static final float DEFAULT_MIN_FACTOR = 0.95f;
+  static final float DEFAULT_ACCEPTABLE_FACTOR = 0.99f;
 
   /** Priority buckets */
   static final float DEFAULT_SINGLE_FACTOR = 0.25f;
@@ -196,6 +197,22 @@ public class LruBlockCache implements Bl
         DEFAULT_SINGLE_FACTOR, DEFAULT_MULTI_FACTOR,
         DEFAULT_MEMORY_FACTOR);
   }
+  
+  public LruBlockCache(long maxSize, long blockSize, boolean evictionThread, Configuration
conf) {
+    this(maxSize, blockSize, evictionThread,
+        (int)Math.ceil(1.2*maxSize/blockSize),
+        DEFAULT_LOAD_FACTOR, 
+        DEFAULT_CONCURRENCY_LEVEL,
+        conf.getFloat(LRU_MIN_FACTOR, DEFAULT_MIN_FACTOR), 
+        DEFAULT_ACCEPTABLE_FACTOR,
+        DEFAULT_SINGLE_FACTOR, 
+        DEFAULT_MULTI_FACTOR,
+        DEFAULT_MEMORY_FACTOR);
+  }
+  
+  public LruBlockCache(long maxSize, long blockSize, Configuration conf) {
+    this(maxSize, blockSize, true, conf);
+  }
 
   /**
    * Configurable constructor.  Use this constructor if not using defaults.

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestLruBlockCache.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestLruBlockCache.java?rev=1363468&r1=1363467&r2=1363468&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestLruBlockCache.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestLruBlockCache.java
Thu Jul 19 18:38:52 2012
@@ -200,10 +200,9 @@ public class TestLruBlockCache {
     assertTrue(cache.heapSize() <
         (maxSize * LruBlockCache.DEFAULT_ACCEPTABLE_FACTOR));
 
-    // All blocks except block 0 and 1 should be in the cache
+    // All blocks except block 0  should be in the cache
     assertTrue(cache.getBlock(blocks[0].cacheKey, true) == null);
-    assertTrue(cache.getBlock(blocks[1].cacheKey, true) == null);
-    for(int i=2;i<blocks.length;i++) {
+    for(int i=1;i<blocks.length;i++) {
       assertEquals(cache.getBlock(blocks[i].cacheKey, true),
           blocks[i]);
     }



Mime
View raw message