Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusting of the prices benchmarks after sanity check benchmarks #1494

Merged
merged 7 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions benches/benches/block_target_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ mod block_target_gas_set;
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

const STATE_SIZE: u64 = 10_000_000;
const TARGET_BLOCK_GAS_LIMIT: u64 = 1_000_000;
const BASE: u64 = 100_000;

Expand All @@ -100,7 +99,7 @@ impl SanityBenchmarkRunnerBuilder {
/// Creates a factory for benchmarks that share a service with a contract, `contract_id`, pre-
/// deployed.
pub fn new_shared(contract_id: ContractId) -> SharedSanityBenchmarkFactory {
let state_size = get_state_size();
let state_size = crate::utils::get_state_size();
let (service, rt) = service_with_contract_id(state_size, contract_id);
let rng = rand::rngs::StdRng::seed_from_u64(2322u64);
SharedSanityBenchmarkFactory {
Expand Down Expand Up @@ -251,7 +250,9 @@ fn run(
else {
panic!("The execution should fails with out of gas")
};
assert!(reason.contains("OutOfGas"));
if !reason.contains("OutOfGas") {
panic!("The test failed because of {}", reason);
}
Comment on lines +253 to +255
Copy link
Member

@Dentosal Dentosal Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
if !reason.contains("OutOfGas") {
panic!("The test failed because of {}", reason);
}
assert!(reason.contains("OutOfGas"), "The test failed because of {reason}");

}
})
});
Expand Down Expand Up @@ -344,19 +345,6 @@ fn service_with_contract_id(
(service, rt)
}

fn get_state_size() -> u64 {
// Override state size if the env var is set
let state_size = std::env::var_os("STATE_SIZE")
.map(|value| {
let value = value.to_str().unwrap();
let value = value.parse::<u64>().unwrap();
println!("Overriding state size with {}", value);
value
})
.unwrap_or(STATE_SIZE);
state_size
}

// Runs benchmark for `script` with prepared `service` and specified contract (by `contract_id`) which should be
// included in service.
// Also include additional inputs and outputs in transaction
Expand Down
10 changes: 3 additions & 7 deletions benches/benches/block_target_gas_set/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ pub fn run_crypto(group: &mut BenchmarkGroup<WallTime>) {
.collect(),
);

let message = fuel_core_types::fuel_crypto::Message::new(b"foo");
let message = Message::new(b"foo");
let ed19_secret = ed25519_dalek::SigningKey::generate(&mut rand::rngs::OsRng {});
let ed19_signature = ed19_secret.sign(&*message);

run(
"crypto/ed19 opcode",
group,
[
vec![
op::gtf_args(0x20, 0x00, GTFArgs::ScriptData),
op::addi(
0x21,
Expand All @@ -122,13 +122,9 @@ pub fn run_crypto(group: &mut BenchmarkGroup<WallTime>) {
ed19_signature.to_bytes().len().try_into().unwrap(),
),
op::addi(0x22, 0x21, message.as_ref().len().try_into().unwrap()),
op::movi(0x10, ed25519_dalek::PUBLIC_KEY_LENGTH.try_into().unwrap()),
op::aloc(0x10),
op::move_(0x11, RegId::HP),
op::ed19(0x20, 0x21, 0x22),
op::jmpb(RegId::ZERO, 0),
]
.to_vec(),
],
ed19_secret
.verifying_key()
.to_bytes()
Expand Down
212 changes: 106 additions & 106 deletions benches/benches/block_target_gas_set/default_gas_costs.rs
Original file line number Diff line number Diff line change
@@ -1,171 +1,171 @@
use super::*;
pub fn default_gas_costs() -> GasCostsValues {
GasCostsValues {
add: 1,
addi: 1,
add: 2,
addi: 2,
aloc: 1,
and: 1,
andi: 1,
bal: 26,
and: 2,
andi: 2,
bal: 328,
bhei: 1,
bhsh: 1,
burn: 27286,
cb: 1,
cfei: 1,
bhsh: 2,
burn: 27738,
cb: 2,
cfei: 2,
cfsi: 1,
croo: 37,
div: 1,
divi: 1,
eck1: 3351,
ecr1: 46061,
ed19: 3163,
eq: 1,
exp: 1,
expi: 1,
croo: 40,
div: 2,
divi: 2,
eck1: 3107,
ecr1: 42738,
ed19: 2897,
eq: 2,
exp: 2,
expi: 2,
flag: 1,
gm: 1,
gt: 1,
gtf: 1,
ji: 1,
jmp: 1,
jne: 1,
jnei: 1,
jnzi: 1,
gm: 2,
gt: 2,
gtf: 2,
ji: 2,
jmp: 2,
jne: 2,
jnei: 2,
jnzi: 2,
jmpf: 1,
jmpb: 1,
jnzf: 1,
jnzb: 1,
jnef: 1,
jneb: 1,
lb: 1,
log: 92,
lt: 1,
lw: 1,
mint: 25370,
mlog: 1,
lb: 2,
log: 87,
lt: 2,
lw: 2,
mint: 25515,
mlog: 2,
vm_initialization: 1,
modi: 1,
mod_op: 1,
movi: 1,
modi: 2,
mod_op: 2,
movi: 2,
mroo: 4,
mul: 1,
muli: 1,
mldv: 3,
mul: 2,
muli: 2,
mldv: 4,
noop: 1,
not: 1,
or: 1,
ori: 1,
poph: 1,
popl: 1,
pshh: 1,
pshl: 1,
or: 2,
ori: 2,
poph: 3,
popl: 3,
pshh: 3,
pshl: 3,
move_op: 1,
ret: 135,
sb: 1,
sll: 1,
slli: 1,
srl: 1,
srli: 1,
srw: 237,
sub: 1,
subi: 1,
sw: 1,
sww: 27313,
time: 1,
tr: 38459,
tro: 26269,
wdcm: 1,
wqcm: 2,
wdop: 2,
wqop: 2,
wdml: 2,
wqml: 3,
wddv: 4,
ret: 127,
sb: 2,
sll: 2,
slli: 2,
srl: 2,
srli: 2,
srw: 224,
sub: 2,
subi: 2,
sw: 2,
sww: 26247,
time: 76,
tr: 38925,
tro: 26756,
wdcm: 2,
wqcm: 3,
wdop: 3,
wqop: 3,
wdml: 3,
wqml: 4,
wddv: 5,
wqdv: 6,
wdmd: 10,
wqmd: 16,
wdam: 8,
wqmd: 17,
wdam: 9,
wqam: 10,
wdmm: 9,
wqmm: 9,
xor: 1,
xori: 1,
wdmm: 10,
wqmm: 10,
xor: 2,
xori: 2,
call: DependentCost::LightOperation {
base: 1171,
units_per_gas: 47,
base: 17510,
units_per_gas: 5,
},
ccp: DependentCost::LightOperation {
base: 39,
units_per_gas: 65,
base: 54,
units_per_gas: 21,
},
csiz: DependentCost::LightOperation {
base: 49,
units_per_gas: 214,
base: 58,
units_per_gas: 212,
},
k256: DependentCost::LightOperation {
base: 277,
units_per_gas: 3,
base: 259,
units_per_gas: 4,
},
ldc: DependentCost::LightOperation {
base: 37,
units_per_gas: 63,
base: 42,
units_per_gas: 65,
},
logd: DependentCost::LightOperation {
base: 444,
base: 413,
units_per_gas: 3,
},
mcl: DependentCost::LightOperation {
base: 1,
units_per_gas: 500,
base: 2,
units_per_gas: 568,
},
mcli: DependentCost::LightOperation {
base: 1,
units_per_gas: 500,
base: 3,
units_per_gas: 568,
},
mcp: DependentCost::LightOperation {
base: 2,
units_per_gas: 493,
base: 3,
units_per_gas: 470,
},
mcpi: DependentCost::LightOperation {
base: 4,
units_per_gas: 1023,
base: 6,
units_per_gas: 682,
},
meq: DependentCost::LightOperation {
base: 2,
units_per_gas: 1111,
base: 10,
units_per_gas: 1161,
},
rvrt: 136,
rvrt: 127,
s256: DependentCost::LightOperation {
base: 44,
base: 42,
units_per_gas: 3,
},
scwq: DependentCost::HeavyOperation {
base: 28687,
gas_per_unit: 27036,
base: 27337,
gas_per_unit: 25552,
},
smo: DependentCost::LightOperation {
base: 58089,
base: 55851,
units_per_gas: 1,
},
srwq: DependentCost::LightOperation {
base: 121,
units_per_gas: 1,
srwq: DependentCost::HeavyOperation {
base: 501,
gas_per_unit: 22,
},
swwq: DependentCost::HeavyOperation {
base: 26790,
gas_per_unit: 25451,
base: 25619,
gas_per_unit: 24002,
},
contract_root: DependentCost::LightOperation {
base: 44,
base: 43,
units_per_gas: 2,
},
state_root: DependentCost::HeavyOperation {
base: 347,
gas_per_unit: 176,
base: 324,
gas_per_unit: 164,
},
new_storage_per_byte: 1,
retd: DependentCost::LightOperation {
base: 466,
base: 434,
units_per_gas: 3,
},
}
Expand Down
7 changes: 1 addition & 6 deletions benches/benches/block_target_gas_set/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ pub fn run_memory(group: &mut BenchmarkGroup<WallTime>) {
run(
"memory/aloc opcode",
group,
[
op::movi(0x10, 1000),
op::aloc(0x10),
op::jmpb(RegId::ZERO, 0),
]
.to_vec(),
[op::movi(0x10, 0), op::aloc(0x10), op::jmpb(RegId::ZERO, 0)].to_vec(),
MitchTurner marked this conversation as resolved.
Show resolved Hide resolved
vec![],
);

Expand Down
15 changes: 15 additions & 0 deletions benches/benches/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ use fuel_core_types::{
},
};

pub const STATE_SIZE: u64 = 10_000_000;

pub fn get_state_size() -> u64 {
// Override state size if the env var is set
let state_size = std::env::var_os("STATE_SIZE")
.map(|value| {
let value = value.to_str().unwrap();
let value = value.parse::<u64>().unwrap();
println!("Overriding state size with {}", value);
value
})
.unwrap_or(STATE_SIZE);
state_size
}

/// Allocates a byte array from heap and initializes it. Then points `reg` to it.
fn aloc_bytearray<const S: usize>(reg: u8, v: [u8; S]) -> Vec<Instruction> {
let mut ops = vec![op::movi(reg, S as u32), op::aloc(reg)];
Expand Down
Loading
Loading