Skip to content

Commit 076a635

Browse files
authored
Fix TPS/TPL conversion for max-sac-tps. (#5259)
# Description The search boundaries are defined as 'TPS', but in some places they were interpreted as TPL which led to assertion failures in some cases and always incorrect logging. # 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)
2 parents 735f72b + f2dd315 commit 076a635

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

src/simulation/ApplyLoad.cpp

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,12 @@ getUpgradeConfigForMaxTPS(Config const& cfg, uint64_t instructionsPerCluster,
280280

281281
return upgradeConfig;
282282
}
283+
284+
uint32_t
285+
convertTPStoTPL(uint32_t tps, uint32_t closeTimeMs)
286+
{
287+
return static_cast<uint32_t>(std::ceil(tps * closeTimeMs / 1000.0));
288+
}
283289
} // namespace
284290

285291
/*
@@ -700,9 +706,9 @@ ApplyLoad::ApplyLoad(Application& app)
700706
2;
701707
break;
702708
case ApplyLoadMode::MAX_SAC_TPS:
703-
mNumAccounts = config.APPLY_LOAD_MAX_SAC_TPS_MAX_TPS *
704-
config.SOROBAN_TRANSACTION_QUEUE_SIZE_MULTIPLIER *
705-
config.APPLY_LOAD_TARGET_CLOSE_TIME_MS / 1000.0 +
709+
mNumAccounts = convertTPStoTPL(config.APPLY_LOAD_MAX_SAC_TPS_MAX_TPS,
710+
config.APPLY_LOAD_TARGET_CLOSE_TIME_MS) *
711+
config.SOROBAN_TRANSACTION_QUEUE_SIZE_MULTIPLIER +
706712
config.APPLY_LOAD_CLASSIC_TXS_PER_LEDGER;
707713
break;
708714
case ApplyLoadMode::BENCHMARK_MODEL_TX:
@@ -1125,7 +1131,9 @@ ApplyLoad::setupBatchTransferContracts()
11251131
// We need to transfer enough XLM to cover all batch transfers
11261132
// Each batch will transfer APPLY_LOAD_BATCH_SAC_COUNT * 1 stroop
11271133
int64_t maxTxsPerCluster =
1128-
mApp.getConfig().APPLY_LOAD_MAX_SAC_TPS_MAX_TPS / numClusters;
1134+
convertTPStoTPL(mApp.getConfig().APPLY_LOAD_MAX_SAC_TPS_MAX_TPS,
1135+
mApp.getConfig().APPLY_LOAD_TARGET_CLOSE_TIME_MS) /
1136+
numClusters;
11291137
int64_t amountToTransfer =
11301138
mApp.getConfig().APPLY_LOAD_BATCH_SAC_COUNT * // Sent per tx
11311139
maxTxsPerCluster * // Max txs per ledger per cluster
@@ -1626,10 +1634,14 @@ ApplyLoad::findMaxSacTps()
16261634
txsPerStep;
16271635
}
16281636
uint32_t minSteps = std::max(
1629-
1u, mApp.getConfig().APPLY_LOAD_MAX_SAC_TPS_MIN_TPS / txsPerStep);
1630-
uint32_t maxSteps = std::ceil(
1631-
static_cast<double>(mApp.getConfig().APPLY_LOAD_MAX_SAC_TPS_MAX_TPS) /
1632-
txsPerStep);
1637+
1u, convertTPStoTPL(mApp.getConfig().APPLY_LOAD_MAX_SAC_TPS_MIN_TPS,
1638+
mApp.getConfig().APPLY_LOAD_TARGET_CLOSE_TIME_MS) /
1639+
txsPerStep);
1640+
uint32_t maxSteps =
1641+
std::ceil(static_cast<double>(convertTPStoTPL(
1642+
mApp.getConfig().APPLY_LOAD_MAX_SAC_TPS_MAX_TPS,
1643+
mApp.getConfig().APPLY_LOAD_TARGET_CLOSE_TIME_MS)) /
1644+
txsPerStep);
16331645

16341646
double targetCloseTimeMs = mApp.getConfig().APPLY_LOAD_TARGET_CLOSE_TIME_MS;
16351647

src/simulation/test/LoadGeneratorTests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,10 +1071,10 @@ TEST_CASE("apply load find max SAC TPS",
10711071
cfg.GENESIS_TEST_ACCOUNT_COUNT = 10000;
10721072

10731073
// Configure test parameters for MAX_SAC_TPS mode
1074-
cfg.APPLY_LOAD_TARGET_CLOSE_TIME_MS = 1500;
1074+
cfg.APPLY_LOAD_TARGET_CLOSE_TIME_MS = 300;
10751075
cfg.APPLY_LOAD_LEDGER_MAX_DEPENDENT_TX_CLUSTERS = 2;
1076-
cfg.APPLY_LOAD_MAX_SAC_TPS_MIN_TPS = 1;
1077-
cfg.APPLY_LOAD_MAX_SAC_TPS_MAX_TPS = 1500;
1076+
cfg.APPLY_LOAD_MAX_SAC_TPS_MIN_TPS = 1000;
1077+
cfg.APPLY_LOAD_MAX_SAC_TPS_MAX_TPS = 2000;
10781078
cfg.APPLY_LOAD_NUM_LEDGERS = 30;
10791079
cfg.APPLY_LOAD_BATCH_SAC_COUNT = 2;
10801080
cfg.APPLY_LOAD_CLASSIC_TXS_PER_LEDGER = 100;

0 commit comments

Comments
 (0)