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

Update default gas costs based on 0.35.0 benchmarks #2153

Merged
merged 18 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed

#### Breaking
- [2153](https://github.com/FuelLabs/fuel-core/pull/2153): Updated default gas costs for the local testnet configuration to match `fuel-core 0.35.0`.
- [2145](https://github.com/FuelLabs/fuel-core/pull/2145): feat: Introduce time port in PoA service.
- [2155](https://github.com/FuelLabs/fuel-core/pull/2155): Added trait declaration for block committer data
- [2142](https://github.com/FuelLabs/fuel-core/pull/2142): Added benchmarks for varied forms of db lookups to assist in optimizations.
Expand Down
2 changes: 1 addition & 1 deletion benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fuel-core = { path = "../crates/fuel-core", default-features = false, features =
fuel-core-chain-config = { workspace = true }
fuel-core-database = { path = "./../crates/database" }
fuel-core-services = { path = "./../crates/services" }
fuel-core-storage = { path = "./../crates/storage" }
fuel-core-storage = { path = "./../crates/storage", features = ["smt"] }
fuel-core-sync = { path = "./../crates/services/sync", features = [
"benchmarking",
] }
Expand Down
77 changes: 73 additions & 4 deletions benches/benches/vm_set/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ pub fn run(c: &mut Criterion) {
let mut ccp = c.benchmark_group("ccp");

for i in linear.clone() {
let mut code = vec![op::noop(); i as usize].into_iter().collect::<Vec<_>>();
let mut code = vec![0; i as usize];

rng.fill_bytes(&mut code);

Expand All @@ -391,10 +391,7 @@ pub fn run(c: &mut Criterion) {
op::movi(0x12, 100_000),
op::movi(0x13, i.try_into().unwrap()),
op::cfe(0x13),
op::movi(0x14, i.try_into().unwrap()),
op::movi(0x15, i.try_into().unwrap()),
op::add(0x15, 0x15, 0x15),
op::addi(0x15, 0x15, 32),
op::aloc(0x15),
op::move_(0x15, RegId::HP),
];
Expand All @@ -413,6 +410,51 @@ pub fn run(c: &mut Criterion) {

ccp.finish();

let mut bldd = c.benchmark_group("bldd");

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

rng.fill_bytes(&mut code);

let blob = BlobCode::from(code);

let data = blob
.id
.iter()
.copied()
.chain((0 as Word).to_be_bytes().iter().copied())
.chain((0 as Word).to_be_bytes().iter().copied())
.chain(AssetId::default().iter().copied())
.collect();

let prepare_script = vec![
op::gtf_args(0x10, 0x00, GTFArgs::ScriptData),
op::addi(0x11, 0x10, BlobId::LEN.try_into().unwrap()),
op::addi(0x11, 0x11, WORD_SIZE.try_into().unwrap()),
op::addi(0x11, 0x11, WORD_SIZE.try_into().unwrap()),
op::movi(0x12, 100_000),
op::movi(0x13, i.try_into().unwrap()),
op::cfe(0x13),
op::movi(0x15, i.try_into().unwrap()),
op::aloc(0x15),
op::move_(0x15, RegId::HP),
];

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

run_group_ref(
&mut bldd,
format!("{i}"),
VmBench::new(op::bldd(0x15, 0x10, RegId::ZERO, 0x13))
.with_blob(blob)
.with_data(data)
.with_prepare_script(prepare_script),
);
}

bldd.finish();

let mut csiz = c.benchmark_group("csiz");

for i in linear.clone() {
Expand Down Expand Up @@ -441,6 +483,33 @@ pub fn run(c: &mut Criterion) {

csiz.finish();

let mut bsiz = c.benchmark_group("bsiz");
Copy link
Member

Choose a reason for hiding this comment

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

How were we getting the values for bldd and bsiz before? It looks like they didn't exist before.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We had a task to add benchamrks for these upcodes: #2049

Before we just copied values from similar contract opcodes


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

rng.fill_bytes(&mut code);

let blob = BlobCode::from(code);

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

let prepare_script = vec![op::gtf_args(0x10, 0x00, GTFArgs::ScriptData)];

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

run_group_ref(
&mut bsiz,
format!("{i}"),
VmBench::new(op::bsiz(0x11, 0x10))
.with_blob(blob)
.with_data(data)
.with_prepare_script(prepare_script),
);
}

bsiz.finish();

run_group_ref(
&mut c.benchmark_group("bhei"),
"bhei",
Expand Down
18 changes: 14 additions & 4 deletions benches/benches/vm_set/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ use criterion::{
Throughput,
};
use fuel_core_benches::*;
use fuel_core_types::fuel_asm::*;
use fuel_core_types::{
fuel_asm::*,
fuel_vm::{
consts::MEM_SIZE,
interpreter::MemoryInstance,
},
};

pub fn run(c: &mut Criterion) {
run_group_ref(
Expand Down Expand Up @@ -60,8 +66,11 @@ pub fn run(c: &mut Criterion) {
cfe_linear.push(30_000_000);
cfe_linear.push(60_000_000);
for i in cfe_linear {
let bench =
VmBench::new(op::cfe(0x10)).with_prepare_script(set_full_word(0x10, i));
let prepare_script = set_full_word(0x10, i);
let memory = MemoryInstance::from(vec![123; MEM_SIZE]);
let bench = VmBench::new(op::cfe(0x10))
.with_prepare_script(prepare_script)
.with_memory(memory);
cfe.throughput(Throughput::Bytes(i));
run_group_ref(&mut cfe, format!("{i}"), bench);
}
Expand All @@ -77,7 +86,8 @@ pub fn run(c: &mut Criterion) {
cfei_linear.push(1_000_000);
cfei_linear.push(10_000_000);
for i in cfei_linear {
let bench = VmBench::new(op::cfei(i as u32));
let memory = MemoryInstance::from(vec![123; MEM_SIZE]);
rafal-ch marked this conversation as resolved.
Show resolved Hide resolved
let bench = VmBench::new(op::cfei(i as u32)).with_memory(memory);
Copy link
Member

Choose a reason for hiding this comment

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

Why did we need the memory added here?/Why didn't we have it before?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just added it to remove any potential optimizations related to zeroed memory. Now all benchmarks use non zeroed memory

cfei.throughput(Throughput::Bytes(i));
run_group_ref(&mut cfei, format!("{i}"), bench);
}
Expand Down
2 changes: 1 addition & 1 deletion benches/src/bin/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ fn linear_regression(x_y: Vec<(u64, u64)>) -> f64 {
}

fn dependent_cost(name: &String, x_y: Vec<(u64, u64)>) -> DependentCost {
const NEAR_LINEAR: f64 = 0.1;
const NEAR_LINEAR: f64 = 0.2;
rafal-ch marked this conversation as resolved.
Show resolved Hide resolved

#[derive(PartialEq, Eq)]
enum Type {
Expand Down
Loading
Loading