This is an automated email from the ASF dual-hosted git repository.

chenhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new ad06dfb2c0 Fix BenchReadThroughputLatency batch read can't stop 
problems. (#4220)
ad06dfb2c0 is described below

commit ad06dfb2c0658d15a46e1837a669cc05702e5350
Author: Yan Zhao <[email protected]>
AuthorDate: Mon Mar 18 11:03:42 2024 +0800

    Fix BenchReadThroughputLatency batch read can't stop problems. (#4220)
    
    Fix BenchReadThroughputLatency batch read can't stop problems.
---
 .../apache/bookkeeper/benchmark/BenchReadThroughputLatency.java   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java
 
b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java
index 5cd029b3c1..bfff2ed53d 100644
--- 
a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java
+++ 
b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java
@@ -79,7 +79,7 @@ public class BenchReadThroughputLatency {
         BookKeeper bk = null;
         long time = 0;
         long entriesRead = 0;
-        long lastRead = 0;
+        long lastRead = -1;
         int nochange = 0;
 
         long absoluteLimit = 5000000;
@@ -90,7 +90,7 @@ public class BenchReadThroughputLatency {
                 lh = bk.openLedgerNoRecovery(ledgerId, 
BookKeeper.DigestType.CRC32,
                                              passwd);
                 long lastConfirmed = Math.min(lh.getLastAddConfirmed(), 
absoluteLimit);
-                if (lastConfirmed == lastRead) {
+                if (lastConfirmed <= lastRead + 1) {
                     nochange++;
                     if (nochange == 10) {
                         break;
@@ -103,14 +103,14 @@ public class BenchReadThroughputLatency {
                 }
                 long starttime = System.nanoTime();
 
-                while (entriesRead <= lastConfirmed) {
+                while (lastRead < lastConfirmed) {
                     long nextLimit = lastRead + 100000;
                     Enumeration<LedgerEntry> entries;
                     if (batchEntries <= 0) {
                         long readTo = Math.min(nextLimit, lastConfirmed);
                         entries = lh.readEntries(lastRead + 1, readTo);
                     } else {
-                        entries = lh.batchReadEntries(lastRead, batchEntries, 
-1);
+                        entries = lh.batchReadEntries(lastRead + 1, 
batchEntries, -1);
                     }
                     while (entries.hasMoreElements()) {
                         LedgerEntry e = entries.nextElement();

Reply via email to