Skip to content

Commit beb1dfb

Browse files
committed
Cleanup
1 parent a982355 commit beb1dfb

17 files changed

+33
-34
lines changed

docs/metrics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ bucketlistDB-<X>.bulk.loads | meter | number of entries Buck
4444
bucketlistDB-live.bulk.inflationWinners | timer | time to load inflation winners
4545
bucketlistDB-live.bulk.poolshareTrustlines | timer | time to load poolshare trustlines by accountID and assetID
4646
bucketlistDB-live.bulk.prefetch | timer | time to prefetch
47-
bucketlistDB-<X>.point.<y> | timer | time to load single entry of type <Y> on BucketList <X> (live/hotArchive)
47+
bucketlistDB-<X>.point.<Y> | timer | time to load single entry of type <Y> on BucketList <X> (live/hotArchive)
4848
bucketlistDB-cache.hit | meter | number of cache hits on Live BucketList Disk random eviction cache
4949
bucketlistDB-cache.miss | meter | number of cache misses on Live BucketList Disk random eviction cache
5050
crypto.verify.hit | meter | number of signature cache hits

docs/stellar-core_example.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ BUCKETLIST_DB_CACHED_PERCENT = 25
247247
# Size, in MB, determining whether a bucket should have an individual
248248
# key index or a key range index. If bucket size is below this value, range
249249
# based index will be used. If set to 0, all buckets are range indexed. If
250-
# BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT == 0, value ingnored and all
250+
# BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT == 0, value ignored and all
251251
# buckets have individual key index.
252252
BUCKETLIST_DB_INDEX_CUTOFF = 250
253253

src/bucket/BucketIndexUtils.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ getPageSizeFromConfig(Config const& cfg)
3131
template <class BucketT>
3232
std::unique_ptr<typename BucketT::IndexT const>
3333
createIndex(BucketManager& bm, std::filesystem::path const& filename,
34-
Hash const& hash, asio::io_context& ctx,
35-
std::optional<SHA256>& hasher)
34+
Hash const& hash, asio::io_context& ctx, SHA256* hasher)
3635
{
3736
BUCKET_TYPE_ASSERT(BucketT);
3837

@@ -89,12 +88,12 @@ loadIndex(BucketManager const& bm, std::filesystem::path const& filename,
8988
template std::unique_ptr<typename LiveBucket::IndexT const>
9089
createIndex<LiveBucket>(BucketManager& bm,
9190
std::filesystem::path const& filename, Hash const& hash,
92-
asio::io_context& ctx, std::optional<SHA256>& hasher);
91+
asio::io_context& ctx, SHA256* hasher);
9392
template std::unique_ptr<typename HotArchiveBucket::IndexT const>
9493
createIndex<HotArchiveBucket>(BucketManager& bm,
9594
std::filesystem::path const& filename,
9695
Hash const& hash, asio::io_context& ctx,
97-
std::optional<SHA256>& hasher);
96+
SHA256* hasher);
9897

9998
template std::unique_ptr<typename LiveBucket::IndexT const>
10099
loadIndex<LiveBucket>(BucketManager const& bm,

src/bucket/BucketIndexUtils.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ std::streamoff getPageSizeFromConfig(Config const& cfg);
101101
template <class BucketT>
102102
std::unique_ptr<typename BucketT::IndexT const>
103103
createIndex(BucketManager& bm, std::filesystem::path const& filename,
104-
Hash const& hash, asio::io_context& ctx,
105-
std::optional<SHA256>& hasher);
104+
Hash const& hash, asio::io_context& ctx, SHA256* hasher);
106105

107106
// Loads index from given file. If file does not exist or if saved
108107
// index does not have expected version or pageSize, return null

src/bucket/BucketOutputIterator.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,8 @@ BucketOutputIterator<BucketT>::getBucket(BucketManager& bucketManager,
198198
if (auto b = bucketManager.getBucketIfExists<BucketT>(hash);
199199
!b || !b->isIndexed())
200200
{
201-
std::optional<SHA256> empty{};
202201
index =
203-
createIndex<BucketT>(bucketManager, mFilename, hash, mCtx, empty);
202+
createIndex<BucketT>(bucketManager, mFilename, hash, mCtx, nullptr);
204203
}
205204

206205
return bucketManager.adoptFileAsBucket<BucketT>(mFilename.string(), hash,

src/bucket/BucketUtils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ class EvictionStatistics
171171
EvictionCounters& counters);
172172
};
173173

174+
// Enum for more granular LedgerEntry types for Bucket metric reporting.
175+
// Specifically, this enum differentiates between TEMPORARY and PERSISTENT
176+
// CONTRACT_DATA types, which the regular LedgerEntryType enum does not.
174177
enum class LedgerEntryTypeAndDurability : uint32_t
175178
{
176179
ACCOUNT = 0,
@@ -187,6 +190,7 @@ enum class LedgerEntryTypeAndDurability : uint32_t
187190
NUM_TYPES = 11,
188191
};
189192

193+
// Metrics for BucketEntry state by LedgerEntryTypeAndDurability
190194
struct BucketEntryCounters
191195
{
192196
std::map<LedgerEntryTypeAndDurability, size_t> entryTypeCounts;

src/bucket/DiskIndex.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ DiskIndex<BucketT>::scan(IterT start, LedgerKey const& k) const
6565

6666
// Search for the key in the index before checking the bloom filter so we
6767
// return the correct iterator to the caller. This may be slightly less
68-
// effecient then checking the bloom filter first, but the filter's primary
68+
// efficient then checking the bloom filter first, but the filter's primary
6969
// purpose is to avoid disk lookups, not to avoid in-memory index search.
7070
auto keyIter =
7171
std::lower_bound(start, mData.keysToOffset.end(), k, lower_bound_pred);
@@ -120,8 +120,7 @@ template <class BucketT>
120120
DiskIndex<BucketT>::DiskIndex(BucketManager& bm,
121121
std::filesystem::path const& filename,
122122
std::streamoff pageSize, Hash const& hash,
123-
asio::io_context& ctx,
124-
std::optional<SHA256>& hasher)
123+
asio::io_context& ctx, SHA256* hasher)
125124
: mBloomLookupMeter(bm.getBloomLookupMeter<BucketT>())
126125
, mBloomMissMeter(bm.getBloomMissMeter<BucketT>())
127126
{
@@ -144,15 +143,14 @@ DiskIndex<BucketT>::DiskIndex(BucketManager& bm,
144143
std::streamoff pageUpperBound = 0;
145144
typename BucketT::EntryT be;
146145
size_t iter = 0;
147-
[[maybe_unused]] size_t count = 0;
146+
size_t count = 0;
148147

149148
std::vector<uint64_t> keyHashes;
150149
auto seed = shortHash::getShortHashInitKey();
151-
SHA256* hasherPtr = hasher.has_value() ? &hasher.value() : nullptr;
152150

153-
while (in && in.readOne(be, hasherPtr))
151+
while (in && in.readOne(be, hasher))
154152
{
155-
// peridocially check if bucket manager is exiting to stop indexing
153+
// periodically check if bucket manager is exiting to stop indexing
156154
// gracefully
157155
if (++iter >= 1000)
158156
{
@@ -240,6 +238,7 @@ DiskIndex<BucketT>::DiskIndex(BucketManager& bm,
240238
{
241239
mData.filter =
242240
std::make_unique<BinaryFuseFilter16>(keyHashes, seed);
241+
break;
243242
}
244243
catch (std::out_of_range& e)
245244
{
@@ -259,6 +258,9 @@ DiskIndex<BucketT>::DiskIndex(BucketManager& bm,
259258
seed[0]++;
260259
}
261260
}
261+
262+
// Population failure is probabilistic is very, very unlikely.
263+
releaseAssertOrThrow(mData.filter);
262264
}
263265

264266
CLOG_DEBUG(Bucket, "Indexed {} positions in {}", mData.keysToOffset.size(),

src/bucket/DiskIndex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ template <class BucketT> class DiskIndex : public NonMovableOrCopyable
120120
// Constructor for creating a fresh index.
121121
DiskIndex(BucketManager& bm, std::filesystem::path const& filename,
122122
std::streamoff pageSize, Hash const& hash, asio::io_context& ctx,
123-
std::optional<SHA256>& hasher);
123+
SHA256* hasher);
124124

125125
// Constructor for loading pre-existing index from disk. Must call preLoad
126126
// before calling this constructor to properly deserialize index.

src/bucket/HotArchiveBucketIndex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace stellar
1515

1616
HotArchiveBucketIndex::HotArchiveBucketIndex(
1717
BucketManager& bm, std::filesystem::path const& filename, Hash const& hash,
18-
asio::io_context& ctx, std::optional<SHA256>& hasher)
18+
asio::io_context& ctx, SHA256* hasher)
1919
: mDiskIndex(bm, filename, getPageSize(bm.getConfig(), 0), hash, ctx,
2020
hasher)
2121
{

src/bucket/HotArchiveBucketIndex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class HotArchiveBucketIndex : public NonMovableOrCopyable
5858
HotArchiveBucketIndex(BucketManager& bm,
5959
std::filesystem::path const& filename,
6060
Hash const& hash, asio::io_context& ctx,
61-
std::optional<SHA256>& hasher);
61+
SHA256* hasher);
6262

6363
template <class Archive>
6464
HotArchiveBucketIndex(BucketManager const& bm, Archive& ar,

0 commit comments

Comments
 (0)