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

Updated croo opcode benchmark to depend on the contract size #1876

Merged
merged 6 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Changed

- [#1876](https://github.com/FuelLabs/fuel-core/pull/1876): Updated benchmark to include the worst scenario for `CROO` opcode.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- [#1876](https://github.com/FuelLabs/fuel-core/pull/1876): Updated benchmark to include the worst scenario for `CROO` opcode.
- [#1876](https://github.com/FuelLabs/fuel-core/pull/1876): Updated benchmark to include the worst scenario for `CROO` opcode. Also include consensus parameters in bench output.


### Added

Expand Down
2 changes: 1 addition & 1 deletion benches/benches/vm_initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub fn vm_initialization(c: &mut Criterion) {

// 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;
const TX_SIZE_POWER_OF_TWO: usize = 13;
Copy link
Member

Choose a reason for hiding this comment

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

The old number matched the comment above. Is is intentionally not updated?


for i in 5..=TX_SIZE_POWER_OF_TWO {
let size = 8 * (1 << i);
Expand Down
33 changes: 27 additions & 6 deletions benches/benches/vm_set/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,18 +558,39 @@ pub fn run(c: &mut Criterion) {
VmBench::new(op::cfsi(0)),
);

{
let mut input = VmBench::contract(rng, op::croo(0x14, 0x16))
.expect("failed to prepare contract");
input.post_call.extend(vec![
let mut croo = c.benchmark_group("croo");

for i in linear.clone() {
let mut code = vec![0u8; i as usize];

rng.fill_bytes(&mut code);

let mut code = ContractCode::from(code);
code.id = VmBench::CONTRACT;

let data = code.id.iter().copied().collect();

let prepare_script = vec![
op::gtf_args(0x16, 0x00, GTFArgs::ScriptData),
op::movi(0x15, 2000),
op::aloc(0x15),
op::move_(0x14, RegId::HP),
]);
run_group_ref(&mut c.benchmark_group("croo"), "croo", input);
];

croo.throughput(Throughput::Bytes(i));

run_group_ref(
&mut croo,
format!("{i}"),
VmBench::new(op::croo(0x14, 0x16))
.with_contract_code(code)
.with_data(data)
.with_prepare_script(prepare_script),
);
}

croo.finish();

run_group_ref(
&mut c.benchmark_group("flag"),
"flag",
Expand Down
15 changes: 14 additions & 1 deletion benches/src/bin/collect.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use clap::Parser;
use fuel_core_types::fuel_tx::consensus_parameters::gas::GasCostsValuesV1;
use fuel_core_types::fuel_tx::{
consensus_parameters::gas::GasCostsValuesV1,
ConsensusParameters,
GasCosts,
};
use serde::{
Deserialize,
Serialize,
Expand Down Expand Up @@ -59,6 +63,7 @@ enum OutputFormat {
Yaml,
Json,
Rust,
ConsensusParameters,
}

#[derive(Debug)]
Expand Down Expand Up @@ -223,6 +228,7 @@ fn main() {
OutputFormat::Yaml => output.push("gas-costs.yaml"),
OutputFormat::Json => output.push("gas-costs.json"),
OutputFormat::Rust => output.push("gas-costs.rs"),
OutputFormat::ConsensusParameters => output.push("consensus-parameters.rs"),
}
}

Expand All @@ -237,6 +243,13 @@ fn main() {
serde_json::to_writer(writer, &state.to_json()).unwrap();
}
OutputFormat::Rust => write!(&mut writer, "{}", state.to_rust_code()).unwrap(),
OutputFormat::ConsensusParameters => {
let gas_costs = GasCosts::new(state.to_gas_costs().into());
let mut consensus_parameters = ConsensusParameters::default();
consensus_parameters.set_gas_costs(gas_costs);

serde_json::to_writer_pretty(writer, &consensus_parameters).unwrap();
}
}
println!("Successfully wrote output to {}", output.display());
}
Expand Down
Loading