You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by re...@apache.org on 2019/06/05 04:03:00 UTC

[hbase] branch branch-1.4 updated: HBASE-22540 [Memstore] Correct counters in MemStoreChunkPool

This is an automated email from the ASF dual-hosted git repository.

reidchan pushed a commit to branch branch-1.4
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-1.4 by this push:
     new 515d293  HBASE-22540 [Memstore] Correct counters in MemStoreChunkPool
515d293 is described below

commit 515d2938f343779b946e8ba61f8d4abbdff99446
Author: Reid Chan <re...@apache.org>
AuthorDate: Wed Jun 5 11:55:10 2019 +0800

    HBASE-22540 [Memstore] Correct counters in MemStoreChunkPool
    
    * First commit: HBASE-22540 [Memstore] Correct counters in MemStoreChunkPool
    
    * Address comment and remove useless parent thread info from Statistics thread
    
    Signed-off-by: Andrew Purtell <ap...@apache.org>
---
 .../hbase/regionserver/MemStoreChunkPool.java      | 23 ++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreChunkPool.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreChunkPool.java
index eb43b43..763a574 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreChunkPool.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreChunkPool.java
@@ -77,6 +77,7 @@ public class MemStoreChunkPool {
   private static final int statThreadPeriod = 60 * 5;
   private AtomicLong createdChunkCount = new AtomicLong();
   private AtomicLong reusedChunkCount = new AtomicLong();
+  private AtomicLong requestedChunkCount = new AtomicLong();
 
   MemStoreChunkPool(Configuration conf, int chunkSize, int maxCount,
       int initialCount) {
@@ -88,9 +89,9 @@ public class MemStoreChunkPool {
       chunk.init();
       reclaimedChunks.add(chunk);
     }
-    final String n = Thread.currentThread().getName();
+    createdChunkCount.set(initialCount);
     scheduleThreadPool = Executors.newScheduledThreadPool(1,
-        new ThreadFactoryBuilder().setNameFormat(n+"-MemStoreChunkPool Statistics")
+        new ThreadFactoryBuilder().setNameFormat("MemStoreChunkPool Statistics")
             .setDaemon(true).build());
     this.scheduleThreadPool.scheduleAtFixedRate(new StatisticsThread(this),
         statThreadPeriod, statThreadPeriod, TimeUnit.SECONDS);
@@ -102,6 +103,7 @@ public class MemStoreChunkPool {
    * @return a chunk
    */
   Chunk getChunk() {
+    requestedChunkCount.incrementAndGet();
     Chunk chunk = reclaimedChunks.poll();
     if (chunk == null) {
       chunk = new Chunk(chunkSize);
@@ -172,15 +174,16 @@ public class MemStoreChunkPool {
   }
 
   private void logStats() {
-    if (!LOG.isDebugEnabled()) return;
-    long created = createdChunkCount.get();
+    long total = createdChunkCount.get();
     long reused = reusedChunkCount.get();
-    long total = created + reused;
-    LOG.debug("Stats: current pool size=" + reclaimedChunks.size()
-        + ",created chunk count=" + created
-        + ",reused chunk count=" + reused
-        + ",reuseRatio=" + (total == 0 ? "0" : StringUtils.formatPercent(
-            (float) reused / (float) total, 2)));
+    long available = reclaimedChunks.size();
+    long requested = requestedChunkCount.get();
+    LOG.info("Stats: chunk in pool=" + available
+        + ", chunk in use=" + (total - available)
+        + ", total chunk=" + total
+        + ", reused chunk=" + reused
+        + ", reuse ratio=" + (requested == 0 ? "0" : StringUtils.formatPercent(
+            (float) reused / (float) requested, 2)));
   }
 
   /**