Skip to content

Commit

Permalink
Wait on merges in apply-load
Browse files Browse the repository at this point in the history
  • Loading branch information
sisuresh committed Nov 8, 2024
1 parent 7023383 commit efb1642
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/bucket/BucketList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,21 @@ BucketList::getLevel(uint32_t i)
return mLevels.at(i);
}

#ifdef BUILD_TESTS
void
BucketList::resolveAllFutures()
{
ZoneScoped;
for (auto& level : mLevels)
{
if (level.getNext().isMerging())
{
level.getNext().resolve();
}
}
}
#endif

void
BucketList::resolveAnyReadyFutures()
{
Expand Down
6 changes: 6 additions & 0 deletions src/bucket/BucketList.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,12 @@ class BucketList
// HistoryArchiveStates, that can cause repeated merges when re-activated.
void resolveAnyReadyFutures();

#ifdef BUILD_TESTS
// Same as the function above, except we don't check if the buckets are
// done merging.
void resolveAllFutures();
#endif

// returns true if levels [0, maxLevel] are resolved
bool futuresAllResolved(uint32_t maxLevel = kNumLevels - 1) const;

Expand Down
5 changes: 5 additions & 0 deletions src/main/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1884,6 +1884,7 @@ runApplyLoad(CommandLineArgs const& args)
[&] {
auto config = configOption.getConfig();
config.RUN_STANDALONE = true;
config.MANUAL_CLOSE = true;
config.USE_CONFIG_FOR_GENESIS = true;
config.TESTING_UPGRADE_MAX_TX_SET_SIZE = 1000;
config.LEDGER_PROTOCOL_VERSION =
Expand Down Expand Up @@ -1926,6 +1927,10 @@ runApplyLoad(CommandLineArgs const& args)

for (size_t i = 0; i < 100; ++i)
{
app.getBucketManager().getBucketList().resolveAllFutures();
releaseAssert(app.getBucketManager()
.getBucketList()
.futuresAllResolved());
al.benchmark();
}

Expand Down
5 changes: 4 additions & 1 deletion src/simulation/test/LoadGeneratorTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,6 @@ TEST_CASE("apply load", "[loadgen][applyload]")

VirtualClock clock(VirtualClock::REAL_TIME);
auto app = createTestApplication(clock, cfg);
auto const& lm = app->getLedgerManager();

uint64_t ledgerMaxInstructions = 500'000'000;
uint64_t ledgerMaxReadLedgerEntries = 2000;
Expand Down Expand Up @@ -871,6 +870,10 @@ TEST_CASE("apply load", "[loadgen][applyload]")
cpuInsRatioExclVm.Clear();
for (size_t i = 0; i < 100; ++i)
{
app->getBucketManager().getBucketList().resolveAllFutures();
releaseAssert(
app->getBucketManager().getBucketList().futuresAllResolved());

al.benchmark();
}
REQUIRE(al.successRate() - 1.0 < std::numeric_limits<double>::epsilon());
Expand Down

0 comments on commit efb1642

Please sign in to comment.