Skip to content

Commit 73fa340

Browse files
Fixed prefetch metric and intialized all point load metrics on startup (#4568)
# Description Resolves #4566 # Checklist - [x] Reviewed the [contributing](https://github.com/stellar/stellar-core/blob/master/CONTRIBUTING.md#submitting-changes) document - [x] Rebased on top of master (no merge commits) - [x] Ran `clang-format` v8.0.0 (via `make format` or the Visual Studio extension) - [x] Compiles - [x] Ran all tests - [ ] If change impacts performance, include supporting evidence per the [performance document](https://github.com/stellar/stellar-core/blob/master/performance-eval/performance-eval.md)
2 parents e3c7a81 + 50e44b0 commit 73fa340

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/bucket/BucketSnapshotManager.cpp

+13-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414
#include "medida/meter.h"
1515
#include "medida/metrics_registry.h"
16+
#include "xdr/Stellar-ledger-entries.h"
1617
#include <shared_mutex>
18+
#include <xdrpp/types.h>
1719

1820
namespace stellar
1921
{
@@ -38,6 +40,16 @@ BucketSnapshotManager::BucketSnapshotManager(
3840
releaseAssert(threadIsMain());
3941
releaseAssert(mCurrLiveSnapshot);
4042
releaseAssert(mCurrHotArchiveSnapshot);
43+
44+
// Initialize point load timers for each LedgerEntry type
45+
for (auto t : xdr::xdr_traits<LedgerEntryType>::enum_values())
46+
{
47+
auto const& label = xdr::xdr_traits<LedgerEntryType>::enum_name(
48+
static_cast<LedgerEntryType>(t));
49+
auto& metric =
50+
mApp.getMetrics().NewTimer({"bucketlistDB", "point", label});
51+
mPointTimers.emplace(static_cast<LedgerEntryType>(t), metric);
52+
}
4153
}
4254

4355
std::shared_ptr<SearchableLiveBucketListSnapshot>
@@ -215,14 +227,7 @@ BucketSnapshotManager::endPointLoadTimer(LedgerEntryType t,
215227
if (!bloomMiss)
216228
{
217229
auto iter = mPointTimers.find(t);
218-
if (iter == mPointTimers.end())
219-
{
220-
auto const& label = xdr::xdr_traits<LedgerEntryType>::enum_name(t);
221-
auto& metric =
222-
mApp.getMetrics().NewTimer({"bucketlistDB", "point", label});
223-
iter = mPointTimers.emplace(t, metric).first;
224-
}
225-
230+
releaseAssert(iter != mPointTimers.end());
226231
iter->second.Update(duration);
227232
}
228233
}

src/bucket/SearchableBucketList.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "bucket/SearchableBucketList.h"
66
#include "bucket/BucketInputIterator.h"
77
#include "bucket/BucketListSnapshotBase.h"
8+
#include "util/GlobalChecks.h"
89

910
#include <medida/timer.h>
1011

@@ -244,6 +245,16 @@ SearchableLiveBucketListSnapshot::loadKeysWithLimits(
244245
std::set<LedgerKey, LedgerEntryIdCmp> const& inKeys,
245246
LedgerKeyMeter* lkMeter)
246247
{
248+
if (threadIsMain())
249+
{
250+
auto timer =
251+
mSnapshotManager.recordBulkLoadMetrics("prefetch", inKeys.size())
252+
.TimeScope();
253+
auto op = loadKeysInternal(inKeys, lkMeter, std::nullopt);
254+
releaseAssertOrThrow(op);
255+
return std::move(*op);
256+
}
257+
247258
auto op = loadKeysInternal(inKeys, lkMeter, std::nullopt);
248259
releaseAssertOrThrow(op);
249260
return std::move(*op);

0 commit comments

Comments
 (0)