Skip to content

Commit

Permalink
Fixed prefetch metric and intialized all point load metrics on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
SirTyson committed Dec 6, 2024
1 parent fdd833d commit 50e44b0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/bucket/BucketSnapshotManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

#include "medida/meter.h"
#include "medida/metrics_registry.h"
#include "xdr/Stellar-ledger-entries.h"
#include <shared_mutex>
#include <xdrpp/types.h>

namespace stellar
{
Expand All @@ -38,6 +40,16 @@ BucketSnapshotManager::BucketSnapshotManager(
releaseAssert(threadIsMain());
releaseAssert(mCurrLiveSnapshot);
releaseAssert(mCurrHotArchiveSnapshot);

// Initialize point load timers for each LedgerEntry type
for (auto t : xdr::xdr_traits<LedgerEntryType>::enum_values())
{
auto const& label = xdr::xdr_traits<LedgerEntryType>::enum_name(
static_cast<LedgerEntryType>(t));
auto& metric =
mApp.getMetrics().NewTimer({"bucketlistDB", "point", label});
mPointTimers.emplace(static_cast<LedgerEntryType>(t), metric);
}
}

std::shared_ptr<SearchableLiveBucketListSnapshot>
Expand Down Expand Up @@ -215,14 +227,7 @@ BucketSnapshotManager::endPointLoadTimer(LedgerEntryType t,
if (!bloomMiss)
{
auto iter = mPointTimers.find(t);
if (iter == mPointTimers.end())
{
auto const& label = xdr::xdr_traits<LedgerEntryType>::enum_name(t);
auto& metric =
mApp.getMetrics().NewTimer({"bucketlistDB", "point", label});
iter = mPointTimers.emplace(t, metric).first;
}

releaseAssert(iter != mPointTimers.end());
iter->second.Update(duration);
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/bucket/SearchableBucketList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "bucket/SearchableBucketList.h"
#include "bucket/BucketInputIterator.h"
#include "bucket/BucketListSnapshotBase.h"
#include "util/GlobalChecks.h"

#include <medida/timer.h>

Expand Down Expand Up @@ -244,6 +245,16 @@ SearchableLiveBucketListSnapshot::loadKeysWithLimits(
std::set<LedgerKey, LedgerEntryIdCmp> const& inKeys,
LedgerKeyMeter* lkMeter)
{
if (threadIsMain())
{
auto timer =
mSnapshotManager.recordBulkLoadMetrics("prefetch", inKeys.size())
.TimeScope();
auto op = loadKeysInternal(inKeys, lkMeter, std::nullopt);
releaseAssertOrThrow(op);
return std::move(*op);
}

auto op = loadKeysInternal(inKeys, lkMeter, std::nullopt);
releaseAssertOrThrow(op);
return std::move(*op);
Expand Down

0 comments on commit 50e44b0

Please sign in to comment.