HBASE-18532 Improve cache related stats rendered on RS UI
Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
parent
ad22437d05
commit
19a80c8234
@ -204,11 +204,21 @@ public class MemcachedBlockCache implements BlockCache {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getCurrentDataSize() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getBlockCount() {
|
public long getBlockCount() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getDataBlockCount() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<CachedBlock> iterator() {
|
public Iterator<CachedBlock> iterator() {
|
||||||
return new Iterator<CachedBlock>() {
|
return new Iterator<CachedBlock>() {
|
||||||
|
@ -327,25 +327,25 @@ are combined counts. Request count is sum of hits and misses.</p>
|
|||||||
</%if>
|
</%if>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Count</td>
|
<td>Count</td>
|
||||||
<td><% String.format("%,d", cbsbf.getCount()) %></td>
|
<td><% String.format("%,d", bc.getBlockCount()) %></td>
|
||||||
<td>Count of Blocks</td>
|
<td>Count of Blocks</td>
|
||||||
</tr>
|
</tr>
|
||||||
<%if !bucketCache %>
|
<%if !bucketCache %>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Count</td>
|
<td>Count</td>
|
||||||
<td><% String.format("%,d", cbsbf.getDataCount()) %></td>
|
<td><% String.format("%,d", bc.getDataBlockCount()) %></td>
|
||||||
<td>Count of DATA Blocks</td>
|
<td>Count of DATA Blocks</td>
|
||||||
</tr>
|
</tr>
|
||||||
</%if>
|
</%if>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Size</td>
|
<td>Size</td>
|
||||||
<td><% TraditionalBinaryPrefix.long2String(cbsbf.getSize(), "B", 1) %></td>
|
<td><% TraditionalBinaryPrefix.long2String(bc.getCurrentSize(), "B", 1) %></td>
|
||||||
<td>Size of Blocks</td>
|
<td>Size of Blocks</td>
|
||||||
</tr>
|
</tr>
|
||||||
<%if !bucketCache %>
|
<%if !bucketCache %>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Size</td>
|
<td>Size</td>
|
||||||
<td><% TraditionalBinaryPrefix.long2String(cbsbf.getDataSize(), "B", 1) %></td>
|
<td><% TraditionalBinaryPrefix.long2String(bc.getCurrentDataSize(), "B", 1) %></td>
|
||||||
<td>Size of DATA Blocks</td>
|
<td>Size of DATA Blocks</td>
|
||||||
</tr>
|
</tr>
|
||||||
</%if>
|
</%if>
|
||||||
@ -371,4 +371,3 @@ are combined counts. Request count is sum of hits and misses.</p>
|
|||||||
cbsbf = null;
|
cbsbf = null;
|
||||||
</%java>
|
</%java>
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
|
@ -101,12 +101,25 @@ public interface BlockCache extends Iterable<CachedBlock> {
|
|||||||
*/
|
*/
|
||||||
long getCurrentSize();
|
long getCurrentSize();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the occupied size of data blocks, in bytes.
|
||||||
|
* @return occupied space in cache, in bytes
|
||||||
|
*/
|
||||||
|
long getCurrentDataSize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of blocks currently cached in the block cache.
|
* Returns the number of blocks currently cached in the block cache.
|
||||||
* @return number of blocks in the cache
|
* @return number of blocks in the cache
|
||||||
*/
|
*/
|
||||||
long getBlockCount();
|
long getBlockCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of data blocks currently cached in the block cache.
|
||||||
|
* @return number of blocks in the cache
|
||||||
|
*/
|
||||||
|
long getDataBlockCount();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Iterator over the blocks in the cache.
|
* @return Iterator over the blocks in the cache.
|
||||||
*/
|
*/
|
||||||
|
@ -121,11 +121,21 @@ public class CombinedBlockCache implements ResizableBlockCache, HeapSize {
|
|||||||
return lruCache.getCurrentSize() + l2Cache.getCurrentSize();
|
return lruCache.getCurrentSize() + l2Cache.getCurrentSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getCurrentDataSize() {
|
||||||
|
return lruCache.getCurrentDataSize() + l2Cache.getCurrentDataSize();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getBlockCount() {
|
public long getBlockCount() {
|
||||||
return lruCache.getBlockCount() + l2Cache.getBlockCount();
|
return lruCache.getBlockCount() + l2Cache.getBlockCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getDataBlockCount() {
|
||||||
|
return lruCache.getDataBlockCount() + l2Cache.getDataBlockCount();
|
||||||
|
}
|
||||||
|
|
||||||
public static class CombinedCacheStats extends CacheStats {
|
public static class CombinedCacheStats extends CacheStats {
|
||||||
private final CacheStats lruCacheStats;
|
private final CacheStats lruCacheStats;
|
||||||
private final CacheStats bucketCacheStats;
|
private final CacheStats bucketCacheStats;
|
||||||
|
@ -173,9 +173,15 @@ public class LruBlockCache implements ResizableBlockCache, HeapSize {
|
|||||||
/** Current size of cache */
|
/** Current size of cache */
|
||||||
private final AtomicLong size;
|
private final AtomicLong size;
|
||||||
|
|
||||||
|
/** Current size of data blocks */
|
||||||
|
private final AtomicLong dataBlockSize;
|
||||||
|
|
||||||
/** Current number of cached elements */
|
/** Current number of cached elements */
|
||||||
private final AtomicLong elements;
|
private final AtomicLong elements;
|
||||||
|
|
||||||
|
/** Current number of cached data block elements */
|
||||||
|
private final AtomicLong dataBlockElements;
|
||||||
|
|
||||||
/** Cache access count (sequential ID) */
|
/** Cache access count (sequential ID) */
|
||||||
private final AtomicLong count;
|
private final AtomicLong count;
|
||||||
|
|
||||||
@ -309,6 +315,8 @@ public class LruBlockCache implements ResizableBlockCache, HeapSize {
|
|||||||
this.stats = new CacheStats(this.getClass().getSimpleName());
|
this.stats = new CacheStats(this.getClass().getSimpleName());
|
||||||
this.count = new AtomicLong(0);
|
this.count = new AtomicLong(0);
|
||||||
this.elements = new AtomicLong(0);
|
this.elements = new AtomicLong(0);
|
||||||
|
this.dataBlockElements = new AtomicLong(0);
|
||||||
|
this.dataBlockSize = new AtomicLong(0);
|
||||||
this.overhead = calculateOverhead(maxSize, blockSize, mapConcurrencyLevel);
|
this.overhead = calculateOverhead(maxSize, blockSize, mapConcurrencyLevel);
|
||||||
this.size = new AtomicLong(this.overhead);
|
this.size = new AtomicLong(this.overhead);
|
||||||
this.hardCapacityLimitFactor = hardLimitFactor;
|
this.hardCapacityLimitFactor = hardLimitFactor;
|
||||||
@ -394,6 +402,9 @@ public class LruBlockCache implements ResizableBlockCache, HeapSize {
|
|||||||
long newSize = updateSizeMetrics(cb, false);
|
long newSize = updateSizeMetrics(cb, false);
|
||||||
map.put(cacheKey, cb);
|
map.put(cacheKey, cb);
|
||||||
long val = elements.incrementAndGet();
|
long val = elements.incrementAndGet();
|
||||||
|
if (buf.getBlockType().isData()) {
|
||||||
|
dataBlockElements.incrementAndGet();
|
||||||
|
}
|
||||||
if (LOG.isTraceEnabled()) {
|
if (LOG.isTraceEnabled()) {
|
||||||
long size = map.size();
|
long size = map.size();
|
||||||
assertCounterSanity(size, val);
|
assertCounterSanity(size, val);
|
||||||
@ -451,9 +462,13 @@ public class LruBlockCache implements ResizableBlockCache, HeapSize {
|
|||||||
*/
|
*/
|
||||||
protected long updateSizeMetrics(LruCachedBlock cb, boolean evict) {
|
protected long updateSizeMetrics(LruCachedBlock cb, boolean evict) {
|
||||||
long heapsize = cb.heapSize();
|
long heapsize = cb.heapSize();
|
||||||
|
BlockType bt = cb.getBuffer().getBlockType();
|
||||||
if (evict) {
|
if (evict) {
|
||||||
heapsize *= -1;
|
heapsize *= -1;
|
||||||
}
|
}
|
||||||
|
if (bt != null && bt.isData()) {
|
||||||
|
dataBlockSize.addAndGet(heapsize);
|
||||||
|
}
|
||||||
return size.addAndGet(heapsize);
|
return size.addAndGet(heapsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,6 +568,9 @@ public class LruBlockCache implements ResizableBlockCache, HeapSize {
|
|||||||
long size = map.size();
|
long size = map.size();
|
||||||
assertCounterSanity(size, val);
|
assertCounterSanity(size, val);
|
||||||
}
|
}
|
||||||
|
if (block.getBuffer().getBlockType().isData()) {
|
||||||
|
dataBlockElements.decrementAndGet();
|
||||||
|
}
|
||||||
stats.evicted(block.getCachedTime(), block.getCacheKey().isPrimary());
|
stats.evicted(block.getCachedTime(), block.getCacheKey().isPrimary());
|
||||||
if (evictedByEvictionProcess && victimHandler != null) {
|
if (evictedByEvictionProcess && victimHandler != null) {
|
||||||
if (victimHandler instanceof BucketCache) {
|
if (victimHandler instanceof BucketCache) {
|
||||||
@ -821,6 +839,11 @@ public class LruBlockCache implements ResizableBlockCache, HeapSize {
|
|||||||
return this.size.get();
|
return this.size.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getCurrentDataSize() {
|
||||||
|
return this.dataBlockSize.get();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getFreeSize() {
|
public long getFreeSize() {
|
||||||
return getMaxSize() - getCurrentSize();
|
return getMaxSize() - getCurrentSize();
|
||||||
@ -836,6 +859,11 @@ public class LruBlockCache implements ResizableBlockCache, HeapSize {
|
|||||||
return this.elements.get();
|
return this.elements.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getDataBlockCount() {
|
||||||
|
return this.dataBlockElements.get();
|
||||||
|
}
|
||||||
|
|
||||||
EvictionThread getEvictionThread() {
|
EvictionThread getEvictionThread() {
|
||||||
return this.evictionThread;
|
return this.evictionThread;
|
||||||
}
|
}
|
||||||
@ -947,7 +975,7 @@ public class LruBlockCache implements ResizableBlockCache, HeapSize {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final static long CACHE_FIXED_OVERHEAD = ClassSize.align(
|
public final static long CACHE_FIXED_OVERHEAD = ClassSize.align(
|
||||||
(4 * Bytes.SIZEOF_LONG) + (9 * ClassSize.REFERENCE) +
|
(4 * Bytes.SIZEOF_LONG) + (11 * ClassSize.REFERENCE) +
|
||||||
(6 * Bytes.SIZEOF_FLOAT) + (2 * Bytes.SIZEOF_BOOLEAN)
|
(6 * Bytes.SIZEOF_FLOAT) + (2 * Bytes.SIZEOF_BOOLEAN)
|
||||||
+ ClassSize.OBJECT);
|
+ ClassSize.OBJECT);
|
||||||
|
|
||||||
|
@ -1121,6 +1121,11 @@ public class BucketCache implements BlockCache, HeapSize {
|
|||||||
return this.realCacheSize.get();
|
return this.realCacheSize.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getCurrentDataSize() {
|
||||||
|
return size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getFreeSize() {
|
public long getFreeSize() {
|
||||||
return this.bucketAllocator.getFreeSize();
|
return this.bucketAllocator.getFreeSize();
|
||||||
@ -1131,6 +1136,11 @@ public class BucketCache implements BlockCache, HeapSize {
|
|||||||
return this.blockNumber.get();
|
return this.blockNumber.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getDataBlockCount() {
|
||||||
|
return getBlockCount();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getCurrentSize() {
|
public long getCurrentSize() {
|
||||||
return this.bucketAllocator.getUsedSize();
|
return this.bucketAllocator.getUsedSize();
|
||||||
|
@ -595,11 +595,21 @@ public class TestHeapMemoryManager {
|
|||||||
return this.testBlockSize;
|
return this.testBlockSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getCurrentDataSize() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getBlockCount() {
|
public long getBlockCount() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getDataBlockCount() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMaxSize(long size) {
|
public void setMaxSize(long size) {
|
||||||
this.maxSize = size;
|
this.maxSize = size;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user