count disk reads
This commit is contained in:
@@ -53,6 +53,7 @@ public class DiskStorage implements AutoCloseable {
|
||||
try {
|
||||
LOGGER.trace("read block={} file={}", blockOffset, relativeDatabaseFileForLogging);
|
||||
|
||||
DiskStoreStats.incrementDiskRead();
|
||||
final var byteBuffer = fileChannel.map(MapMode.READ_WRITE, blockOffset, blockSize);
|
||||
|
||||
return new DiskBlock(blockOffset, byteBuffer);
|
||||
@@ -227,6 +228,7 @@ public class DiskStorage implements AutoCloseable {
|
||||
|
||||
private FreeListNode readFreeListNode(final long freeListNodePosition) throws IOException {
|
||||
final var freeListNode = ByteBuffer.allocate(FREE_LIST_NODE_SIZE);
|
||||
DiskStoreStats.incrementDiskRead();
|
||||
fileChannel.read(freeListNode, freeListNodePosition);
|
||||
final long offset = freeListNodePosition;
|
||||
final long next = freeListNode.getLong(FREE_LIST_NEXT_POINTER);
|
||||
@@ -250,6 +252,7 @@ public class DiskStorage implements AutoCloseable {
|
||||
|
||||
private long readFreeListRootNodePosition() throws IOException {
|
||||
final var freeListFirstBlock = ByteBuffer.allocate(8);
|
||||
DiskStoreStats.incrementDiskRead();
|
||||
fileChannel.read(freeListFirstBlock, FREE_LIST_ROOT_OFFSET);
|
||||
return freeListFirstBlock.getLong(0);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.lucares.pdb.diskstorage;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public class DiskStoreStats {
|
||||
private static final AtomicLong diskRead = new AtomicLong(0);
|
||||
|
||||
public static void incrementDiskRead() {
|
||||
diskRead.incrementAndGet();
|
||||
}
|
||||
|
||||
public static void resetDiskRead() {
|
||||
diskRead.set(0);
|
||||
}
|
||||
|
||||
public static long getDiskRead() {
|
||||
return diskRead.get();
|
||||
}
|
||||
|
||||
public static long getAndResetDiskRead() {
|
||||
|
||||
return diskRead.getAndSet(0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user