Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add metric for rocksdb getLastEntryInLedger to help find out bottleneck #4529

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,16 @@ public long getLastEntryInLedger(long ledgerId) throws IOException {
private long getLastEntryInLedgerInternal(long ledgerId) throws IOException {
LongPairWrapper maxEntryId = LongPairWrapper.get(ledgerId, Long.MAX_VALUE);

long startTimeNanos = MathUtils.nowInNano();
// Search the last entry in storage
Entry<byte[], byte[]> entry = locationsDb.getFloor(maxEntryId.array);
if (entry != null) {
stats.getGetLastEntryInLedgerStats()
.registerSuccessfulEvent(MathUtils.elapsedNanos(startTimeNanos), TimeUnit.NANOSECONDS);
} else {
stats.getGetLastEntryInLedgerStats()
.registerFailedEvent(MathUtils.elapsedNanos(startTimeNanos), TimeUnit.NANOSECONDS);
}
maxEntryId.recycle();

if (entry == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class EntryLocationIndexStats {

private static final String ENTRIES_COUNT = "entries-count";
private static final String LOOKUP_ENTRY_LOCATION = "lookup-entry-location";
private static final String GET_LAST_ENTRY_IN_LEDGER = "get-last-entry-in-ledger";

@StatsDoc(
name = ENTRIES_COUNT,
Expand All @@ -55,6 +56,12 @@ class EntryLocationIndexStats {
)
private final OpStatsLogger lookupEntryLocationStats;

@StatsDoc(
name = GET_LAST_ENTRY_IN_LEDGER,
help = "operation stats of get last entry in ledger"
)
private final OpStatsLogger getLastEntryInLedgerStats;

EntryLocationIndexStats(StatsLogger statsLogger,
Supplier<Long> entriesCountSupplier) {
entriesCountGauge = new Gauge<Long>() {
Expand All @@ -70,6 +77,7 @@ public Long getSample() {
};
statsLogger.registerGauge(ENTRIES_COUNT, entriesCountGauge);
lookupEntryLocationStats = statsLogger.getOpStatsLogger(LOOKUP_ENTRY_LOCATION);
getLastEntryInLedgerStats = statsLogger.getOpStatsLogger(GET_LAST_ENTRY_IN_LEDGER);
}

}
Loading