You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by fr...@apache.org on 2017/02/13 15:04:46 UTC
svn commit: r1782791 - in
/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file:
IOMonitor.java TarReader.java TarWriter.java tooling/ConsistencyChecker.java
Author: frm
Date: Mon Feb 13 15:04:45 2017
New Revision: 1782791
URL: http://svn.apache.org/viewvc?rev=1782791&view=rev
Log:
OAK-5637 - Increase time granularity in IOMonitor
Modified:
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/IOMonitor.java
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/TarReader.java
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/TarWriter.java
jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/tooling/ConsistencyChecker.java
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/IOMonitor.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/IOMonitor.java?rev=1782791&r1=1782790&r2=1782791&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/IOMonitor.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/IOMonitor.java Mon Feb 13 15:04:45 2017
@@ -19,14 +19,54 @@ package org.apache.jackrabbit.oak.segmen
import java.io.File;
+/**
+ * Callback interface that eases the collection of statistics about I/O
+ * operations.
+ */
public interface IOMonitor {
+ /**
+ * Called before a segment is read from the file system.
+ *
+ * @param file File containing the segment.
+ * @param msb Most significant bits of the segment ID.
+ * @param lsb Least significant bits of the segment ID.
+ * @param length Size of the segment.
+ */
void beforeSegmentRead(File file, long msb, long lsb, int length);
+ /**
+ * Called after a segment is read from the file system. This is called only
+ * in case of successful operations.
+ *
+ * @param file File containing the segment.
+ * @param msb Most significant bits of the segment ID.
+ * @param lsb Least significant bits of the segment ID.
+ * @param length Size of the segment.
+ * @param elapsed Time spent by the read operation, in nanoseconds.
+ */
void afterSegmentRead(File file, long msb, long lsb, int length, long elapsed);
+ /**
+ * Called before a segment is written to the file system.
+ *
+ * @param file File containing the segment.
+ * @param msb Most significant bits of the segment ID.
+ * @param lsb Least significant bits of the segment ID.
+ * @param length Size of the segment.
+ */
void beforeSegmentWrite(File file, long msb, long lsb, int length);
+ /**
+ * Called after a segment is written to the file system. This is called only
+ * in case of successful operations.
+ *
+ * @param file File containing the segment.
+ * @param msb Most significant bits of the segment ID.
+ * @param lsb Least significant bits of the segment ID.
+ * @param length Size of the segment.
+ * @param elapsed Time spent by the write operation, in nanoseconds.
+ */
void afterSegmentWrite(File file, long msb, long lsb, int length, long elapsed);
}
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/TarReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/TarReader.java?rev=1782791&r1=1782790&r2=1782791&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/TarReader.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/TarReader.java Mon Feb 13 15:04:45 2017
@@ -1118,7 +1118,7 @@ class TarReader implements Closeable {
ioMonitor.beforeSegmentRead(file, msb, lsb, size);
Stopwatch stopwatch = Stopwatch.createStarted();
ByteBuffer buffer = access.read(offset, size);
- long elapsed = stopwatch.elapsed(TimeUnit.MILLISECONDS);
+ long elapsed = stopwatch.elapsed(TimeUnit.NANOSECONDS);
ioMonitor.afterSegmentRead(file, msb, lsb, size, elapsed);
return buffer;
}
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/TarWriter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/TarWriter.java?rev=1782791&r1=1782790&r2=1782791&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/TarWriter.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/TarWriter.java Mon Feb 13 15:04:45 2017
@@ -262,7 +262,7 @@ class TarWriter implements Closeable {
ioMonitor.beforeSegmentWrite(file, msb, lsb, size);
Stopwatch stopwatch = Stopwatch.createStarted();
access.write(data, offset, size);
- ioMonitor.afterSegmentWrite(file, msb, lsb, size, stopwatch.elapsed(TimeUnit.MILLISECONDS));
+ ioMonitor.afterSegmentWrite(file, msb, lsb, size, stopwatch.elapsed(TimeUnit.NANOSECONDS));
if (padding > 0) {
access.write(ZERO_BYTES, 0, padding);
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/tooling/ConsistencyChecker.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/tooling/ConsistencyChecker.java?rev=1782791&r1=1782790&r2=1782791&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/tooling/ConsistencyChecker.java (original)
+++ jackrabbit/oak/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/tooling/ConsistencyChecker.java Mon Feb 13 15:04:45 2017
@@ -65,12 +65,15 @@ public class ConsistencyChecker implemen
private final AtomicLong ioOperations = new AtomicLong(0);
- private final AtomicLong bytesRead = new AtomicLong(0);
+ private final AtomicLong readBytes = new AtomicLong(0);
+
+ private final AtomicLong readTime = new AtomicLong(0);
@Override
- public void beforeSegmentRead(File file, long msb, long lsb, int length) {
+ public void afterSegmentRead(File file, long msb, long lsb, int length, long elapsed) {
ioOperations.incrementAndGet();
- bytesRead.addAndGet(length);
+ readBytes.addAndGet(length);
+ readTime.addAndGet(elapsed);
}
}
@@ -144,13 +147,17 @@ public class ConsistencyChecker implemen
if (ioStatistics) {
checker.print(
- "[I/O] Segment read operations: {0}",
+ "[I/O] Segment read: Number of operations: {0}",
checker.statisticsIOMonitor.ioOperations
);
checker.print(
- "[I/O] Segment bytes read: {0} ({1} bytes)",
- humanReadableByteCount(checker.statisticsIOMonitor.bytesRead.get()),
- checker.statisticsIOMonitor.bytesRead
+ "[I/O] Segment read: Total size: {0} ({1} bytes)",
+ humanReadableByteCount(checker.statisticsIOMonitor.readBytes.get()),
+ checker.statisticsIOMonitor.readBytes
+ );
+ checker.print(
+ "[I/O] Segment read: Total time: {0} ns",
+ checker.statisticsIOMonitor.readTime
);
}