Skip to content

Commit

Permalink
Fixed TPS benchmark to work with latest changes (#2515)
Browse files Browse the repository at this point in the history
### Before requesting review
- [x] I have reviewed the code myself
  • Loading branch information
xgreenx authored Jan 10, 2025
1 parent c2a31ef commit bc91cb5
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions benches/benches/transaction_throughput.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Tests throughput of various transaction types
//! `cargo bench --bench transaction_throughput -p fuel-core-benches`
use criterion::{
criterion_group,
Expand Down Expand Up @@ -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),
Expand Down
6 changes: 5 additions & 1 deletion crates/fuel-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
1 change: 1 addition & 0 deletions crates/services/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ test-helpers = [
"fuel-core-types/test-helpers",
"fuel-core-storage/test-helpers",
]
limited-tx-count = []
4 changes: 2 additions & 2 deletions crates/services/executor/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions crates/services/upgradable-executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 }
Expand Down
13 changes: 12 additions & 1 deletion tests/test-helpers/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(),
}
Expand Down

0 comments on commit bc91cb5

Please sign in to comment.