This is an automated email from the ASF dual-hosted git repository.
ayegorov pushed a commit to branch branch-4.14
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/branch-4.14 by this push:
new 4f7bebb86d add rocksDB get latency and read from storage latency for
entry reading (#3647)
4f7bebb86d is described below
commit 4f7bebb86d67d8be429b25b4f1aa762227b9864b
Author: Hang Chen <[email protected]>
AuthorDate: Sat Nov 19 08:06:06 2022 +0800
add rocksDB get latency and read from storage latency for entry reading
(#3647)
---
.../bookie/storage/ldb/DbLedgerStorageStats.java | 18 ++++++++++++++++++
.../storage/ldb/SingleDirectoryDbLedgerStorage.java | 12 ++++++++++++
2 files changed, 30 insertions(+)
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/DbLedgerStorageStats.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/DbLedgerStorageStats.java
index f8c5c71a11..cff14d0f72 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/DbLedgerStorageStats.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/DbLedgerStorageStats.java
@@ -44,6 +44,8 @@ class DbLedgerStorageStats {
private static final String ADD_ENTRY = "add-entry";
private static final String READ_ENTRY = "read-entry";
+ private static final String READ_ENTRY_LOCATIONS_INDEX_TIME =
"read-locations-index-time";
+ private static final String READ_ENTRYLOG_TIME = "read-entrylog-time";
private static final String READ_CACHE_HITS = "read-cache-hits";
private static final String READ_CACHE_MISSES = "read-cache-misses";
private static final String READAHEAD_BATCH_COUNT =
"readahead-batch-count";
@@ -73,6 +75,20 @@ class DbLedgerStorageStats {
parent = BOOKIE_ADD_ENTRY
)
private final OpStatsLogger readEntryStats;
+
+ @StatsDoc(
+ name = READ_ENTRY_LOCATIONS_INDEX_TIME,
+ help = "time spent reading entries from the locations index of the
db ledger storage engine",
+ parent = READ_ENTRY
+ )
+ private final OpStatsLogger readFromLocationIndexTime;
+
+ @StatsDoc(
+ name = READ_ENTRYLOG_TIME,
+ help = "time spent reading entries from the entry log files of the db
ledger storage engine",
+ parent = READ_ENTRY
+ )
+ private final OpStatsLogger readFromEntryLogTime;
@StatsDoc(
name = READ_CACHE_HITS,
help = "operation stats of read cache hits",
@@ -149,6 +165,8 @@ class DbLedgerStorageStats {
Supplier<Long> readCacheCountSupplier) {
addEntryStats = stats.getOpStatsLogger(ADD_ENTRY);
readEntryStats = stats.getOpStatsLogger(READ_ENTRY);
+ readFromLocationIndexTime =
stats.getOpStatsLogger(READ_ENTRY_LOCATIONS_INDEX_TIME);
+ readFromEntryLogTime = stats.getOpStatsLogger(READ_ENTRYLOG_TIME);
readCacheHitStats = stats.getOpStatsLogger(READ_CACHE_HITS);
readCacheMissStats = stats.getOpStatsLogger(READ_CACHE_MISSES);
readAheadBatchCountStats =
stats.getOpStatsLogger(READAHEAD_BATCH_COUNT);
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java
index 74bbcabc13..0c6b0be1c2 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java
@@ -448,15 +448,27 @@ public class SingleDirectoryDbLedgerStorage implements
CompactableLedgerStorage
// Read from main storage
long entryLocation;
+ long locationIndexStartNano = MathUtils.nowInNano();
try {
entryLocation = entryLocationIndex.getLocation(ledgerId, entryId);
if (entryLocation == 0) {
+ recordFailedEvent(dbLedgerStorageStats.getReadEntryStats(),
startTime);
throw new NoEntryException(ledgerId, entryId);
}
+ } finally {
+
dbLedgerStorageStats.getReadFromLocationIndexTime().registerSuccessfulEvent(
+ MathUtils.elapsedNanos(locationIndexStartNano),
TimeUnit.NANOSECONDS);
+ }
+
+ long readEntryStartNano = MathUtils.nowInNano();
+ try {
entry = entryLogger.readEntry(ledgerId, entryId, entryLocation);
} catch (NoEntryException e) {
recordFailedEvent(dbLedgerStorageStats.getReadEntryStats(),
startTime);
throw e;
+ } finally {
+
dbLedgerStorageStats.getReadFromEntryLogTime().registerSuccessfulEvent(
+ MathUtils.elapsedNanos(readEntryStartNano),
TimeUnit.NANOSECONDS);
}
readCache.put(ledgerId, entryId, entry);