From 2a3b385095beecd8340ce3e5c5349a19c5ca0443 Mon Sep 17 00:00:00 2001 From: Mitchell Turner Date: Thu, 16 Nov 2023 04:28:37 -0800 Subject: [PATCH] "other" op code sanity check (#1476) https://github.com/FuelLabs/fuel-core/issues/1386 ``` block target estimation/other/flag time: [27.326 ms 27.458 ms 27.603 ms] block target estimation/other/gm time: [7.7485 ms 7.7831 ms 7.8231 ms] ``` --------- Co-authored-by: Hannes Karppila Co-authored-by: xgreenx --- CHANGELOG.md | 2 +- benches/benches/block_target_gas.rs | 33 ++++++++------- benches/benches/block_target_gas_set/mod.rs | 2 + benches/benches/block_target_gas_set/other.rs | 41 +++++++++++++++++++ 4 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 benches/benches/block_target_gas_set/other.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b4e6af8361..cdc7d147ed9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,8 @@ Description of the upcoming release here. ### Added -- [#1488](https://github.com/FuelLabs/fuel-core/pull/1488): Add docker login for cross binaries that use docker - [#1485](https://github.com/FuelLabs/fuel-core/pull/1485): Prepare rc release of fuel core v0.21 +- [#1476](https://github.com/FuelLabs/fuel-core/pull/1453): Add the majority of the "other" benchmarks for contract opcodes. - [#1453](https://github.com/FuelLabs/fuel-core/pull/1453): Add the majority of the "sanity" benchmarks for contract opcodes. - [#1473](https://github.com/FuelLabs/fuel-core/pull/1473): Expose fuel-core version as a constant - [#1469](https://github.com/FuelLabs/fuel-core/pull/1469): Added support of bloom filter for RocksDB tables and increased the block cache. diff --git a/benches/benches/block_target_gas.rs b/benches/benches/block_target_gas.rs index 2bd8feec1da..33d73bc4e31 100644 --- a/benches/benches/block_target_gas.rs +++ b/benches/benches/block_target_gas.rs @@ -1,9 +1,11 @@ +use crate::block_target_gas_set::default_gas_costs::default_gas_costs; use block_target_gas_set::{ alu::run_alu, contract::run_contract, crypto::run_crypto, flow::run_flow, memory::run_memory, + other::run_other, }; use criterion::{ criterion_group, @@ -13,16 +15,16 @@ use criterion::{ Criterion, }; use ed25519_dalek::Signer; -use fuel_core::service::{ - config::Trigger, - Config, - FuelService, - ServiceTrait, -}; -use rand::SeedableRng; - use ethnum::U256; -use fuel_core::txpool::types::Word; +use fuel_core::{ + service::{ + config::Trigger, + Config, + FuelService, + ServiceTrait, + }, + txpool::types::Word, +}; use fuel_core_benches::*; use fuel_core_chain_config::ContractConfig; use fuel_core_storage::{ @@ -67,17 +69,16 @@ use fuel_core_types::{ consts::WORD_SIZE, }, }; - -mod utils; - -mod block_target_gas_set; - -use crate::block_target_gas_set::default_gas_costs::default_gas_costs; +use rand::SeedableRng; use utils::{ make_u128, make_u256, }; +mod utils; + +mod block_target_gas_set; + // Use Jemalloc during benchmarks #[global_allocator] static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; @@ -462,6 +463,8 @@ fn block_target_gas(c: &mut Criterion) { run_memory(&mut group); + run_other(&mut group); + group.finish(); } diff --git a/benches/benches/block_target_gas_set/mod.rs b/benches/benches/block_target_gas_set/mod.rs index cd266169cf3..01dbc5ca58b 100644 --- a/benches/benches/block_target_gas_set/mod.rs +++ b/benches/benches/block_target_gas_set/mod.rs @@ -13,4 +13,6 @@ pub mod contract; pub mod memory; +pub mod other; + pub mod default_gas_costs; diff --git a/benches/benches/block_target_gas_set/other.rs b/benches/benches/block_target_gas_set/other.rs new file mode 100644 index 00000000000..69e3dc77a63 --- /dev/null +++ b/benches/benches/block_target_gas_set/other.rs @@ -0,0 +1,41 @@ +use crate::*; + +// ECAL +// FLAG +// GM +// GTF + +pub fn run_other(group: &mut BenchmarkGroup) { + let contract_id = ContractId::zeroed(); + let asset_id = AssetId::zeroed(); + let script_data = script_data(&contract_id, &asset_id); + let mut shared_runner_builder = SanityBenchmarkRunnerBuilder::new_shared(contract_id); + // run_group_ref( + // &mut c.benchmark_group("flag"), + // "flag", + // VmBench::new(op::flag(0x10)), + // ); + run( + "other/flag", + group, + vec![op::flag(0x10), op::jmpb(RegId::ZERO, 0)], + vec![], + ); + + // ecal: Skipped because it would exit the VM + + // gm + { + let contract_instructions = vec![op::gm(0x10, 1), op::jmpb(RegId::ZERO, 0)]; + + let mut instructions = setup_instructions(); + instructions.extend(vec![op::call(0x10, RegId::ZERO, 0x11, 0x12)]); + + let id = "other/gm"; + shared_runner_builder + .build_with_new_contract(contract_instructions) + .run(id, group, instructions, script_data.clone()); + } + + // gtf: TODO: As part of parent issue (https://github.com/FuelLabs/fuel-core/issues/1386) +}