From 630fb5dc6e319682ba9a5043305cde2af5bbfdb0 Mon Sep 17 00:00:00 2001 From: green Date: Wed, 25 Dec 2024 16:35:09 -0500 Subject: [PATCH 1/6] Fixed TPS tests to allow more than 1k transactions in TxPool --- benches/benches/transaction_throughput.rs | 1 + tests/test-helpers/src/builder.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/benches/benches/transaction_throughput.rs b/benches/benches/transaction_throughput.rs index 5d78818e8da..858fcc050b6 100644 --- a/benches/benches/transaction_throughput.rs +++ b/benches/benches/transaction_throughput.rs @@ -90,6 +90,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 = transactions.len(); // spin up node let transactions: Vec = diff --git a/tests/test-helpers/src/builder.rs b/tests/test-helpers/src/builder.rs index 0d16bc48dc6..73d70eeb2a0 100644 --- a/tests/test-helpers/src/builder.rs +++ b/tests/test-helpers/src/builder.rs @@ -99,6 +99,7 @@ pub struct TestSetupBuilder { pub privileged_address: Address, pub base_asset_id: AssetId, pub trigger: Trigger, + pub max_txs: usize, } impl TestSetupBuilder { @@ -231,9 +232,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 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) @@ -265,6 +275,7 @@ impl Default for TestSetupBuilder { privileged_address: Default::default(), base_asset_id: AssetId::BASE, trigger: Trigger::Instant, + max_txs: 100000, } } } From 9256358aa2407bc1765ea5190cd7b1195e2327f2 Mon Sep 17 00:00:00 2001 From: green Date: Wed, 25 Dec 2024 17:14:47 -0500 Subject: [PATCH 2/6] Allow more txs --- benches/benches/transaction_throughput.rs | 2 +- crates/services/executor/src/executor.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/benches/benches/transaction_throughput.rs b/benches/benches/transaction_throughput.rs index 858fcc050b6..c3fb88da35d 100644 --- a/benches/benches/transaction_throughput.rs +++ b/benches/benches/transaction_throughput.rs @@ -90,7 +90,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 = transactions.len(); + test_builder.max_txs = 100000; // spin up node let transactions: Vec = diff --git a/crates/services/executor/src/executor.rs b/crates/services/executor/src/executor.rs index 1277b143d9c..42b5201ad87 100644 --- a/crates/services/executor/src/executor.rs +++ b/crates/services/executor/src/executor.rs @@ -170,7 +170,7 @@ pub const fn max_tx_count() -> u16 { } #[cfg(feature = "test-helpers")] pub const fn max_tx_count() -> u16 { - 1024 + 10240 } pub struct OnceTransactionsSource { From 6a88fc1c10d66cdee660c527e7f1b823589bc42e Mon Sep 17 00:00:00 2001 From: green Date: Thu, 26 Dec 2024 11:43:39 -0500 Subject: [PATCH 3/6] Use an explicit name for the feature to not mix it with `test-helpers` --- Cargo.lock | 1 - benches/benches/transaction_throughput.rs | 1 + crates/fuel-core/Cargo.toml | 2 +- crates/services/executor/Cargo.toml | 1 + crates/services/executor/src/executor.rs | 6 +++--- crates/services/upgradable-executor/Cargo.toml | 1 + tests/Cargo.toml | 3 +-- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f785bfaae99..a9a193ba3f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3737,7 +3737,6 @@ dependencies = [ "cynic", "ethers", "fuel-core", - "fuel-core-benches", "fuel-core-bin", "fuel-core-client", "fuel-core-compression", diff --git a/benches/benches/transaction_throughput.rs b/benches/benches/transaction_throughput.rs index c3fb88da35d..4475e9d3759 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, diff --git a/crates/fuel-core/Cargo.toml b/crates/fuel-core/Cargo.toml index 8e3230df1fc..2fb392dc0c4 100644 --- a/crates/fuel-core/Cargo.toml +++ b/crates/fuel-core/Cargo.toml @@ -71,7 +71,7 @@ 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 42b5201ad87..07c23c8475f 100644 --- a/crates/services/executor/src/executor.rs +++ b/crates/services/executor/src/executor.rs @@ -164,13 +164,13 @@ 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 { - 10240 + 1024 } pub struct OnceTransactionsSource { 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..df09812da7b 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -33,11 +33,9 @@ fuel-core = { path = "../crates/fuel-core", default-features = false, features = "wasm-executor", "test-helpers", ] } -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", @@ -77,6 +75,7 @@ tokio = { workspace = true, features = [ [dev-dependencies] pretty_assertions = "1.4" +fuel-core-executor = { workspace = true, features = ["limited-tx-count"] } proptest = { workspace = true } tracing = { workspace = true } From 2e1e84ecca4e41335a88ba28826fa01539488636 Mon Sep 17 00:00:00 2001 From: green Date: Mon, 30 Dec 2024 19:09:33 -0500 Subject: [PATCH 4/6] Make CI happy --- tests/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Cargo.toml b/tests/Cargo.toml index df09812da7b..8d10eb1f5f7 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -74,8 +74,8 @@ tokio = { workspace = true, features = [ ] } [dev-dependencies] -pretty_assertions = "1.4" fuel-core-executor = { workspace = true, features = ["limited-tx-count"] } +pretty_assertions = "1.4" proptest = { workspace = true } tracing = { workspace = true } From b2e92af085a46037bee9d8933e8df400be5a7be6 Mon Sep 17 00:00:00 2001 From: green Date: Mon, 30 Dec 2024 19:41:43 -0500 Subject: [PATCH 5/6] Make CI happy --- Cargo.lock | 1 + crates/fuel-core/Cargo.toml | 6 +++++- tests/Cargo.toml | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 5fb48bf4581..6fa3ea715a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3712,6 +3712,7 @@ dependencies = [ "cynic", "ethers", "fuel-core", + "fuel-core-benches", "fuel-core-bin", "fuel-core-client", "fuel-core-compression", diff --git a/crates/fuel-core/Cargo.toml b/crates/fuel-core/Cargo.toml index 2fb392dc0c4..f1bf18fd60b 100644 --- a/crates/fuel-core/Cargo.toml +++ b/crates/fuel-core/Cargo.toml @@ -71,7 +71,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", "limited-tx-count"] } +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/tests/Cargo.toml b/tests/Cargo.toml index 8d10eb1f5f7..3498ae56f20 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -33,6 +33,7 @@ fuel-core = { path = "../crates/fuel-core", default-features = false, features = "wasm-executor", "test-helpers", ] } +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" } From f73e16eda7ca49e3a04e0f8708d26999221b17cd Mon Sep 17 00:00:00 2001 From: green Date: Mon, 30 Dec 2024 19:44:22 -0500 Subject: [PATCH 6/6] Added description and example of the "thin" LTO --- Cargo.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 1c72cac2bca..1bdb62f1f66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,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]