diff --git a/CHANGELOG.md b/CHANGELOG.md index e12d7b42065..b5ff39b4f80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - [#1866](https://github.com/FuelLabs/fuel-core/pull/1866): Fixed a runtime panic that occurred when restarting a node. The panic happens when the relayer database is already populated, and the relayer attempts an empty commit during start up. This invalid commit is removed in this PR. - [#1871](https://github.com/FuelLabs/fuel-core/pull/1871): Fixed `block` endpoint to return fetch the blocks from both databases after regenesis. - [#1856](https://github.com/FuelLabs/fuel-core/pull/1856): Replaced instances of `Union` with `Enum` for GraphQL definitions of `ConsensusParametersVersion` and related types. This is needed because `Union` does not support multiple `Version`s inside discriminants or empty variants. +- [#1870](https://github.com/FuelLabs/fuel-core/pull/1870): Fixed benchmarks for the `0.25.3`. +- [#1870](https://github.com/FuelLabs/fuel-core/pull/1870): Improves the performance of getting the size of the contract from the `InMemoryTransaction`. - [#1851](https://github.com/FuelLabs/fuel-core/pull/1851/): Provided migration capabilities (enabled addition of new column families) to RocksDB instance. ### Added diff --git a/benches/benches/block_target_gas_set/crypto.rs b/benches/benches/block_target_gas_set/crypto.rs index 84ba98fb5ad..fd53a7c0a1b 100644 --- a/benches/benches/block_target_gas_set/crypto.rs +++ b/benches/benches/block_target_gas_set/crypto.rs @@ -144,6 +144,7 @@ pub fn run_crypto(group: &mut BenchmarkGroup) { op::movi(0x11, 32), op::aloc(0x11), op::movi(0x10, i), + op::cfe(0x10), op::s256(RegId::HP, RegId::ZERO, 0x10), op::jmpb(RegId::ZERO, 0), ] @@ -161,6 +162,7 @@ pub fn run_crypto(group: &mut BenchmarkGroup) { op::movi(0x11, 32), op::aloc(0x11), op::movi(0x10, i), + op::cfe(0x10), op::k256(RegId::HP, RegId::ZERO, 0x10), op::jmpb(RegId::ZERO, 0), ] diff --git a/benches/benches/vm.rs b/benches/benches/vm.rs index 799d222a0eb..1efdf9629ce 100644 --- a/benches/benches/vm.rs +++ b/benches/benches/vm.rs @@ -89,3 +89,14 @@ fn vm(c: &mut Criterion) { criterion_group!(benches, vm); criterion_main!(benches); + +// If you want to debug the benchmarks, you can run them with code below: +// But first you need to comment `criterion_group` and `criterion_main` macros above. +// +// fn main() { +// let mut criterio = Criterion::default(); +// blockchain::run(&mut criterio); +// } +// +// #[test] +// fn dummy() {} diff --git a/benches/benches/vm_initialization.rs b/benches/benches/vm_initialization.rs index ff996271537..75f59de71d6 100644 --- a/benches/benches/vm_initialization.rs +++ b/benches/benches/vm_initialization.rs @@ -3,6 +3,7 @@ use criterion::{ Criterion, Throughput, }; +use fuel_core_storage::InterpreterStorage; use fuel_core_types::{ fuel_asm::{ op, @@ -22,7 +23,10 @@ use fuel_core_types::{ checked_transaction::{ Checked, IntoChecked, + Ready, }, + constraints::reg_key::Reg, + consts::VM_MAX_RAM, interpreter::NotSupportedEcal, Interpreter, }, @@ -75,36 +79,76 @@ fn transaction( pub fn vm_initialization(c: &mut Criterion) { let mut rng = StdRng::seed_from_u64(8586); - + let consensus_params = ConsensusParameters::default(); let mut group = c.benchmark_group("vm_initialization"); - let consensus_params = ConsensusParameters::default(); - let mut i = 5usize; - loop { + // Increase the size of the script to measure the performance of the VM initialization + // with a large script. THe largest allowed script is 64 KB = 2^16 bytes. + const TX_SIZE_POWER_OF_TWO: usize = 16; + + for i in 5..=TX_SIZE_POWER_OF_TWO { let size = 8 * (1 << i); - if size as u64 > consensus_params.script_params().max_script_data_length() { - break - } + let script = vec![op::ret(1); size / Instruction::SIZE] .into_iter() .collect(); let script_data = vec![255; size]; let tx = transaction(&mut rng, script, script_data, &consensus_params); let tx_size = tx.transaction().size(); + let tx = tx.test_into_ready(); + let name = format!("vm_initialization_with_tx_size_{}", tx_size); group.throughput(Throughput::Bytes(tx_size as u64)); group.bench_function(name, |b| { b.iter(|| { - let mut vm = black_box( - Interpreter::<_, Script, NotSupportedEcal>::with_memory_storage(), - ); - let ready_tx = tx.clone().test_into_ready(); - black_box(vm.init_script(ready_tx)) - .expect("Should be able to execute transaction"); + unoptimized_vm_initialization_with_allocating_full_range_of_memory(&tx); }) }); - i += 1; } group.finish(); } + +fn unoptimized_vm_initialization_with_allocating_full_range_of_memory( + ready_tx: &Ready