hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nspiegelb...@apache.org
Subject svn commit: r1181547 - in /hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase: io/hfile/LruBlockCache.java regionserver/HRegionServer.java
Date Tue, 11 Oct 2011 02:18:46 GMT
Author: nspiegelberg
Date: Tue Oct 11 02:18:46 2011
New Revision: 1181547

URL: http://svn.apache.org/viewvc?rev=1181547&view=rev
Log:
Make LRU Cache Hit Ratio Incremental

Summary:
While trying to understand how compaction policies affect
performance, I noticed that the block cache hit ratio was very steady.
That is because it averages since process start time.  In practice, the
ratio varies widely based on the time.  Change this stat to be
incremental so we can observe those changes

Test Plan:
- JMX

DiffCamp Revision:

Reviewed By: kannan
Reviewers: kannan, kranganathan
Commenters: jgray
CC: , nspiegelberg, jgray, kannan
Differential Revision: 257940

Modified:
    hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
    hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Modified: hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java?rev=1181547&r1=1181546&r2=1181547&view=diff
==============================================================================
--- hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
(original)
+++ hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
Tue Oct 11 02:18:46 2011
@@ -587,6 +587,9 @@ public class LruBlockCache implements Bl
     private final AtomicLong evictionCount = new AtomicLong(0);
     private final AtomicLong evictedCount = new AtomicLong(0);
 
+    private long lastHitCount = 0;
+    private long lastRqCount = 0;
+
     public void miss() {
       missCount.incrementAndGet();
       accessCount.incrementAndGet();
@@ -629,6 +632,19 @@ public class LruBlockCache implements Bl
       return ((float)getHitCount()/(float)getRequestCount());
     }
 
+    public synchronized double getIncrementalHitRatio() {
+      long curHitCount = getHitCount();
+      long curRqCount = getRequestCount();
+      double hitRatio = 0;
+      if (curRqCount >= lastRqCount) {
+        hitRatio = (double) (curHitCount - lastHitCount)
+            / (double) (curRqCount - lastRqCount);
+      }
+      lastHitCount = curHitCount;
+      lastRqCount = curRqCount;
+      return hitRatio;
+    }
+
     public double getMissRatio() {
       return ((float)getMissCount()/(float)getRequestCount());
     }

Modified: hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1181547&r1=1181546&r2=1181547&view=diff
==============================================================================
--- hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++ hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Tue Oct 11 02:18:46 2011
@@ -1009,7 +1009,8 @@ public class HRegionServer implements HR
       this.metrics.blockCacheCount.set(lruBlockCache.size());
       this.metrics.blockCacheFree.set(lruBlockCache.getFreeSize());
       this.metrics.blockCacheSize.set(lruBlockCache.getCurrentSize());
-      double ratio = lruBlockCache.getStats().getHitRatio();
+
+      double ratio = lruBlockCache.getStats().getIncrementalHitRatio();
       int percent = (int) (ratio * 100);
       this.metrics.blockCacheHitRatio.set(percent);
     }



Mime
View raw message