Skip to content

Commit 08e165b

Browse files
authored
Added batched max_sac_tps configs (#4941)
# Description Adds a batched payments setting to max_sac_tps. In initial testing, it looks like SAC apply time is bounded by single threaded pre and post invoke steps. Since the instructions required for a single SAC payment are small and invocation time is dominated by these pre and post invoke steps, we saw little improvement with parallelism when measuring SAC payment load. This PR adds batching functionality, where a single TX will perform many SAC transfers. This increases the instruction count significantly, which we can do in parallel, while not increasing the single threaded pre and post invoke work. Config settings have been added to tune the number of batch payments made per TX. Note that for the purposes of measurement and reporting, "TPS" really refers to "SAC transfers per second" in the batch payment case. I've also added the `APPLY_LOAD_TIME_WRITES` flag. When set, we count BucketList write time when calculating max TPS. Currently a draft until stellar/rs-soroban-env#1595 merges, then I'll update the cargo accordingly. # Checklist - [x] Reviewed the [contributing](https://github.com/stellar/stellar-core/blob/master/CONTRIBUTING.md#submitting-changes) document - [x] Rebased on top of master (no merge commits) - [x] Ran `clang-format` v8.0.0 (via `make format` or the Visual Studio extension) - [x] Compiles - [x] 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 5239184 + 4319e05 commit 08e165b

File tree

14 files changed

+426
-91
lines changed

14 files changed

+426
-91
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/Config.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,11 +1681,6 @@ Config::processConfig(std::shared_ptr<cpptoml::table> t)
16811681
APPLY_LOAD_MAX_SAC_TPS_TARGET_CLOSE_TIME_MS =
16821682
readInt<uint32_t>(item, 10);
16831683
}},
1684-
{"APPLY_LOAD_MAX_SAC_TPS_TEST_ITERATIONS",
1685-
[&]() {
1686-
APPLY_LOAD_MAX_SAC_TPS_TEST_ITERATIONS =
1687-
readInt<uint32_t>(item);
1688-
}},
16891684
{"APPLY_LOAD_MAX_SAC_TPS_MIN_TPS",
16901685
[&]() {
16911686
APPLY_LOAD_MAX_SAC_TPS_MIN_TPS = readInt<uint32_t>(item);
@@ -1694,6 +1689,12 @@ Config::processConfig(std::shared_ptr<cpptoml::table> t)
16941689
[&]() {
16951690
APPLY_LOAD_MAX_SAC_TPS_MAX_TPS = readInt<uint32_t>(item);
16961691
}},
1692+
{"APPLY_LOAD_BATCH_SAC_COUNT",
1693+
[&]() {
1694+
APPLY_LOAD_BATCH_SAC_COUNT = readInt<uint32_t>(item, 1);
1695+
}},
1696+
{"APPLY_LOAD_TIME_WRITES",
1697+
[&]() { APPLY_LOAD_TIME_WRITES = readBool(item); }},
16971698
{"GENESIS_TEST_ACCOUNT_COUNT",
16981699
[&]() {
16991700
GENESIS_TEST_ACCOUNT_COUNT = readInt<uint32_t>(item, 0);

src/main/Config.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,6 @@ class Config : public std::enable_shared_from_this<Config>
387387
uint32_t APPLY_LOAD_NUM_ACCOUNTS = 0;
388388
uint32_t APPLY_LOAD_NUM_LEDGERS = 100;
389389

390-
// MAX_SAC_TPS mode specific parameters
391-
uint32_t APPLY_LOAD_MAX_SAC_TPS_TARGET_CLOSE_TIME_MS = 1000;
392-
uint32_t APPLY_LOAD_MAX_SAC_TPS_TEST_ITERATIONS = 3;
393-
uint32_t APPLY_LOAD_MAX_SAC_TPS_MIN_TPS = 100;
394-
uint32_t APPLY_LOAD_MAX_SAC_TPS_MAX_TPS = 50000;
395-
396390
// Number of read-only and read-write entries in the apply-load
397391
// transactions. Every entry will have
398392
// `APPLY_LOAD_DATA_ENTRY_SIZE_FOR_TESTING` size.
@@ -405,6 +399,22 @@ class Config : public std::enable_shared_from_this<Config>
405399
std::vector<uint32_t> APPLY_LOAD_EVENT_COUNT_FOR_TESTING;
406400
std::vector<uint32_t> APPLY_LOAD_EVENT_COUNT_DISTRIBUTION_FOR_TESTING;
407401

402+
// MAX_SAC_TPS mode specific parameters
403+
uint32_t APPLY_LOAD_MAX_SAC_TPS_TARGET_CLOSE_TIME_MS = 1000;
404+
uint32_t APPLY_LOAD_MAX_SAC_TPS_MIN_TPS = 100;
405+
uint32_t APPLY_LOAD_MAX_SAC_TPS_MAX_TPS = 50000;
406+
407+
// Number of SAC payments to include in each tx for MAX_SAC_TPS mode.
408+
// If set to 1, each TX will be a single SAC invocation.
409+
// If set to > 1, each TX will invoke the specified number of SAC sub
410+
// invocations. Note that TPS measurement count each SAC invocation as one
411+
// "transaction".
412+
uint32_t APPLY_LOAD_BATCH_SAC_COUNT = 1;
413+
414+
// If set to true, database writes will count towards TPS calculation.
415+
// Otherwise, BucketList writes will not be counted.
416+
bool APPLY_LOAD_TIME_WRITES = true;
417+
408418
// Waits for merges to complete before applying transactions during catchup
409419
bool CATCHUP_WAIT_MERGES_TX_APPLY_FOR_TESTING;
410420

src/rust/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ optional = true
130130
# supported host, since test material usually just grows over time.
131131

132132
[dependencies.soroban-test-wasms]
133-
version = "=23.0.0"
133+
version = "=23.0.2"
134134
git = "https://github.com/stellar/rs-soroban-env"
135-
rev = "688bc34e6cd15c71742139e625268c7f30f55a92"
135+
rev = "30249f0549141dbe7fdce84b6401a4235dbad64f"
136136

137137
[dependencies.soroban-synth-wasm]
138138
version = "=23.0.0"

src/rust/src/bridge.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ pub(crate) mod rust_bridge {
206206
fn get_test_wasm_complex() -> Result<RustBuf>;
207207
fn get_test_wasm_loadgen() -> Result<RustBuf>;
208208
fn get_test_wasm_err() -> Result<RustBuf>;
209-
fn get_test_contract_sac_transfer() -> Result<RustBuf>;
209+
fn get_test_contract_sac_transfer(protocol_version: u32) -> Result<RustBuf>;
210210
fn get_write_bytes() -> Result<RustBuf>;
211211
fn get_invoke_contract_wasm() -> Result<RustBuf>;
212212

src/rust/src/soroban_test_wasm.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@ pub(crate) fn get_test_wasm_loadgen() -> Result<RustBuf, Box<dyn std::error::Err
4040
})
4141
}
4242

43-
pub(crate) fn get_test_contract_sac_transfer() -> Result<RustBuf, Box<dyn std::error::Error>> {
43+
pub(crate) fn get_test_contract_sac_transfer(
44+
protocol_version: u32,
45+
) -> Result<RustBuf, Box<dyn std::error::Error>> {
46+
let wasm_bytes = if protocol_version >= 23 {
47+
soroban_test_wasms::CONTRACT_SAC_TRANSFER_CONTRACT_P23
48+
} else {
49+
soroban_test_wasms::CONTRACT_SAC_TRANSFER_CONTRACT
50+
};
4451
Ok(RustBuf {
45-
data: soroban_test_wasms::CONTRACT_SAC_TRANSFER_CONTRACT
46-
.iter()
47-
.cloned()
48-
.collect(),
52+
data: wasm_bytes.iter().cloned().collect(),
4953
})
5054
}
5155

0 commit comments

Comments
 (0)