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

test: Add state root and contract id benchmarks #1462

Merged
merged 38 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
dca8bd6
Create contract root bench
bvrooman Oct 25, 2023
291e88d
Update CHANGELOG.md
bvrooman Oct 25, 2023
4756bfe
Merge branch 'master' into bvrooman/test/contract_root_bench
bvrooman Oct 25, 2023
a99e210
Simplify the benchmark for root calcualtion
xgreenx Oct 25, 2023
c679465
Add contract root bench to gas costs in collect
bvrooman Oct 27, 2023
75aa6af
Merge branch 'master' into bvrooman/test/contract_root_bench
bvrooman Oct 27, 2023
4d7485d
Update contract_root to dependent cost
bvrooman Oct 27, 2023
6154ece
Remove dbg
bvrooman Oct 27, 2023
9d19ae4
Merge branch 'master' into bvrooman/test/contract_root_bench
bvrooman Oct 28, 2023
64ec816
Remove test code
bvrooman Oct 28, 2023
91cc7da
Add state root and contract id benchmarks
bvrooman Oct 29, 2023
97d018a
Remove criterion main from contract
bvrooman Oct 30, 2023
cbb8137
Remove contract root main
bvrooman Oct 30, 2023
5a4c175
Merge branch 'master' into bvrooman/test/contract_root_bench
Oct 30, 2023
904ed1b
Update CHANGELOG.md
bvrooman Oct 30, 2023
f406312
Merge branch 'bvrooman/test/contract_root_bench' of https://github.co…
bvrooman Oct 30, 2023
fea1686
Revert "Update CHANGELOG.md"
bvrooman Oct 30, 2023
ad761cd
Update CHANGELOG.md
bvrooman Oct 30, 2023
653be70
Merge branch 'bvrooman/test/contract_root_bench' into bvrooman/test/s…
bvrooman Oct 30, 2023
ad5a2a1
Merge branch 'master' into bvrooman/test/contract_root_bench
Oct 31, 2023
87bd4f3
Merge branch 'bvrooman/test/contract_root_bench' into bvrooman/test/s…
Oct 31, 2023
abb2fae
Merge branch 'master' into bvrooman/test/contract_root_bench
Oct 31, 2023
739d805
Merge branch 'bvrooman/test/contract_root_bench' into bvrooman/test/s…
Oct 31, 2023
ac59bf4
Merge branch 'master' into bvrooman/test/contract_root_bench
bvrooman Nov 1, 2023
7c26a15
Corrections after merge
bvrooman Nov 1, 2023
457cd94
Fix warnings
bvrooman Nov 1, 2023
a8914d3
Merge branch 'bvrooman/test/contract_root_bench' into bvrooman/test/s…
bvrooman Nov 1, 2023
ab18150
Update contract.rs
bvrooman Nov 1, 2023
5078702
Remove unused imports
bvrooman Nov 1, 2023
954e759
Update contract.rs
bvrooman Nov 1, 2023
efd65f0
Merge branch 'bvrooman/test/contract_root_bench' into bvrooman/test/s…
bvrooman Nov 1, 2023
0445c76
Update contract_root.rs
bvrooman Nov 1, 2023
139e6ea
Merge branch 'bvrooman/test/contract_root_bench' into bvrooman/test/s…
bvrooman Nov 1, 2023
357e603
Revert bad merge to changelog
bvrooman Nov 1, 2023
94df2c5
Merge branch 'bvrooman/test/contract_root_bench' into bvrooman/test/s…
Nov 1, 2023
ed5bc3e
Update schema.sdl
bvrooman Nov 1, 2023
d176900
Merge branch 'bvrooman/test/state_root_contract_id_bench' of https://…
bvrooman Nov 1, 2023
dcaacb3
Merge branch 'master' into bvrooman/test/state_root_contract_id_bench
bvrooman Nov 1, 2023
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 @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
Description of the upcoming release here.

### Added
- [#1642](https://github.com/FuelLabs/fuel-core/pull/1462): Added benchmark to measure the performance of contract state and contract ID calculation; use for gas costing.
- [#1465](https://github.com/FuelLabs/fuel-core/pull/1465): Improvements for keygen cli and crates
- [#1457](https://github.com/FuelLabs/fuel-core/pull/1457): Fixing incorrect measurement for fast(µs) opcodes.
- [#1456](https://github.com/FuelLabs/fuel-core/pull/1456): Added flushing of the RocksDB during a graceful shutdown.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use criterion::{
Criterion,
Throughput,
};
use fuel_core_types::fuel_tx::Contract;
use fuel_core_types::fuel_tx::{
Contract,
StorageSlot,
};
use rand::{
rngs::StdRng,
Rng,
Expand Down Expand Up @@ -46,3 +49,27 @@ pub fn contract_root(c: &mut Criterion) {

group.finish();
}

pub fn state_root(c: &mut Criterion) {
let rng = &mut StdRng::seed_from_u64(8586);

let mut group = c.benchmark_group("state_root");

const N: usize = 20;
let sizes = successors(Some(2), |n| Some(n * 2)).take(N);
for (i, size) in sizes.enumerate() {
let gen_storage_slot = || rng.gen::<StorageSlot>();
let storage_slots = std::iter::repeat_with(gen_storage_slot)
.take(size)
.collect::<Vec<_>>();
group.throughput(Throughput::Bytes(size as u64));
let name = format!("state_root_from_slots_2^{exp:#02}", exp = i + 1);
group.bench_function(name, |b| {
b.iter(|| {
Contract::initial_state_root(storage_slots.iter());
})
});
}

group.finish();
}
5 changes: 3 additions & 2 deletions benches/benches/vm.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod contract_root;
mod contract;
mod utils;
mod vm_set;

Expand All @@ -11,7 +11,7 @@ use criterion::{
Criterion,
};

use contract_root::*;
use contract::*;
use fuel_core_benches::*;
use fuel_core_storage::transactional::Transaction;
use fuel_core_types::fuel_asm::Instruction;
Expand Down Expand Up @@ -95,6 +95,7 @@ fn vm(c: &mut Criterion) {
flow::run(c);
mem::run(c);
contract_root(c);
state_root(c);
}

criterion_group!(benches, vm);
Expand Down
Loading