Skip to content

Commit

Permalink
"other" op code sanity check (#1476)
Browse files Browse the repository at this point in the history
#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 <[email protected]>
Co-authored-by: xgreenx <[email protected]>
  • Loading branch information
3 people authored Nov 16, 2023
1 parent 053c260 commit 2a3b385
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
33 changes: 18 additions & 15 deletions benches/benches/block_target_gas.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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::{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -462,6 +463,8 @@ fn block_target_gas(c: &mut Criterion) {

run_memory(&mut group);

run_other(&mut group);

group.finish();
}

Expand Down
2 changes: 2 additions & 0 deletions benches/benches/block_target_gas_set/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ pub mod contract;

pub mod memory;

pub mod other;

pub mod default_gas_costs;
41 changes: 41 additions & 0 deletions benches/benches/block_target_gas_set/other.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use crate::*;

// ECAL
// FLAG
// GM
// GTF

pub fn run_other(group: &mut BenchmarkGroup<WallTime>) {
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)
}

0 comments on commit 2a3b385

Please sign in to comment.