From bc91cb5d5bf1318dd4c717863084d42b275f2be5 Mon Sep 17 00:00:00 2001 From: Green Baneling Date: Fri, 10 Jan 2025 18:59:36 -0500 Subject: [PATCH] Fixed TPS benchmark to work with latest changes (#2515) ### Before requesting review - [x] I have reviewed the code myself --- Cargo.toml | 5 +++++ benches/benches/transaction_throughput.rs | 2 ++ crates/fuel-core/Cargo.toml | 6 +++++- crates/services/executor/Cargo.toml | 1 + crates/services/executor/src/executor.rs | 4 ++-- crates/services/upgradable-executor/Cargo.toml | 1 + tests/Cargo.toml | 2 +- tests/test-helpers/src/builder.rs | 13 ++++++++++++- 8 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dc85bbc0535..6b49ff33df8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,11 @@ exclude = ["version-compatibility"] [profile.release] codegen-units = 1 lto = "fat" +# The difference in performance for "fat" and "thin" is small, +# but "thin" LTO is much faster to compile. +# If you play with benchamrks or flamegraph, it is better to use "thin" +# To speedup iterations between compialtion. +#lto = "thin" panic = "unwind" [workspace.package] diff --git a/benches/benches/transaction_throughput.rs b/benches/benches/transaction_throughput.rs index 5e37c3af6a5..cafe8705000 100644 --- a/benches/benches/transaction_throughput.rs +++ b/benches/benches/transaction_throughput.rs @@ -1,4 +1,5 @@ //! Tests throughput of various transaction types +//! `cargo bench --bench transaction_throughput -p fuel-core-benches` use criterion::{ criterion_group, @@ -99,6 +100,7 @@ where test_builder.utxo_validation = true; test_builder.gas_limit = Some(10_000_000_000); test_builder.block_size_limit = Some(1_000_000_000_000); + test_builder.max_txs = 100000; test_builder.database_type = DbType::RocksDb; test_builder.database_config = DatabaseConfig { cache_capacity: Some(16 * 1024 * 1024 * 1024), diff --git a/crates/fuel-core/Cargo.toml b/crates/fuel-core/Cargo.toml index bc8b72d310d..79c05ec33e6 100644 --- a/crates/fuel-core/Cargo.toml +++ b/crates/fuel-core/Cargo.toml @@ -73,7 +73,11 @@ uuid = { version = "1.1", features = ["v4"] } [dev-dependencies] assert_matches = "1.5" fuel-core = { path = ".", features = ["smt", "test-helpers"] } -fuel-core-executor = { workspace = true, features = ["std", "test-helpers"] } +fuel-core-executor = { workspace = true, features = [ + "std", + "test-helpers", + "limited-tx-count", +] } fuel-core-services = { path = "./../services", features = ["test-helpers"] } fuel-core-storage = { path = "./../storage", features = ["test-helpers"] } fuel-core-trace = { path = "./../trace" } diff --git a/crates/services/executor/Cargo.toml b/crates/services/executor/Cargo.toml index 9f3627f07d1..5c96c082f47 100644 --- a/crates/services/executor/Cargo.toml +++ b/crates/services/executor/Cargo.toml @@ -36,3 +36,4 @@ test-helpers = [ "fuel-core-types/test-helpers", "fuel-core-storage/test-helpers", ] +limited-tx-count = [] diff --git a/crates/services/executor/src/executor.rs b/crates/services/executor/src/executor.rs index 383dcea5e68..77252c843ad 100644 --- a/crates/services/executor/src/executor.rs +++ b/crates/services/executor/src/executor.rs @@ -164,11 +164,11 @@ use alloc::{ /// The maximum amount of transactions that can be included in a block, /// excluding the mint transaction. -#[cfg(not(feature = "test-helpers"))] +#[cfg(not(feature = "limited-tx-count"))] pub const fn max_tx_count() -> u16 { u16::MAX.saturating_sub(1) } -#[cfg(feature = "test-helpers")] +#[cfg(feature = "limited-tx-count")] pub const fn max_tx_count() -> u16 { 1024 } diff --git a/crates/services/upgradable-executor/Cargo.toml b/crates/services/upgradable-executor/Cargo.toml index 16eeb0fc391..819253f449d 100644 --- a/crates/services/upgradable-executor/Cargo.toml +++ b/crates/services/upgradable-executor/Cargo.toml @@ -59,3 +59,4 @@ test-helpers = [ "fuel-core-storage/test-helpers", "fuel-core-types/test-helpers", ] +limited-tx-count = ["fuel-core-executor/limited-tx-count"] diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 291f41ab7d7..3498ae56f20 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -37,7 +37,6 @@ fuel-core-benches = { path = "../benches" } fuel-core-bin = { path = "../bin/fuel-core", features = ["parquet", "p2p"] } fuel-core-client = { path = "../crates/client", features = ["test-helpers"] } fuel-core-compression = { path = "../crates/compression" } -fuel-core-executor = { workspace = true, features = ["test-helpers"] } fuel-core-gas-price-service = { path = "../crates/services/gas_price_service" } fuel-core-p2p = { path = "../crates/services/p2p", features = [ "test-helpers", @@ -76,6 +75,7 @@ tokio = { workspace = true, features = [ ] } [dev-dependencies] +fuel-core-executor = { workspace = true, features = ["limited-tx-count"] } pretty_assertions = "1.4" proptest = { workspace = true } tracing = { workspace = true } diff --git a/tests/test-helpers/src/builder.rs b/tests/test-helpers/src/builder.rs index fa23f8608a1..cb615cea811 100644 --- a/tests/test-helpers/src/builder.rs +++ b/tests/test-helpers/src/builder.rs @@ -100,6 +100,7 @@ pub struct TestSetupBuilder { pub privileged_address: Address, pub base_asset_id: AssetId, pub trigger: Trigger, + pub max_txs: usize, pub database_type: DbType, pub database_config: DatabaseConfig, } @@ -234,9 +235,18 @@ impl TestSetupBuilder { ..StateConfig::default() }; + let mut txpool = fuel_core_txpool::config::Config::default(); + txpool.pool_limits.max_txs = self.max_txs; + txpool.max_tx_update_subscriptions = self.max_txs; + txpool.service_channel_limits = fuel_core_txpool::config::ServiceChannelLimits { + max_pending_write_pool_requests: self.max_txs, + max_pending_read_pool_requests: self.max_txs, + }; + txpool.heavy_work.size_of_verification_queue = self.max_txs; + let mut config = Config { utxo_validation: self.utxo_validation, - txpool: fuel_core_txpool::config::Config::default(), + txpool, block_production: self.trigger, starting_gas_price: self.starting_gas_price, ..Config::local_node_with_configs(chain_conf, state) @@ -268,6 +278,7 @@ impl Default for TestSetupBuilder { privileged_address: Default::default(), base_asset_id: AssetId::BASE, trigger: Trigger::Instant, + max_txs: 100000, database_type: DbType::RocksDb, database_config: DatabaseConfig::config_for_tests(), }