HBASE-4989 Metrics to measure sequential reads and random reads separately
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1213345 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
54c3a0a530
commit
28ee3bf9ba
|
@ -153,15 +153,19 @@ public class HFile {
|
|||
*/
|
||||
public final static int MIN_NUM_HFILE_PATH_LEVELS = 5;
|
||||
|
||||
// For measuring latency of "typical" reads and writes
|
||||
// For measuring latency of "sequential" reads and writes
|
||||
static volatile AtomicInteger readOps = new AtomicInteger();
|
||||
static volatile AtomicLong readTimeNano = new AtomicLong();
|
||||
static volatile AtomicInteger writeOps = new AtomicInteger();
|
||||
static volatile AtomicLong writeTimeNano = new AtomicLong();
|
||||
// For measuring latency of pread
|
||||
static volatile AtomicInteger preadOps = new AtomicInteger();
|
||||
static volatile AtomicLong preadTimeNano = new AtomicLong();
|
||||
|
||||
// for test purpose
|
||||
public static volatile AtomicLong dataBlockReadCnt = new AtomicLong(0);
|
||||
|
||||
// number of sequential reads
|
||||
public static final int getReadOps() {
|
||||
return readOps.getAndSet(0);
|
||||
}
|
||||
|
@ -170,6 +174,15 @@ public class HFile {
|
|||
return readTimeNano.getAndSet(0) / 1000000;
|
||||
}
|
||||
|
||||
// number of positional reads
|
||||
public static final int getPreadOps() {
|
||||
return preadOps.getAndSet(0);
|
||||
}
|
||||
|
||||
public static final long getPreadTimeMs() {
|
||||
return preadTimeNano.getAndSet(0) / 1000000;
|
||||
}
|
||||
|
||||
public static final int getWriteOps() {
|
||||
return writeOps.getAndSet(0);
|
||||
}
|
||||
|
|
|
@ -237,8 +237,8 @@ public class HFileReaderV1 extends AbstractHFileReader {
|
|||
hfileBlock.expectType(BlockType.META);
|
||||
|
||||
long delta = System.nanoTime() - startTimeNs;
|
||||
HFile.readTimeNano.addAndGet(delta);
|
||||
HFile.readOps.incrementAndGet();
|
||||
HFile.preadTimeNano.addAndGet(delta);
|
||||
HFile.preadOps.incrementAndGet();
|
||||
getSchemaMetrics().updateOnCacheMiss(BlockCategory.META, false, delta);
|
||||
|
||||
// Cache the block
|
||||
|
@ -316,8 +316,13 @@ public class HFileReaderV1 extends AbstractHFileReader {
|
|||
ByteBuffer buf = hfileBlock.getBufferWithoutHeader();
|
||||
|
||||
long delta = System.nanoTime() - startTimeNs;
|
||||
HFile.readTimeNano.addAndGet(delta);
|
||||
HFile.readOps.incrementAndGet();
|
||||
if (pread) {
|
||||
HFile.preadTimeNano.addAndGet(delta);
|
||||
HFile.preadOps.incrementAndGet();
|
||||
} else {
|
||||
HFile.readTimeNano.addAndGet(delta);
|
||||
HFile.readOps.incrementAndGet();
|
||||
}
|
||||
getSchemaMetrics().updateOnCacheMiss(BlockCategory.DATA, isCompaction,
|
||||
delta);
|
||||
|
||||
|
|
|
@ -206,8 +206,8 @@ public class HFileReaderV2 extends AbstractHFileReader {
|
|||
passSchemaMetricsTo(metaBlock);
|
||||
|
||||
long delta = System.nanoTime() - startTimeNs;
|
||||
HFile.readTimeNano.addAndGet(delta);
|
||||
HFile.readOps.incrementAndGet();
|
||||
HFile.preadTimeNano.addAndGet(delta);
|
||||
HFile.preadOps.incrementAndGet();
|
||||
getSchemaMetrics().updateOnCacheMiss(BlockCategory.META, false, delta);
|
||||
|
||||
// Cache the block
|
||||
|
@ -283,8 +283,13 @@ public class HFileReaderV2 extends AbstractHFileReader {
|
|||
BlockCategory blockCategory = dataBlock.getBlockType().getCategory();
|
||||
|
||||
long delta = System.nanoTime() - startTimeNs;
|
||||
HFile.readTimeNano.addAndGet(delta);
|
||||
HFile.readOps.incrementAndGet();
|
||||
if (pread) {
|
||||
HFile.preadTimeNano.addAndGet(delta);
|
||||
HFile.preadOps.incrementAndGet();
|
||||
} else {
|
||||
HFile.readTimeNano.addAndGet(delta);
|
||||
HFile.readOps.incrementAndGet();
|
||||
}
|
||||
getSchemaMetrics().updateOnCacheMiss(blockCategory, isCompaction, delta);
|
||||
|
||||
// Cache the block
|
||||
|
|
|
@ -186,11 +186,17 @@ public class RegionServerMetrics implements Updater {
|
|||
new MetricsIntValue("flushQueueSize", registry);
|
||||
|
||||
/**
|
||||
* filesystem read latency
|
||||
* filesystem sequential read latency
|
||||
*/
|
||||
public final MetricsTimeVaryingRate fsReadLatency =
|
||||
new MetricsTimeVaryingRate("fsReadLatency", registry);
|
||||
|
||||
/**
|
||||
* filesystem positional read latency
|
||||
*/
|
||||
public final MetricsTimeVaryingRate fsPreadLatency =
|
||||
new MetricsTimeVaryingRate("fsPreadLatency", registry);
|
||||
|
||||
/**
|
||||
* filesystem write latency
|
||||
*/
|
||||
|
@ -317,9 +323,12 @@ public class RegionServerMetrics implements Updater {
|
|||
addHLogMetric(HLog.getWriteTime(), this.fsWriteLatency);
|
||||
addHLogMetric(HLog.getWriteSize(), this.fsWriteSize);
|
||||
addHLogMetric(HLog.getSyncTime(), this.fsSyncLatency);
|
||||
// HFile metrics
|
||||
int ops = HFile.getReadOps();
|
||||
// HFile metrics, sequential reads
|
||||
int ops = HFile.getReadOps();
|
||||
if (ops != 0) this.fsReadLatency.inc(ops, HFile.getReadTimeMs());
|
||||
// HFile metrics, positional reads
|
||||
ops = HFile.getPreadOps();
|
||||
if (ops != 0) this.fsPreadLatency.inc(ops, HFile.getPreadTimeMs());
|
||||
/* NOTE: removed HFile write latency. 2 reasons:
|
||||
* 1) Mixing HLog latencies are far higher priority since they're
|
||||
* on-demand and HFile is used in background (compact/flush)
|
||||
|
|
Loading…
Reference in New Issue