Skip to content

Commit

Permalink
Merge pull request #4273 from SirTyson/bl-memory-fix
Browse files Browse the repository at this point in the history
Fix memory issue with individual indexes

Reviewed-by: marta-lokhova
  • Loading branch information
latobarita committed Apr 18, 2024
2 parents 07a1f55 + e6f9b7f commit 7b59b05
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/bucket/BucketIndexImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ BucketIndexImpl<IndexT>::BucketIndexImpl(BucketManager& bm,
xdr::xdr_traits<BucketEntry>::serial_size(BucketEntry{});
auto fileSize = fs::size(filename.string());
auto estimatedNumElems = fileSize / estimatedLedgerEntrySize;
size_t estimatedIndexEntries;

// Initialize bloom filter for range index
if constexpr (std::is_same<IndexT, RangeIndex>::value)
Expand All @@ -105,7 +104,7 @@ BucketIndexImpl<IndexT>::BucketIndexImpl(BucketManager& bm,
params.random_seed = shortHash::getShortHashInitKey();
params.compute_optimal_parameters();
mData.filter = std::make_unique<bloom_filter>(params);
estimatedIndexEntries = fileSize / mData.pageSize;
auto estimatedIndexEntries = fileSize / mData.pageSize;
CLOG_DEBUG(
Bucket,
"Bloom filter initialized with params: projected element count "
Expand All @@ -115,13 +114,11 @@ BucketIndexImpl<IndexT>::BucketIndexImpl(BucketManager& bm,
params.false_positive_probability,
params.optimal_parameters.number_of_hashes,
params.optimal_parameters.table_size);
}
else
{
estimatedIndexEntries = estimatedNumElems;
}

mData.keysToOffset.reserve(estimatedIndexEntries);
// We don't have a good way of estimating IndividualIndex size, so
// only reserve range indexes
mData.keysToOffset.reserve(estimatedIndexEntries);
}

XDRInputFileStream in;
in.open(filename.string());
Expand Down

0 comments on commit 7b59b05

Please sign in to comment.