Skip to content

Commit

Permalink
Re-establish pallet_revive weights baseline (#5845)
Browse files Browse the repository at this point in the history
- update baseline for pallet_revive
- update cmd pipeline name
- Fix compilation after renaming some of benchmarks in pallet_revive.
[Runtime Dev]. Changed the "instr" benchmark so that it should no longer
return to little weight. It is still bogus but at least benchmarking
should not work. (by @athei )

---------

Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com>
Co-authored-by: command-bot <>
  • Loading branch information
4 people authored Oct 2, 2024
1 parent 8614dc0 commit 972b053
Show file tree
Hide file tree
Showing 8 changed files with 785 additions and 965 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cmd-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:
cancel-in-progress: true

jobs:
test:
test-cmd-bot:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
15 changes: 15 additions & 0 deletions prdoc/pr_5845.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Fix compilation after renaming some of benchmarks in pallet_revive.

doc:
- audience: Runtime Dev
description: |
Changed the "instr" benchmark so that it should no longer return to little weight. It is still bogus but at least benchmarking should not work.

crates:
- name: pallet-revive
bump: patch
- name: pallet-revive-fixtures
bump: major
12 changes: 7 additions & 5 deletions substrate/frame/revive/fixtures/contracts/instr_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,22 @@ extern crate common;
use common::input;
use uapi::{HostFn, HostFnImpl as api, ReturnFlags};

static mut MULT: [u32; 5_000] = [1u32; 5_000];

#[no_mangle]
#[polkavm_derive::polkavm_export]
pub extern "C" fn deploy() {}

#[no_mangle]
#[polkavm_derive::polkavm_export]
pub extern "C" fn call() {
input!(rounds: u32, start: u32, div: u32, mult: u32, add: u32, );
input!(rounds: u32, );

let mut acc = start;
let mut acc = 5;

for _ in 0..rounds {
acc = acc / div * mult + add;
for i in 0..rounds {
acc = acc * unsafe { MULT[i as usize] }
}

api::return_value(ReturnFlags::empty(), start.to_le_bytes().as_ref());
api::return_value(ReturnFlags::empty(), acc.to_le_bytes().as_ref());
}
4 changes: 1 addition & 3 deletions substrate/frame/revive/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1727,11 +1727,9 @@ mod benchmarks {
// Benchmark the execution of instructions.
#[benchmark(pov_mode = Ignored)]
fn instr(r: Linear<0, INSTR_BENCHMARK_RUNS>) {
// (round, start, div, mult, add)
let input = (r, 1_000u32, 2u32, 3u32, 100u32).encode();
let mut setup = CallSetup::<T>::new(WasmModule::instr());
let (mut ext, module) = setup.ext();
let prepared = CallSetup::<T>::prepare_call(&mut ext, module, input);
let prepared = CallSetup::<T>::prepare_call(&mut ext, module, r.encode());
#[block]
{
prepared.call().unwrap();
Expand Down
4 changes: 1 addition & 3 deletions substrate/frame/revive/src/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ impl<T: Config> EngineMeter<T> {
// We execute 6 different instructions therefore we have to divide the actual
// computed gas costs by 6 to have a rough estimate as to how expensive each
// single executed instruction is going to be.
let instr_cost = T::WeightInfo::instr_i64_load_store(1)
.saturating_sub(T::WeightInfo::instr_i64_load_store(0))
.ref_time();
let instr_cost = T::WeightInfo::instr(1).saturating_sub(T::WeightInfo::instr(0)).ref_time();
instr_cost / 6
}
}
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/revive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ pub mod pallet {
/// only be instantiated by permissioned entities. The same is true when uploading
/// through [`Self::instantiate_with_code`].
#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::upload_code_determinism_enforced(code.len() as u32))]
#[pallet::weight(T::WeightInfo::upload_code(code.len() as u32))]
pub fn upload_code(
origin: OriginFor<T>,
code: Vec<u8>,
Expand Down
8 changes: 4 additions & 4 deletions substrate/frame/revive/src/wasm/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ pub enum RuntimeCosts {
CallerIsRoot,
/// Weight of calling `seal_address`.
Address,
/// Weight of calling `seal_gas_left`.
GasLeft,
/// Weight of calling `seal_weight_left`.
WeightLeft,
/// Weight of calling `seal_balance`.
Balance,
/// Weight of calling `seal_balance_of`.
Expand Down Expand Up @@ -457,7 +457,7 @@ impl<T: Config> Token<T> for RuntimeCosts {
CallerIsOrigin => T::WeightInfo::seal_caller_is_origin(),
CallerIsRoot => T::WeightInfo::seal_caller_is_root(),
Address => T::WeightInfo::seal_address(),
GasLeft => T::WeightInfo::seal_gas_left(),
WeightLeft => T::WeightInfo::seal_weight_left(),
Balance => T::WeightInfo::seal_balance(),
BalanceOf => T::WeightInfo::seal_balance_of(),
ValueTransferred => T::WeightInfo::seal_value_transferred(),
Expand Down Expand Up @@ -1501,7 +1501,7 @@ pub mod env {
out_ptr: u32,
out_len_ptr: u32,
) -> Result<(), TrapReason> {
self.charge_gas(RuntimeCosts::GasLeft)?;
self.charge_gas(RuntimeCosts::WeightLeft)?;
let gas_left = &self.ext.gas_meter().gas_left().encode();
Ok(self.write_sandbox_output(
memory,
Expand Down
Loading

0 comments on commit 972b053

Please sign in to comment.