Skip to content

Commit

Permalink
Wait on merges in apply-load (#4538)
Browse files Browse the repository at this point in the history
# Description

Related to #4520.

The goal here is to make sure buckets aren't being merged during calls
to `benchmark`.

<!---

Describe what this pull request does, which issue it's resolving
(usually applicable for code changes).

--->

# Checklist
- [ ] Reviewed the
[contributing](https://github.com/stellar/stellar-core/blob/master/CONTRIBUTING.md#submitting-changes)
document
- [ ] Rebased on top of master (no merge commits)
- [ ] Ran `clang-format` v8.0.0 (via `make format` or the Visual Studio
extension)
- [ ] Compiles
- [ ] 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)
  • Loading branch information
sisuresh authored Nov 9, 2024
2 parents 7023383 + efb1642 commit 0579fd9
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 0579fd9

Please sign in to comment.