diff --git a/src/bucket/BucketSnapshotManager.cpp b/src/bucket/BucketSnapshotManager.cpp index 0cad98addf..9d9918cd16 100644 --- a/src/bucket/BucketSnapshotManager.cpp +++ b/src/bucket/BucketSnapshotManager.cpp @@ -13,7 +13,9 @@ #include "medida/meter.h" #include "medida/metrics_registry.h" +#include "xdr/Stellar-ledger-entries.h" #include +#include namespace stellar { @@ -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::enum_values()) + { + auto const& label = xdr::xdr_traits::enum_name( + static_cast(t)); + auto& metric = + mApp.getMetrics().NewTimer({"bucketlistDB", "point", label}); + mPointTimers.emplace(static_cast(t), metric); + } } std::shared_ptr @@ -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::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); } } diff --git a/src/bucket/SearchableBucketList.cpp b/src/bucket/SearchableBucketList.cpp index dd49a424c0..15b6e4792b 100644 --- a/src/bucket/SearchableBucketList.cpp +++ b/src/bucket/SearchableBucketList.cpp @@ -5,6 +5,7 @@ #include "bucket/SearchableBucketList.h" #include "bucket/BucketInputIterator.h" #include "bucket/BucketListSnapshotBase.h" +#include "util/GlobalChecks.h" #include @@ -244,6 +245,16 @@ SearchableLiveBucketListSnapshot::loadKeysWithLimits( std::set 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);