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 benches that are affected by receipts #1454

Merged
merged 24 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
93c6ecc
WIP
Dentosal Oct 26, 2023
f06f674
Fix upgrade to latest fuelvm
Dentosal Oct 26, 2023
6d646c3
Add receipts to all related benches
Dentosal Oct 27, 2023
4fcc611
changelog
Dentosal Oct 27, 2023
0ac658a
Merge branch 'master' into dento/receipt-opcode-gas-benches
Dentosal Oct 27, 2023
8f41b04
Move receipt context to work without PrepareCall
Dentosal Nov 1, 2023
210946b
Add a black_box after the benchmark do deny optimizations
Dentosal Nov 1, 2023
91e8d70
Merge branch 'master' into dento/receipt-opcode-gas-benches
Dentosal Nov 1, 2023
53617b1
Fix after merge
Dentosal Nov 1, 2023
35f284f
Latest rustfmt
Dentosal Nov 1, 2023
7fcbde5
Update snapshots
Dentosal Nov 1, 2023
07f10bf
Attempt to add one more black_box to fix timings
Dentosal Nov 1, 2023
c552c70
Disable sequental storage opcodes
Dentosal Nov 1, 2023
53708ac
More black_box
Dentosal Nov 1, 2023
1ad57f8
Attempt more accurate timing
Dentosal Nov 7, 2023
2aa4f17
Add debug info for unstable env bench
Dentosal Nov 7, 2023
5f5ea52
Remove reset part of instr bench
Dentosal Nov 7, 2023
a0139df
Merge branch 'master' into dento/receipt-opcode-gas-benches
Dentosal Nov 8, 2023
a53fe1d
Set the number of receipts in bench to u16::MAX-1
Dentosal Nov 8, 2023
5c39463
Merge branch 'master' into dento/receipt-opcode-gas-benches
xgreenx Nov 10, 2023
27ae51e
Merge remote-tracking branch 'origin/master' into dento/receipt-opcod…
xgreenx Nov 10, 2023
a70e841
Master merge
xgreenx Nov 10, 2023
8f25c5e
Merge branch 'master' into dento/receipt-opcode-gas-benches
Dentosal Nov 20, 2023
f4203c8
Revert Cargo.lock to master
Dentosal Nov 20, 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 @@ -79,6 +79,7 @@ Description of the upcoming release here.
- [#1393](https://github.com/FuelLabs/fuel-core/pull/1393): Increase heartbeat timeout from `2` to `60` seconds, as suggested in [this issue](https://github.com/FuelLabs/fuel-core/issues/1330).
- [#1395](https://github.com/FuelLabs/fuel-core/pull/1395): Add DependentCost benchmarks for `k256`, `s256` and `mcpi` instructions.
- [#1408](https://github.com/FuelLabs/fuel-core/pull/1408): Update gas benchmarks for storage opcodes to use a pre-populated database to get more accurate worst-case costs.
- [#1454](https://github.com/FuelLabs/fuel-core/pull/1454): Update gas benchmarks for opcodes that append receipts.

#### Breaking
- [#1491](https://github.com/FuelLabs/fuel-core/pull/1491): Removed unused request and response variants from the Gossipsub implementation, as well as related definitions and tests. Specifically, this removes gossiping of `ConsensusVote` and `NewBlock` events.
Expand Down
38 changes: 19 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions benches/benches/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ use fuel_core_types::{
Instruction,
RegId,
},
fuel_tx,
fuel_types::{
RegisterId,
Word,
},
fuel_vm::interpreter::ReceiptsCtx,
};
use rand::{
rngs::StdRng,
Rng,
};

pub const STATE_SIZE: u64 = 10_000_000;
Expand Down Expand Up @@ -70,3 +76,24 @@ pub fn set_full_word(r: RegisterId, v: Word) -> Vec<Instruction> {
ops.pop().unwrap(); // Remove last shift
ops
}

const BENCH_RECEIPTS: usize = (u16::MAX - 1) as usize;

/// Testing receipt context
#[allow(dead_code)] // Unsure why this is needed, as the code is used
pub fn make_receipts(rng: &mut StdRng) -> ReceiptsCtx {
let mut ctx = ReceiptsCtx::default();
for _ in 0..BENCH_RECEIPTS {
ctx.push(fuel_tx::Receipt::Log {
id: rng.gen(),
ra: rng.gen(),
rb: rng.gen(),
rc: rng.gen(),
rd: rng.gen(),
pc: rng.gen(),
is: rng.gen(),
})
.expect("Context should not be full");
}
ctx
}
22 changes: 16 additions & 6 deletions benches/benches/vm_set/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use std::{
sync::Arc,
};

use crate::utils::make_receipts;

use super::run_group_ref;

use criterion::{
Expand Down Expand Up @@ -130,6 +132,8 @@ pub fn run(c: &mut Criterion) {

let db = BenchDb::new(&contract).expect("Unable to fill contract storage");

let receipts_ctx = make_receipts(rng);

run_group_ref(
&mut c.benchmark_group("bal"),
"bal",
Expand Down Expand Up @@ -279,7 +283,8 @@ pub fn run(c: &mut Criterion) {
.with_db(db.to_vm_database())
.with_contract_code(code)
.with_data(data)
.with_prepare_script(prepare_script),
.with_prepare_script(prepare_script)
.with_call_receipts(receipts_ctx.clone()),
);
}

Expand Down Expand Up @@ -427,7 +432,8 @@ pub fn run(c: &mut Criterion) {
db.to_vm_database(),
op::mint(RegId::ONE, RegId::ZERO),
)
.expect("failed to prepare contract"),
.expect("failed to prepare contract")
.with_call_receipts(receipts_ctx.clone()),
);

run_group_ref(
Expand All @@ -439,7 +445,8 @@ pub fn run(c: &mut Criterion) {
op::burn(RegId::ONE, RegId::HP),
)
.expect("failed to prepare contract")
.prepend_prepare_script(vec![op::movi(0x10, 32), op::aloc(0x10)]),
.prepend_prepare_script(vec![op::movi(0x10, 32), op::aloc(0x10)])
.with_call_receipts(receipts_ctx.clone()),
);

run_group_ref(
Expand All @@ -459,7 +466,8 @@ pub fn run(c: &mut Criterion) {
db.to_vm_database(),
op::tr(0x15, 0x14, 0x15),
)
.expect("failed to prepare contract");
.expect("failed to prepare contract")
.with_call_receipts(receipts_ctx.clone());
input
.prepare_script
.extend(vec![op::movi(0x15, 2000), op::movi(0x14, 100)]);
Expand All @@ -473,7 +481,8 @@ pub fn run(c: &mut Criterion) {
db.to_vm_database(),
op::tro(RegId::ZERO, 0x15, 0x14, RegId::HP),
)
.expect("failed to prepare contract");
.expect("failed to prepare contract")
.with_call_receipts(receipts_ctx.clone());
let coin_output = Output::variable(Address::zeroed(), 100, AssetId::zeroed());
input.outputs.push(coin_output);
let predicate = op::ret(RegId::ONE).to_bytes().to_vec();
Expand Down Expand Up @@ -546,7 +555,8 @@ pub fn run(c: &mut Criterion) {
db.to_vm_database(),
op::smo(0x15, 0x16, 0x17, 0x18),
)
.expect("failed to prepare contract");
.expect("failed to prepare contract")
.with_call_receipts(receipts_ctx.clone());
input.post_call.extend(vec![
op::gtf_args(0x15, 0x00, GTFArgs::ScriptData),
// Offset 32 + 8 + 8 + 32
Expand Down
30 changes: 21 additions & 9 deletions benches/benches/vm_set/flow.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use super::run_group_ref;

use crate::utils::arb_dependent_cost_values;
use crate::utils::{
arb_dependent_cost_values,
make_receipts,
};
use criterion::{
Criterion,
Throughput,
Expand All @@ -16,6 +19,7 @@ pub fn run(c: &mut Criterion) {
let rng = &mut StdRng::seed_from_u64(2322u64);

let linear = arb_dependent_cost_values();
let receipts_ctx = make_receipts(rng);

run_group_ref(
&mut c.benchmark_group("jmp"),
Expand Down Expand Up @@ -47,13 +51,15 @@ pub fn run(c: &mut Criterion) {
run_group_ref(
&mut c.benchmark_group("ret_script"),
"ret_script",
VmBench::new(op::ret(RegId::ONE)),
VmBench::new(op::ret(RegId::ONE)).with_call_receipts(receipts_ctx.clone()),
);

run_group_ref(
&mut c.benchmark_group("ret_contract"),
"ret_contract",
VmBench::contract(rng, op::ret(RegId::ONE)).unwrap(),
VmBench::contract(rng, op::ret(RegId::ONE))
.unwrap()
.with_call_receipts(receipts_ctx.clone()),
);

let mut retd_contract = c.benchmark_group("retd_contract");
Expand All @@ -64,7 +70,8 @@ pub fn run(c: &mut Criterion) {
format!("{i}"),
VmBench::contract(rng, op::retd(RegId::ONE, 0x10))
.unwrap()
.with_post_call(vec![op::movi(0x10, *i)]),
.with_post_call(vec![op::movi(0x10, *i)])
.with_call_receipts(receipts_ctx.clone()),
);
}
retd_contract.finish();
Expand All @@ -77,27 +84,31 @@ pub fn run(c: &mut Criterion) {
format!("{i}"),
VmBench::contract(rng, op::retd(RegId::ONE, 0x10))
.unwrap()
.with_post_call(vec![op::movi(0x10, *i)]),
.with_post_call(vec![op::movi(0x10, *i)])
.with_call_receipts(receipts_ctx.clone()),
);
}
retd_script.finish();

run_group_ref(
&mut c.benchmark_group("rvrt_script"),
"rvrt_script",
VmBench::new(op::rvrt(RegId::ONE)),
VmBench::new(op::rvrt(RegId::ONE)).with_call_receipts(receipts_ctx.clone()),
);

run_group_ref(
&mut c.benchmark_group("rvrt_contract"),
"rvrt_contract",
VmBench::contract(rng, op::ret(RegId::ONE)).unwrap(),
VmBench::contract(rng, op::ret(RegId::ONE))
.unwrap()
.with_call_receipts(receipts_ctx.clone()),
);

run_group_ref(
&mut c.benchmark_group("log"),
"log",
VmBench::new(op::log(0x10, 0x11, 0x12, 0x13)),
VmBench::new(op::log(0x10, 0x11, 0x12, 0x13))
.with_call_receipts(receipts_ctx.clone()),
);

let mut logd = c.benchmark_group("logd");
Expand All @@ -107,7 +118,8 @@ pub fn run(c: &mut Criterion) {
&mut logd,
format!("{i}"),
VmBench::new(op::logd(0x10, 0x11, RegId::ZERO, 0x13))
.with_prepare_script(vec![op::movi(0x13, *i)]),
.with_prepare_script(vec![op::movi(0x13, *i)])
.with_call_receipts(receipts_ctx.clone()),
);
}
logd.finish();
Expand Down
Loading
Loading