Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bench/disable_meta-20260410-205536/results.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
scenario,median_time_ms,p95_time_ms,p99_time_ms
"sac,TX=3200,T=1",337.0062885000008,388.6413382500008,449.63406636999326
"sac,TX=3200,T=8",234.05063849999988,256.48933750000083,264.29044799000235
"custom_token,TX=1600,T=1",310.4716815000029,334.2666388999983,343.7057104299992
"custom_token,TX=1600,T=8",159.46541449999904,179.4608217500015,195.17456334999972
"soroswap,TX=1000,T=1",444.1408194999967,479.7950516499987,504.93647869998614
"soroswap,TX=1000,T=8",170.7175889999994,191.4872912999981,200.91390174999842
61 changes: 61 additions & 0 deletions bench/disable_meta-20260410-205536/stamp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Warning: running non-release version v26.0.0-62-g0ad388f96 of stellar-core
v26.0.0-62-g0ad388f96
ledger protocol version: 26
rust version: rustc 1.88.0 (6b00bc388 2025-06-23)
soroban-env-host versions:
host[0]:
package version: 21.2.2
git version: 7eeddd897cfb0f700f938b0c8d6f0541150d1fcb
ledger protocol version: 21
pre-release version: 0
rs-stellar-xdr:
package version: 21.2.0
git version: 9bea881f2057e412fdbb98875841626bf77b4b88
base XDR git version: 70180d5e8d9caee9e8645ed8a38c36a8cf403cd9
host[1]:
package version: 22.0.0
git version: 1cd8b8dca9aeeca9ce45b129cd923992b32dc258
ledger protocol version: 22
pre-release version: 0
rs-stellar-xdr:
package version: 22.0.0
git version: 715003372ea6380044b5a4a02907ff73e56ae9e7
base XDR git version: 529d5176f24c73eeccfa5eba481d4e89c19b1181
host[2]:
package version: 23.0.0
git version: 688bc34e6cd15c71742139e625268c7f30f55a92
ledger protocol version: 23
pre-release version: 0
rs-stellar-xdr:
package version: 23.0.0
git version: e83a6337204ecfdb0ac0d44ffb857130c1249b1b
base XDR git version: 4b7a2ef7931ab2ca2499be68d849f38190b443ca
host[3]:
package version: 24.0.0
git version: a37eeda815e626f416eff13f2eacb32a8b0c3729
ledger protocol version: 24
pre-release version: 0
rs-stellar-xdr:
package version: 24.0.0
git version: 07b765d3ab146f7f7ea951af1f9e41e0ece8fb48
base XDR git version: 4b7a2ef7931ab2ca2499be68d849f38190b443ca
host[4]:
package version: 25.0.0
git version: 6323c1fc03ecb9f53b7c1e42fd62c1bbd3aebc2c
ledger protocol version: 25
pre-release version: 0
rs-stellar-xdr:
package version: 25.0.0
git version: dc9f40fcb83c3054341f70b65a2222073369b37b
base XDR git version: 0a621ec7811db000a60efae5b35f78dee3aa2533
host[5]:
package version: 26.0.0
git version: b351f88a468d3b9e1d6de53d5b0ca585f6b7dadb
ledger protocol version: 26
pre-release version: 0
rs-stellar-xdr:
package version: 26.0.0
git version: dd7a165a193126fd37a751d867bee1cb8f3b55a6
base XDR git version: cff714a5ebaaaf2dac343b3546c2df73f0b7a36e

Benchmark ledgers=200
7 changes: 7 additions & 0 deletions bench/p26_baseline_again-20260410-193305/results.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
scenario,median_time_ms,p95_time_ms,p99_time_ms
"sac,TX=3200,T=1",348.6932005000017,395.12184564999995,409.27602225000237
"sac,TX=3200,T=8",242.59525600000052,266.3564931000006,277.14852171
"custom_token,TX=1600,T=1",310.3890900000006,343.3200991000005,352.79791974000204
"custom_token,TX=1600,T=8",163.62422350000043,180.21471705000042,187.8724304600013
"soroswap,TX=1000,T=1",469.7830955000027,495.3508111500008,504.3309423599958
"soroswap,TX=1000,T=8",183.22680400000036,199.4422209999998,211.36548991000078
61 changes: 61 additions & 0 deletions bench/p26_baseline_again-20260410-193305/stamp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Warning: running non-release version v26.0.0-60-g8c7d5ef0b-dirty of stellar-core
v26.0.0-60-g8c7d5ef0b-dirty
ledger protocol version: 26
rust version: rustc 1.88.0 (6b00bc388 2025-06-23)
soroban-env-host versions:
host[0]:
package version: 21.2.2
git version: 7eeddd897cfb0f700f938b0c8d6f0541150d1fcb
ledger protocol version: 21
pre-release version: 0
rs-stellar-xdr:
package version: 21.2.0
git version: 9bea881f2057e412fdbb98875841626bf77b4b88
base XDR git version: 70180d5e8d9caee9e8645ed8a38c36a8cf403cd9
host[1]:
package version: 22.0.0
git version: 1cd8b8dca9aeeca9ce45b129cd923992b32dc258
ledger protocol version: 22
pre-release version: 0
rs-stellar-xdr:
package version: 22.0.0
git version: 715003372ea6380044b5a4a02907ff73e56ae9e7
base XDR git version: 529d5176f24c73eeccfa5eba481d4e89c19b1181
host[2]:
package version: 23.0.0
git version: 688bc34e6cd15c71742139e625268c7f30f55a92
ledger protocol version: 23
pre-release version: 0
rs-stellar-xdr:
package version: 23.0.0
git version: e83a6337204ecfdb0ac0d44ffb857130c1249b1b
base XDR git version: 4b7a2ef7931ab2ca2499be68d849f38190b443ca
host[3]:
package version: 24.0.0
git version: a37eeda815e626f416eff13f2eacb32a8b0c3729
ledger protocol version: 24
pre-release version: 0
rs-stellar-xdr:
package version: 24.0.0
git version: 07b765d3ab146f7f7ea951af1f9e41e0ece8fb48
base XDR git version: 4b7a2ef7931ab2ca2499be68d849f38190b443ca
host[4]:
package version: 25.0.0
git version: 6323c1fc03ecb9f53b7c1e42fd62c1bbd3aebc2c
ledger protocol version: 25
pre-release version: 0
rs-stellar-xdr:
package version: 25.0.0
git version: dc9f40fcb83c3054341f70b65a2222073369b37b
base XDR git version: 0a621ec7811db000a60efae5b35f78dee3aa2533
host[5]:
package version: 26.0.0
git version: b351f88a468d3b9e1d6de53d5b0ca585f6b7dadb
ledger protocol version: 26
pre-release version: 0
rs-stellar-xdr:
package version: 26.0.0
git version: dd7a165a193126fd37a751d867bee1cb8f3b55a6
base XDR git version: cff714a5ebaaaf2dac343b3546c2df73f0b7a36e

Benchmark ledgers=200
4 changes: 3 additions & 1 deletion docs/apply-load-benchmark-sac.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ APPLY_LOAD_TIME_WRITES = true
# eventually, it is useful to disable these when optimizing anything besides
# the metrics.
DISABLE_SOROBAN_METRICS_FOR_TESTING = true
# Disable transaction metadata collection (BUILD_TESTS forces it otherwise)
DISABLE_TX_META_FOR_TESTING = true
# Disable metadata output
METADATA_OUTPUT_STREAM = ""
# Disable metadata debug
Expand All @@ -32,7 +34,7 @@ APPLY_LOAD_LEDGER_MAX_DEPENDENT_TX_CLUSTERS = 1
# operations are batched for 'classic' transactions.
# This is useful to reduce the impact of non-env parts of the apply path, e.g.
# when evaluating the impact of changes to env itself.
APPLY_LOAD_BATCH_SAC_COUNT = 100
APPLY_LOAD_BATCH_SAC_COUNT = 1

# Number of ledgers to close for every iteration of search.
APPLY_LOAD_NUM_LEDGERS = 100
Expand Down
2 changes: 2 additions & 0 deletions docs/apply-load-benchmark-token.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ APPLY_LOAD_TIME_WRITES = true
# eventually, it is useful to disable these when optimizing anything besides
# the metrics.
DISABLE_SOROBAN_METRICS_FOR_TESTING = true
# Disable transaction metadata collection (BUILD_TESTS forces it otherwise)
DISABLE_TX_META_FOR_TESTING = true
# Disable metadata output
METADATA_OUTPUT_STREAM = ""
# Disable metadata debug
Expand Down
16 changes: 6 additions & 10 deletions scripts/run_apply_load_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,44 +71,40 @@ def summary(self) -> str:
SCENARIOS: tuple[Scenario, ...] = (
Scenario(
model_tx="sac",
tx_count=6400,
tx_count=3200,
thread_count=1,
),
Scenario(
model_tx="sac",
tx_count=6400,
tx_count=3200,
thread_count=8,
),
Scenario(
model_tx="custom_token",
tx_count=3000,
tx_count=1600,
thread_count=1,
),
Scenario(
model_tx="custom_token",
tx_count=3000,
tx_count=1600,
thread_count=8,
),
Scenario(
model_tx="soroswap",
tx_count=1600,
tx_count=1000,
thread_count=1,
),
Scenario(
model_tx="soroswap",
tx_count=1600,
tx_count=1000,
thread_count=8,
),
)


def validate_scenarios(scenarios: tuple[Scenario, ...]) -> None:
seen_identifiers: set[str] = set()
for scenario in scenarios:
identifier = scenario.identifier()
if identifier in seen_identifiers:
raise ValueError(f"Duplicate scenario identifier: {identifier}")
seen_identifiers.add(identifier)

if scenario.model_tx != "sac":
continue
Expand Down
24 changes: 17 additions & 7 deletions src/ledger/LedgerManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1596,8 +1596,9 @@ LedgerManagerImpl::applyLedger(LedgerCloseData const& ledgerData,
}

#ifdef BUILD_TESTS
// We always store the ledgerCloseMeta in tests so we can inspect it.
if (!ledgerCloseMeta)
// We always store the ledgerCloseMeta in tests so we can inspect it,
// unless explicitly disabled for benchmarking.
if (!ledgerCloseMeta && !mApp.getConfig().DISABLE_TX_META_FOR_TESTING)
{
ledgerCloseMeta = std::make_unique<LedgerCloseMetaFrame>(
header.current().ledgerVersion);
Expand Down Expand Up @@ -2589,7 +2590,10 @@ LedgerManagerImpl::processResultAndMeta(
{
auto metaXDR = txMetaBuilder.finalize(result.isSuccess());
#ifdef BUILD_TESTS
mLastLedgerTxMeta.emplace_back(metaXDR);
if (!mApp.getConfig().DISABLE_TX_META_FOR_TESTING)
{
mLastLedgerTxMeta.emplace_back(metaXDR);
}
#endif

ledgerCloseMeta->setTxProcessingMetaAndResultPair(
Expand All @@ -2598,8 +2602,11 @@ LedgerManagerImpl::processResultAndMeta(
else
{
#ifdef BUILD_TESTS
mLastLedgerTxMeta.emplace_back(
txMetaBuilder.finalize(result.isSuccess()));
if (!mApp.getConfig().DISABLE_TX_META_FOR_TESTING)
{
mLastLedgerTxMeta.emplace_back(
txMetaBuilder.finalize(result.isSuccess()));
}
#endif
}
}
Expand Down Expand Up @@ -2645,8 +2652,11 @@ LedgerManagerImpl::applyTransactions(
bool enableTxMeta = ledgerCloseMeta != nullptr;
#ifdef BUILD_TESTS
// In tests we want to always enable tx meta because we store it in
// mLastLedgerTxMeta.
enableTxMeta = true;
// mLastLedgerTxMeta, unless explicitly disabled for benchmarking.
if (!mApp.getConfig().DISABLE_TX_META_FOR_TESTING)
{
enableTxMeta = true;
}
#endif
std::optional<SorobanNetworkConfig> sorobanConfig;
if (protocolVersionStartsFrom(ltx.loadHeader().current().ledgerVersion,
Expand Down
5 changes: 5 additions & 0 deletions src/main/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ Config::Config() : NODE_SEED(SecretKey::random())
BACKGROUND_OVERLAY_PROCESSING = true;
PARALLEL_LEDGER_APPLY = true;
DISABLE_SOROBAN_METRICS_FOR_TESTING = false;
DISABLE_TX_META_FOR_TESTING = false;
BACKGROUND_TX_SIG_VERIFICATION = true;
BUCKETLIST_DB_INDEX_PAGE_SIZE_EXPONENT = 14; // 2^14 == 16 kb
BUCKETLIST_DB_INDEX_CUTOFF = 20; // 20 mb
Expand Down Expand Up @@ -1180,6 +1181,10 @@ Config::processConfig(std::shared_ptr<cpptoml::table> t)
[&]() {
DISABLE_SOROBAN_METRICS_FOR_TESTING = readBool(item);
}},
{"DISABLE_TX_META_FOR_TESTING",
[&]() {
DISABLE_TX_META_FOR_TESTING = readBool(item);
}},
{"EXPERIMENTAL_BACKGROUND_TX_SIG_VERIFICATION",
[&]() {
CLOG_WARNING(Overlay,
Expand Down
5 changes: 5 additions & 0 deletions src/main/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,11 @@ class Config : public std::enable_shared_from_this<Config>
// Disable expensive Soroban metrics for performance testing
bool DISABLE_SOROBAN_METRICS_FOR_TESTING;

// Disable transaction metadata collection in test builds for benchmarking.
// When true, BUILD_TESTS overrides that force ledgerCloseMeta allocation
// and enableTxMeta are suppressed, avoiding significant XDR copy overhead.
bool DISABLE_TX_META_FOR_TESTING;

// Batch transactions for flooding purposes (experimental).
// Has no effect on non-test builds.
size_t EXPERIMENTAL_TX_BATCH_MAX_SIZE;
Expand Down
38 changes: 2 additions & 36 deletions src/rust/src/soroban_invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,8 @@ pub(crate) fn invoke_host_function(
rent_fee_configuration: CxxRentFeeConfiguration,
module_cache: &SorobanModuleCache,
) -> Result<InvokeHostFunctionOutput, Box<dyn std::error::Error>> {
use std::error::Error as StdError;
type BoxStdErr = Box<dyn StdError>;
type BoxStdErrSend = Box<dyn StdError + Send>;
type BoxStdErrSendSync = Box<dyn StdError + Send + Sync>;

fn sendable_str_err(str: &str) -> BoxStdErrSend {
let tmp: BoxStdErrSendSync = Box::from(str);
tmp as BoxStdErrSend
}

let hm = get_host_module_for_protocol(config_max_protocol, ledger_info.protocol_version)?;
// Rust stacks are 2MiB by default, which is a little too small
// for comfort; to give ourselves a little more breathing room
// against unforeseen bugs we use a 100MiB stack. Unfortunately
// there's no easy way to enforce this at the C++ side when the
// initial std::async parallel-exec thread is spawned, so we
// have to spawn _another_ here. On linux this is fairly fast,
// on the order of a ten-ish microseconds.
let LARGE_STACK_SIZE: usize = 100 * 1024 * 1024; // 100 MiB
let res = std::thread::scope(|scope| {
std::thread::Builder::new()
.stack_size(LARGE_STACK_SIZE)
.spawn_scoped(scope, || {
(hm.invoke_host_function)(
let res = (hm.invoke_host_function)(
enable_diagnostics,
instruction_limit,
hf_buf,
Expand All @@ -57,19 +35,7 @@ pub(crate) fn invoke_host_function(
base_prng_seed,
&rent_fee_configuration,
module_cache,
)
// Map non-sendable error to sendable for crossing thread boundary.
// This is crude but the error is going to be stringified on the
// bridge-crossing anyways.
.map_err(|e| sendable_str_err(&format!("{e}")))
})
.map_err(|_| sendable_str_err("spawn_scoped failed"))?
.join()
.map_err(|_| sendable_str_err("join failed"))?
});

// Map sendable error back to non-sendable -- Rust doesn't do dyn upcasts.
let res = res.map_err(|e: BoxStdErrSend| e as BoxStdErr);
);

#[cfg(feature = "testutils")]
crate::soroban_test_extra_protocol::maybe_invoke_host_function_again_and_compare_outputs(
Expand Down
Loading