DL-113: Improve the sync reader benchmark

Add more logging information for calcuating the stats for catching up reads


Project: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/commit/1feaeb43
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/tree/1feaeb43
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/diff/1feaeb43

Branch: refs/heads/master
Commit: 1feaeb43702c59b0fc069e8dde6bca92d6c01fe4
Parents: e690a8c
Author: Sijie Guo <[email protected]>
Authored: Mon Nov 21 17:41:26 2016 -0800
Committer: Sijie Guo <[email protected]>
Committed: Tue Dec 27 16:49:30 2016 -0800

----------------------------------------------------------------------
 .../distributedlog/benchmark/stream/SyncReaderBenchmark.java | 8 ++++++++
 .../java/com/twitter/distributedlog/BKSyncLogReaderDLSN.java | 1 -
 2 files changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1feaeb43/distributedlog-benchmark/src/main/java/com/twitter/distributedlog/benchmark/stream/SyncReaderBenchmark.java
----------------------------------------------------------------------
diff --git 
a/distributedlog-benchmark/src/main/java/com/twitter/distributedlog/benchmark/stream/SyncReaderBenchmark.java
 
b/distributedlog-benchmark/src/main/java/com/twitter/distributedlog/benchmark/stream/SyncReaderBenchmark.java
index 3d5bd73..87006f4 100644
--- 
a/distributedlog-benchmark/src/main/java/com/twitter/distributedlog/benchmark/stream/SyncReaderBenchmark.java
+++ 
b/distributedlog-benchmark/src/main/java/com/twitter/distributedlog/benchmark/stream/SyncReaderBenchmark.java
@@ -119,6 +119,9 @@ public class SyncReaderBenchmark extends 
AbstractReaderBenchmark {
             LogRecord record;
             boolean nonBlocking = false;
             stopwatch = Stopwatch.createUnstarted();
+            long numCatchupReads = 0L;
+            long numCatchupBytes = 0L;
+            Stopwatch catchupStopwatch = Stopwatch.createStarted();
             while (true) {
                 try {
                     stopwatch.start();
@@ -128,6 +131,8 @@ public class SyncReaderBenchmark extends 
AbstractReaderBenchmark {
                         if (nonBlocking) {
                             
nonBlockingReadStats.registerSuccessfulEvent(elapsedMicros);
                         } else {
+                            numCatchupBytes += record.getPayload().length;
+                            ++numCatchupReads;
                             
blockingReadStats.registerSuccessfulEvent(elapsedMicros);
                         }
                         lastTxId = record.getTransactionId();
@@ -136,6 +141,9 @@ public class SyncReaderBenchmark extends 
AbstractReaderBenchmark {
                     }
                     if (null == record && !nonBlocking) {
                         nonBlocking = true;
+                        catchupStopwatch.stop();
+                        logger.info("Catchup {} records (total {} bytes) in {} 
milliseconds",
+                                new Object[] { numCatchupReads, 
numCatchupBytes, stopwatch.elapsed(TimeUnit.MILLISECONDS) });
                     }
                     stopwatch.reset();
                 } catch (IOException e) {

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/1feaeb43/distributedlog-core/src/main/java/com/twitter/distributedlog/BKSyncLogReaderDLSN.java
----------------------------------------------------------------------
diff --git 
a/distributedlog-core/src/main/java/com/twitter/distributedlog/BKSyncLogReaderDLSN.java
 
b/distributedlog-core/src/main/java/com/twitter/distributedlog/BKSyncLogReaderDLSN.java
index ded318c..f4ca45e 100644
--- 
a/distributedlog-core/src/main/java/com/twitter/distributedlog/BKSyncLogReaderDLSN.java
+++ 
b/distributedlog-core/src/main/java/com/twitter/distributedlog/BKSyncLogReaderDLSN.java
@@ -105,7 +105,6 @@ class BKSyncLogReaderDLSN implements LogReader, 
AsyncNotification {
             }
             // reader is caught up
             if (readHandler.isReadAheadCaughtUp()
-                    && null == entry
                     && null == readerException.get()) {
                 entry = readHandler.getNextReadAheadEntry(maxReadAheadWaitTime,
                         TimeUnit.MILLISECONDS);

Reply via email to