Skip to content

Commit 6bacbf2

Browse files
authored
Improve binary search for apply-load. (#5123)
# Description The binary search uses t-statistic to ensure the necessary confidence at each step. This results in needing less samples far away from the true value and more samples around it. We still need at least 30 samples though to keep math simple. This works reasonably well, but still doesn't avoid some fundamental variance issues that we have that result in very different and statistically significant performance difference between different runs. That concern should hopefully be addressed separately. Also fix some SAC max TPS benchmark issues, the math got messed up after I've updated it from 1s granularity to 50ms. # 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 c69069e + 229867f commit 6bacbf2

7 files changed

Lines changed: 759 additions & 174 deletions

File tree

Builds/VisualStudio/stellar-core.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ exit /b 0
577577
<ClCompile Include="..\..\src\invariant\AccountSubEntriesCountIsValid.cpp" />
578578
<ClCompile Include="..\..\src\invariant\ArchivedStateConsistency.cpp" />
579579
<ClCompile Include="..\..\src\invariant\BucketListIsConsistentWithDatabase.cpp" />
580+
<ClCompile Include="..\..\src\invariant\BucketListStateConsistency.cpp" />
580581
<ClCompile Include="..\..\src\invariant\ConservationOfLumens.cpp" />
581582
<ClCompile Include="..\..\src\invariant\ConstantProductInvariant.cpp" />
582583
<ClCompile Include="..\..\src\invariant\EventsAreConsistentWithEntryDiffs.cpp" />
@@ -1044,6 +1045,7 @@ exit /b 0
10441045
<ClInclude Include="..\..\src\invariant\AccountSubEntriesCountIsValid.h" />
10451046
<ClInclude Include="..\..\src\invariant\ArchivedStateConsistency.h" />
10461047
<ClInclude Include="..\..\src\invariant\BucketListIsConsistentWithDatabase.h" />
1048+
<ClInclude Include="..\..\src\invariant\BucketListStateConsistency.h" />
10471049
<ClInclude Include="..\..\src\invariant\ConservationOfLumens.h" />
10481050
<ClInclude Include="..\..\src\invariant\ConstantProductInvariant.h" />
10491051
<ClInclude Include="..\..\src\invariant\EventsAreConsistentWithEntryDiffs.h" />

Builds/VisualStudio/stellar-core.vcxproj.filters

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,12 @@
14201420
<ClCompile Include="..\..\src\invariant\ArchivedStateConsistency.cpp">
14211421
<Filter>invariant</Filter>
14221422
</ClCompile>
1423+
<ClCompile Include="..\..\src\ledger\LedgerEntryScope.cpp" />
1424+
<ClCompile Include="..\..\src\util\MetricsRegistry.cpp" />
1425+
<ClCompile Include="..\..\src\util\SimpleTimer.cpp" />
1426+
<ClCompile Include="..\..\src\invariant\BucketListStateConsistency.cpp">
1427+
<Filter>invariant</Filter>
1428+
</ClCompile>
14231429
</ItemGroup>
14241430
<ItemGroup>
14251431
<ClInclude Include="..\..\lib\util\cpptoml.h">
@@ -2518,6 +2524,12 @@
25182524
<ClInclude Include="..\..\src\invariant\ArchivedStateConsistency.h">
25192525
<Filter>invariant</Filter>
25202526
</ClInclude>
2527+
<ClInclude Include="..\..\src\ledger\LedgerEntryScope.h" />
2528+
<ClInclude Include="..\..\src\util\MetricsRegistry.h" />
2529+
<ClInclude Include="..\..\src\util\SimpleTimer.h" />
2530+
<ClInclude Include="..\..\src\invariant\BucketListStateConsistency.h">
2531+
<Filter>invariant</Filter>
2532+
</ClInclude>
25212533
</ItemGroup>
25222534
<ItemGroup>
25232535
<None Include="..\..\AUTHORS" />

src/main/CommandLine.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,19 +1897,20 @@ runApplyLoad(CommandLineArgs const& args)
18971897
config.TESTING_UPGRADE_MAX_TX_SET_SIZE = 1000;
18981898
config.LEDGER_PROTOCOL_VERSION =
18991899
Config::CURRENT_LEDGER_PROTOCOL_VERSION;
1900-
if (config.APPLY_LOAD_NUM_LEDGERS == 0)
1900+
if (config.APPLY_LOAD_NUM_LEDGERS < 30)
19011901
{
19021902
throw std::runtime_error(
1903-
"APPLY_LOAD_NUM_LEDGERS must be greater than 0");
1903+
"APPLY_LOAD_NUM_LEDGERS must be at least 30");
19041904
}
19051905
if (mode == ApplyLoadMode::MAX_SAC_TPS)
19061906
{
1907-
if (config.APPLY_LOAD_MAX_SAC_TPS_MIN_TPS >=
1907+
if (config.APPLY_LOAD_MAX_SAC_TPS_MIN_TPS >
19081908
config.APPLY_LOAD_MAX_SAC_TPS_MAX_TPS)
19091909
{
19101910
throw std::runtime_error(
1911-
"APPLY_LOAD_MAX_SAC_TPS_MIN_TPS must be less than "
1912-
"APPLY_LOAD_MAX_SAC_TPS_MAX_TPS for max_sac_tps mode");
1911+
"APPLY_LOAD_MAX_SAC_TPS_MIN_TPS must not be greater "
1912+
"than APPLY_LOAD_MAX_SAC_TPS_MAX_TPS for max_sac_tps "
1913+
"mode");
19131914
}
19141915

19151916
// For now, metrics are expensive at high, parallel load. We

src/main/Config.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,15 +1752,6 @@ Config::processConfig(std::shared_ptr<cpptoml::table> t)
17521752
[&]() {
17531753
APPLY_LOAD_TARGET_CLOSE_TIME_MS =
17541754
readInt<uint32_t>(item, 1);
1755-
if (APPLY_LOAD_TARGET_CLOSE_TIME_MS %
1756-
ApplyLoad::TARGET_CLOSE_TIME_STEP_MS !=
1757-
0)
1758-
{
1759-
throw std::invalid_argument(fmt::format(
1760-
FMT_STRING("APPLY_LOAD_TARGET_CLOSE_TIME_MS "
1761-
"must be a multiple of {}."),
1762-
ApplyLoad::TARGET_CLOSE_TIME_STEP_MS));
1763-
}
17641755
}},
17651756
{"APPLY_LOAD_MAX_SAC_TPS_MIN_TPS",
17661757
[&]() {

0 commit comments

Comments
 (0)