Skip to content

Commit

Permalink
HBASE-27948 Report memstore on-heap and off-heap size as jmx metrics …
Browse files Browse the repository at this point in the history
…in sub=Memory bean (#5293)

Signed-off-by: Viraj Jasani <[email protected]>
  • Loading branch information
jinggou authored and virajjasani committed Jun 29, 2023
1 parent 24a345a commit b9dbccc
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ public interface MetricsHeapMemoryManagerSource extends BaseSource {
*/
void setCurMemStoreSizeGauge(long memStoreSize);

/**
* Set the current global memstore on-heap size used gauge
* @param memStoreOnHeapSize the current memory usage in memstore on-heap, in bytes.
*/
void setCurMemStoreOnHeapSizeGauge(long memStoreOnHeapSize);

/**
* Set the current global memstore off-heap size used gauge
* @param memStoreOffHeapSize the current memory usage in memstore off-heap, in bytes.
*/
void setCurMemStoreOffHeapSizeGauge(long memStoreOffHeapSize);

/**
* Update the increase/decrease memstore size histogram
* @param memStoreDeltaSize the tuning result of memstore.
Expand Down Expand Up @@ -118,6 +130,13 @@ public interface MetricsHeapMemoryManagerSource extends BaseSource {
String UNBLOCKED_FLUSH_GAUGE_DESC = "Gauge for the unblocked flush count before tuning";
String MEMSTORE_SIZE_GAUGE_NAME = "memStoreSize";
String MEMSTORE_SIZE_GAUGE_DESC = "Global MemStore used in bytes by the RegionServer";
String MEMSTORE_ONHEAP_SIZE_GAUGE_NAME = "memStoreOnHeapSize";
String MEMSTORE_ONHEAP_SIZE_GAUGE_DESC =
"Global MemStore On-heap size in bytes by the RegionServer";
String MEMSTORE_OFFHEAP_SIZE_GAUGE_NAME = "memStoreOffHeapSize";
String MEMSTORE_OFFHEAP_SIZE_GAUGE_DESC =
"Global MemStore Off-heap size in bytes by the RegionServer";

String BLOCKCACHE_SIZE_GAUGE_NAME = "blockCacheSize";
String BLOCKCACHE_SIZE_GAUGE_DESC = "BlockCache used in bytes by the RegionServer";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class MetricsHeapMemoryManagerSourceImpl extends BaseSourceImpl
private final MutableGaugeLong blockedFlushGauge;
private final MutableGaugeLong unblockedFlushGauge;
private final MutableGaugeLong memStoreSizeGauge;
private final MutableGaugeLong memStoreOnHeapSizeGauge;
private final MutableGaugeLong memStoreOffHeapSizeGauge;
private final MutableGaugeLong blockCacheSizeGauge;

private final MutableFastCounter doNothingCounter;
Expand Down Expand Up @@ -75,6 +77,10 @@ public MetricsHeapMemoryManagerSourceImpl(String metricsName, String metricsDesc
getMetricsRegistry().newGauge(UNBLOCKED_FLUSH_GAUGE_NAME, UNBLOCKED_FLUSH_GAUGE_DESC, 0L);
memStoreSizeGauge =
getMetricsRegistry().newGauge(MEMSTORE_SIZE_GAUGE_NAME, MEMSTORE_SIZE_GAUGE_DESC, 0L);
memStoreOnHeapSizeGauge = getMetricsRegistry().newGauge(MEMSTORE_ONHEAP_SIZE_GAUGE_NAME,
MEMSTORE_ONHEAP_SIZE_GAUGE_DESC, 0L);
memStoreOffHeapSizeGauge = getMetricsRegistry().newGauge(MEMSTORE_OFFHEAP_SIZE_GAUGE_NAME,
MEMSTORE_OFFHEAP_SIZE_GAUGE_DESC, 0L);
blockCacheSizeGauge =
getMetricsRegistry().newGauge(BLOCKCACHE_SIZE_GAUGE_NAME, BLOCKCACHE_SIZE_GAUGE_DESC, 0L);

Expand Down Expand Up @@ -111,6 +117,16 @@ public void setCurMemStoreSizeGauge(long memstoreSize) {
memStoreSizeGauge.set(memstoreSize);
}

@Override
public void setCurMemStoreOnHeapSizeGauge(long memstoreOnHeapSize) {
memStoreOnHeapSizeGauge.set(memstoreOnHeapSize);
}

@Override
public void setCurMemStoreOffHeapSizeGauge(long memstoreOffHeapSize) {
memStoreOffHeapSizeGauge.set(memstoreOffHeapSize);
}

@Override
public void updateMemStoreDeltaSizeHistogram(int memStoreDeltaSize) {
if (memStoreDeltaSize >= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,15 @@ private void tune() {
unblockedFlushCnt = unblockedFlushCount.getAndSet(0);
tunerContext.setUnblockedFlushCount(unblockedFlushCnt);
metricsHeapMemoryManager.updateUnblockedFlushCount(unblockedFlushCnt);
// TODO : add support for offheap metrics
tunerContext.setCurBlockCacheUsed((float) blockCache.getCurrentSize() / maxHeapSize);
metricsHeapMemoryManager.setCurBlockCacheSizeGauge(blockCache.getCurrentSize());
long globalMemstoreDataSize = regionServerAccounting.getGlobalMemStoreDataSize();
long globalMemstoreHeapSize = regionServerAccounting.getGlobalMemStoreHeapSize();
long globalMemStoreOffHeapSize = regionServerAccounting.getGlobalMemStoreOffHeapSize();
tunerContext.setCurMemStoreUsed((float) globalMemstoreHeapSize / maxHeapSize);
metricsHeapMemoryManager.setCurMemStoreSizeGauge(globalMemstoreHeapSize);
metricsHeapMemoryManager.setCurMemStoreSizeGauge(globalMemstoreDataSize);
metricsHeapMemoryManager.setCurMemStoreOnHeapSizeGauge(globalMemstoreHeapSize);
metricsHeapMemoryManager.setCurMemStoreOffHeapSizeGauge(globalMemStoreOffHeapSize);
tunerContext.setCurBlockCacheSize(blockCachePercent);
tunerContext.setCurMemStoreSize(globalMemStorePercent);
TunerResult result = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ public void setCurMemStoreSizeGauge(final long memStoreSize) {
source.setCurMemStoreSizeGauge(memStoreSize);
}

/**
* Set the current global memstore on-heap size gauge
* @param memStoreOnHeapSize the current memory on-heap size in memstore, in bytes.
*/
public void setCurMemStoreOnHeapSizeGauge(final long memStoreOnHeapSize) {
source.setCurMemStoreOnHeapSizeGauge(memStoreOnHeapSize);
}

/**
* Set the current global memstore off-heap size gauge
* @param memStoreOffHeapSize the current memory off-heap size in memstore, in bytes.
*/
public void setCurMemStoreOffHeapSizeGauge(final long memStoreOffHeapSize) {
source.setCurMemStoreOffHeapSizeGauge(memStoreOffHeapSize);
}

/**
* Update the increase/decrease memstore size histogram
* @param memStoreDeltaSize the tuning result of memstore.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ public long getGlobalMemStoreDataSize() {
return globalMemStoreDataSize.sum();
}

/** Returns the global memstore heap size in the RegionServer */
/** Returns the global memstore on-heap size in the RegionServer */
public long getGlobalMemStoreHeapSize() {
return this.globalMemStoreHeapSize.sum();
}

/** Returns the global memstore heap size in the RegionServer */
/** Returns the global memstore off-heap size in the RegionServer */
public long getGlobalMemStoreOffHeapSize() {
return this.globalMemStoreOffHeapSize.sum();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@ public void testGauge() {
hmm.updateBlockedFlushCount(200);
hmm.updateUnblockedFlushCount(50);
hmm.setCurMemStoreSizeGauge(256 * 1024 * 1024);
hmm.setCurMemStoreOnHeapSizeGauge(512 * 1024 * 1024);
hmm.setCurMemStoreOffHeapSizeGauge(128 * 1024 * 1024);
hmm.setCurBlockCacheSizeGauge(100 * 1024 * 1024);

HELPER.assertGauge("blockedFlushGauge", 200, source);
HELPER.assertGauge("unblockedFlushGauge", 50, source);
HELPER.assertGauge("memStoreSize", 256 * 1024 * 1024, source);
HELPER.assertGauge("memStoreOnHeapSize", 512 * 1024 * 1024, source);
HELPER.assertGauge("memStoreOffHeapSize", 128 * 1024 * 1024, source);
HELPER.assertGauge("blockCacheSize", 100 * 1024 * 1024, source);
}
}

0 comments on commit b9dbccc

Please sign in to comment.