HBASE-4310 SlabCache metrics bugfix (Li Pi)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1163620 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2011-08-31 13:46:01 +00:00
parent 9a66fe79df
commit 6fbc5260af
2 changed files with 23 additions and 13 deletions

View File

@ -228,6 +228,7 @@ Release 0.91.0 - Unreleased
non-distributed case (todd) non-distributed case (todd)
HBASE-4303 HRegionInfo.toString has bad quoting (todd) HBASE-4303 HRegionInfo.toString has bad quoting (todd)
HBASE-4307 race condition in CacheTestUtils (Li Pi) HBASE-4307 race condition in CacheTestUtils (Li Pi)
HBASE-4310 SlabCache metrics bugfix (Li Pi)
IMPROVEMENTS IMPROVEMENTS
HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack) HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack)

View File

@ -64,7 +64,8 @@ public class SlabCache implements SlabItemEvictionWatcher, BlockCache, HeapSize
long size; long size;
private final CacheStats stats; private final CacheStats stats;
final SlabStats slabstats; final SlabStats requestStats;
final SlabStats successfullyCachedStats;
private final long avgBlockSize; private final long avgBlockSize;
private static final long CACHE_FIXED_OVERHEAD = ClassSize.estimateBase( private static final long CACHE_FIXED_OVERHEAD = ClassSize.estimateBase(
SlabCache.class, false); SlabCache.class, false);
@ -80,7 +81,9 @@ public class SlabCache implements SlabItemEvictionWatcher, BlockCache, HeapSize
this.avgBlockSize = avgBlockSize; this.avgBlockSize = avgBlockSize;
this.size = size; this.size = size;
this.stats = new CacheStats(); this.stats = new CacheStats();
this.slabstats = new SlabStats(); this.requestStats = new SlabStats();
this.successfullyCachedStats = new SlabStats();
backingStore = new ConcurrentHashMap<String, SingleSizeCache>(); backingStore = new ConcurrentHashMap<String, SingleSizeCache>();
sizer = new TreeMap<Integer, SingleSizeCache>(); sizer = new TreeMap<Integer, SingleSizeCache>();
this.scheduleThreadPool.scheduleAtFixedRate(new StatisticsThread(this), this.scheduleThreadPool.scheduleAtFixedRate(new StatisticsThread(this),
@ -191,12 +194,13 @@ public class SlabCache implements SlabItemEvictionWatcher, BlockCache, HeapSize
Entry<Integer, SingleSizeCache> scacheEntry = getHigherBlock(cachedItem Entry<Integer, SingleSizeCache> scacheEntry = getHigherBlock(cachedItem
.getSerializedLength()); .getSerializedLength());
this.slabstats.addin(cachedItem.getSerializedLength()); this.requestStats.addin(cachedItem.getSerializedLength());
if (scacheEntry == null) { if (scacheEntry == null) {
return; // we can't cache, something too big. return; // we can't cache, something too big.
} }
this.successfullyCachedStats.addin(cachedItem.getSerializedLength());
SingleSizeCache scache = scacheEntry.getValue(); SingleSizeCache scache = scacheEntry.getValue();
scache.cacheBlock(blockName, cachedItem); // if this scache.cacheBlock(blockName, cachedItem); // if this
// fails, due to // fails, due to
@ -312,7 +316,10 @@ public class SlabCache implements SlabItemEvictionWatcher, BlockCache, HeapSize
@Override @Override
public void run() { public void run() {
ourcache.slabstats.logStats(ourcache); LOG.info("Request Stats");
ourcache.requestStats.logStats(ourcache);
LOG.info("Successfully Cached Stats");
ourcache.successfullyCachedStats.logStats(ourcache);
} }
} }
@ -353,11 +360,12 @@ public class SlabCache implements SlabItemEvictionWatcher, BlockCache, HeapSize
SlabCache.LOG.info("Current heap size is: " SlabCache.LOG.info("Current heap size is: "
+ StringUtils.humanReadableInt(slabCache.heapSize())); + StringUtils.humanReadableInt(slabCache.heapSize()));
for (int i = 0; i < fineGrainedStats.length; i++) { for (int i = 0; i < fineGrainedStats.length; i++) {
double lowerbound = Math.pow(Math.E, (double) i / (double) multiplier double lowerbound = Math.pow(Math.E,
- 0.5); ((double) i / (double) multiplier) - 0.5);
double upperbound = Math.pow(Math.E, (double) i / (double) multiplier double upperbound = Math.pow(Math.E,
+ 0.5); ((double) i / (double) multiplier) + 0.5);
if (fineGrainedStats[i].get() > 0) {
SlabCache.LOG.info("From " SlabCache.LOG.info("From "
+ StringUtils.humanReadableInt((long) lowerbound) + "- " + StringUtils.humanReadableInt((long) lowerbound) + "- "
+ StringUtils.humanReadableInt((long) upperbound) + ": " + StringUtils.humanReadableInt((long) upperbound) + ": "
@ -367,6 +375,7 @@ public class SlabCache implements SlabItemEvictionWatcher, BlockCache, HeapSize
} }
} }
} }
}
public int evictBlocksByPrefix(String prefix) { public int evictBlocksByPrefix(String prefix) {
int numEvicted = 0; int numEvicted = 0;