diff --git a/core-backend/common/src/funcs.rs b/core-backend/common/src/funcs.rs index ae4ee8fa71d..40030fe5728 100644 --- a/core-backend/common/src/funcs.rs +++ b/core-backend/common/src/funcs.rs @@ -232,7 +232,7 @@ where .map_err(Into::into) } - #[host(cost = RuntimeCosts::Alloc)] + #[host(cost = RuntimeCosts::Alloc(pages))] pub fn alloc(ctx: &mut R, pages: u32) -> Result { let res = ctx.alloc(pages); let res = ctx.process_alloc_func_result(res)?; diff --git a/core-backend/sandbox/src/lib.rs b/core-backend/sandbox/src/lib.rs index 7e4b1fec3df..196e42589f6 100644 --- a/core-backend/sandbox/src/lib.rs +++ b/core-backend/sandbox/src/lib.rs @@ -27,4 +27,4 @@ pub mod memory; pub mod runtime; pub use env::SandboxEnvironment; -pub use memory::MemoryWrap; +pub use memory::{DefaultExecutorMemory, MemoryWrap}; diff --git a/core-backend/sandbox/src/memory.rs b/core-backend/sandbox/src/memory.rs index 24212268742..7b6646c7952 100644 --- a/core-backend/sandbox/src/memory.rs +++ b/core-backend/sandbox/src/memory.rs @@ -22,7 +22,10 @@ use gear_core::{ memory::{HostPointer, Memory, MemoryError}, pages::{PageNumber, PageU32Size, WasmPage}, }; -use gear_sandbox::{default_executor::Memory as DefaultExecutorMemory, SandboxMemory}; +use gear_core_errors::MemoryError; +use gear_sandbox::SandboxMemory; + +pub type DefaultExecutorMemory = gear_sandbox::default_executor::Memory; /// Wrapper for sp_sandbox::Memory. pub struct MemoryWrap(DefaultExecutorMemory); diff --git a/core/src/costs.rs b/core/src/costs.rs index 7ce2386d38d..5b2fcad40ff 100644 --- a/core/src/costs.rs +++ b/core/src/costs.rs @@ -91,6 +91,9 @@ pub struct HostFnWeights { /// Weight of calling `alloc`. pub alloc: u64, + /// Weight per allocated page for `alloc`. + pub alloc_per_page: u64, + /// Weight of calling `alloc`. pub free: u64, @@ -313,8 +316,8 @@ impl Token for RuntimeToken { pub enum RuntimeCosts { /// Charge zero gas Null, - /// Weight of calling `alloc`. - Alloc, + /// Weight of calling `alloc` per amount of pages. + Alloc(u32), /// Weight of calling `free`. Free, /// Weight of calling `gr_reserve_gas`. @@ -446,9 +449,13 @@ impl RuntimeCosts { }; } + let cost_with_weight_per_page = |call_weight: u64, weight_per_page: u64, pages: u32| { + call_weight.saturating_add(weight_per_page.saturating_mul(pages as u64)) + }; + let weight = match *self { Null => 0, - Alloc => s.alloc, + Alloc(pages) => cost_with_weight_per_page(s.alloc, s.alloc_per_page, pages), Free => s.free, ReserveGas => s.gr_reserve_gas, UnreserveGas => s.gr_unreserve_gas, diff --git a/core/src/gas.rs b/core/src/gas.rs index 72bda6a14de..d4f3a9cd1b9 100644 --- a/core/src/gas.rs +++ b/core/src/gas.rs @@ -353,7 +353,7 @@ mod tests { #[test] fn charge_token_fails() { - let token = RuntimeCosts::Alloc.token(&HostFnWeights { + let token = RuntimeCosts::Alloc(0).token(&HostFnWeights { alloc: 1_000, ..Default::default() }); @@ -371,7 +371,7 @@ mod tests { #[test] fn charge_allowance_token_fails() { - let token = RuntimeCosts::Alloc.token(&HostFnWeights { + let token = RuntimeCosts::Alloc(0).token(&HostFnWeights { alloc: 1_000, ..Default::default() }); diff --git a/gsdk/src/metadata/generated.rs b/gsdk/src/metadata/generated.rs index 9f5fccd9e55..0396dbcaecf 100644 --- a/gsdk/src/metadata/generated.rs +++ b/gsdk/src/metadata/generated.rs @@ -2141,6 +2141,7 @@ pub mod runtime_types { #[derive(Debug, crate::gp::Decode, crate::gp::DecodeAsType, crate::gp::Encode)] pub struct HostFnWeights { pub alloc: runtime_types::sp_weights::weight_v2::Weight, + pub alloc_per_page: runtime_types::sp_weights::weight_v2::Weight, pub free: runtime_types::sp_weights::weight_v2::Weight, pub gr_reserve_gas: runtime_types::sp_weights::weight_v2::Weight, pub gr_unreserve_gas: runtime_types::sp_weights::weight_v2::Weight, diff --git a/pallets/gear/src/benchmarking/mod.rs b/pallets/gear/src/benchmarking/mod.rs index f8d6d09643c..65ac317ec71 100644 --- a/pallets/gear/src/benchmarking/mod.rs +++ b/pallets/gear/src/benchmarking/mod.rs @@ -54,10 +54,12 @@ use self::{ sandbox::Sandbox, }; use crate::{ - manager::ExtManager, pallet, schedule::INSTR_BENCHMARK_BATCH_SIZE, BalanceOf, BenchmarkStorage, - Call, Config, Event, ExecutionEnvironment, Ext as Externalities, GasHandlerOf, MailboxOf, - Pallet as Gear, Pallet, ProgramStorageOf, QueueOf, RentFreePeriodOf, ResumeMinimalPeriodOf, - Schedule, + manager::ExtManager, + pallet, + schedule::{API_BENCHMARK_BATCH_SIZE, INSTR_BENCHMARK_BATCH_SIZE}, + BalanceOf, BenchmarkStorage, Call, Config, Event, ExecutionEnvironment, Ext as Externalities, + GasHandlerOf, MailboxOf, Pallet as Gear, Pallet, ProgramStorageOf, QueueOf, RentFreePeriodOf, + ResumeMinimalPeriodOf, Schedule, }; use ::alloc::{ collections::{BTreeMap, BTreeSet}, @@ -82,16 +84,18 @@ use frame_support::{ }; use frame_system::{Pallet as SystemPallet, RawOrigin}; use gear_backend_common::Environment; +use gear_backend_sandbox::{DefaultExecutorMemory, MemoryWrap}; use gear_core::{ code::{Code, CodeAndId}, gas::{GasAllowanceCounter, GasCounter, ValueCounter}, ids::{CodeId, MessageId, ProgramId}, - memory::{AllocationsContext, PageBuf}, + memory::{AllocationsContext, Memory, PageBuf}, message::{ContextSettings, DispatchKind, IncomingDispatch, MessageContext}, pages::{GearPage, PageU32Size, WasmPage, GEAR_PAGE_SIZE, WASM_PAGE_SIZE}, reservation::GasReserver, }; use gear_core_errors::*; +use gear_sandbox::SandboxMemory; use gear_wasm_instrument::{ parity_wasm::elements::{BlockType, BrTableData, Instruction, SignExtInstruction, ValueType}, syscalls::SysCallName, @@ -821,10 +825,22 @@ benchmarks! { Gear::::reinstrument_code(code_id, &schedule); } + // Alloc there 1 page because `alloc` execution time is non-linear along with other amounts of pages. alloc { let r in 0 .. API_BENCHMARK_BATCHES; let mut res = None; - let exec = Benches::::alloc(r)?; + let exec = Benches::::alloc(r, 1)?; + }: { + res.replace(run_process(exec)); + } + verify { + verify_process(res.unwrap()); + } + + alloc_per_page { + let p in 1 .. MAX_PAGES; + let mut res = None; + let exec = Benches::::alloc(1, p)?; }: { res.replace(run_process(exec)); } @@ -1656,6 +1672,15 @@ benchmarks! { verify_process(res.unwrap()); } + mem_grow { + let r in 0 .. API_BENCHMARK_BATCHES; + let mut mem = MemoryWrap::new(DefaultExecutorMemory::new(1, None).unwrap()); + }: { + for _ in 0..(r * API_BENCHMARK_BATCH_SIZE) { + mem.grow(1.into()).unwrap(); + } + } + // w_load = w_bench instr_i64load { // Increased interval in order to increase accuracy diff --git a/pallets/gear/src/benchmarking/syscalls.rs b/pallets/gear/src/benchmarking/syscalls.rs index 099052686c0..14afa62f339 100644 --- a/pallets/gear/src/benchmarking/syscalls.rs +++ b/pallets/gear/src/benchmarking/syscalls.rs @@ -116,6 +116,24 @@ where ) } + fn prepare_handle_override_max_pages( + module: ModuleDefinition, + value: u32, + max_pages: WasmPage, + ) -> Result, &'static str> { + let instance = Program::::new(module.into(), vec![])?; + utils::prepare_exec::( + instance.caller.into_origin(), + HandleKind::Handle(ProgramId::from_origin(instance.addr)), + vec![], + PrepareConfig { + value: value.into(), + max_pages_override: Some(max_pages), + ..Default::default() + }, + ) + } + fn prepare_handle_with_reservation_slots( module: ModuleDefinition, repetitions: u32, @@ -158,24 +176,30 @@ where ) } - pub fn alloc(r: u32) -> Result, &'static str> { + pub fn alloc(repetitions: u32, pages: u32) -> Result, &'static str> { + const MAX_PAGES_OVERRIDE: u16 = u16::MAX; + + assert!(repetitions * pages * API_BENCHMARK_BATCH_SIZE <= MAX_PAGES_OVERRIDE as u32); + let mut instructions = vec![ - // Alloc 0 pages take almost the same amount of resources as another amount. - Instruction::I32Const(0), + Instruction::I32Const(pages as i32), Instruction::Call(0), - Instruction::I32Const(i32::MAX), + Instruction::I32Const(-1), ]; - unreachable_condition(&mut instructions, Instruction::I32Eq); // if alloc returns i32::MAX then it's error + unreachable_condition(&mut instructions, Instruction::I32Eq); // if alloc returns -1 then it's error let module = ModuleDefinition { memory: Some(ImportedMemory::new(0)), imported_functions: vec![SysCallName::Alloc], - handle_body: Some(body::repeated(r * API_BENCHMARK_BATCH_SIZE, &instructions)), + handle_body: Some(body::repeated( + repetitions * API_BENCHMARK_BATCH_SIZE, + &instructions, + )), ..Default::default() }; - Self::prepare_handle(module, 0) + Self::prepare_handle_override_max_pages(module, 0, MAX_PAGES_OVERRIDE.into()) } pub fn free(r: u32) -> Result, &'static str> { @@ -184,8 +208,8 @@ where use Instruction::*; let mut instructions = vec![]; for _ in 0..API_BENCHMARK_BATCH_SIZE { - instructions.extend([I32Const(r as i32), Call(0), I32Const(i32::MAX)]); - unreachable_condition(&mut instructions, I32Eq); // if alloc returns i32::MAX then it's error + instructions.extend([I32Const(r as i32), Call(0), I32Const(-1)]); + unreachable_condition(&mut instructions, I32Eq); // if alloc returns -1 then it's error for page in 0..r { instructions.extend([I32Const(page as i32), Call(1), I32Const(0)]); diff --git a/pallets/gear/src/benchmarking/utils.rs b/pallets/gear/src/benchmarking/utils.rs index 910d40ea26e..60992c73675 100644 --- a/pallets/gear/src/benchmarking/utils.rs +++ b/pallets/gear/src/benchmarking/utils.rs @@ -34,6 +34,7 @@ use gear_core::{ code::{Code, CodeAndId}, ids::{CodeId, MessageId, ProgramId}, message::{Dispatch, DispatchKind, Message, ReplyDetails, SignalDetails}, + pages::WasmPage, }; use sp_core::H256; use sp_runtime::traits::UniqueSaturatedInto; @@ -94,6 +95,7 @@ pub struct PrepareConfig { pub value: u128, pub gas_allowance: u64, pub gas_limit: u64, + pub max_pages_override: Option, } impl Default for PrepareConfig { @@ -102,6 +104,7 @@ impl Default for PrepareConfig { value: 0, gas_allowance: u64::MAX, gas_limit: u64::MAX / 2, + max_pages_override: None, } } } @@ -257,7 +260,8 @@ where .get_actor(actor_id) .ok_or("Program not found in the storage")?; - let block_config = prepare_block_config::(); + let mut block_config = prepare_block_config::(); + block_config.max_pages = config.max_pages_override.unwrap_or(block_config.max_pages); let precharged_dispatch = core_processor::precharge_for_program( &block_config, diff --git a/pallets/gear/src/schedule.rs b/pallets/gear/src/schedule.rs index a93a7cda00c..10835dea10c 100644 --- a/pallets/gear/src/schedule.rs +++ b/pallets/gear/src/schedule.rs @@ -331,7 +331,10 @@ pub struct HostFnWeights { /// Weight of calling `alloc`. pub alloc: Weight, - /// Weight of calling `alloc`. + /// Weight per page in `alloc`. + pub alloc_per_page: Weight, + + /// Weight of calling `free`. pub free: Weight, /// Weight of calling `gr_reserve_gas`. @@ -839,6 +842,7 @@ impl HostFnWeights { pub fn into_core(self) -> CoreHostFnWeights { CoreHostFnWeights { alloc: self.alloc.ref_time(), + alloc_per_page: self.alloc_per_page.ref_time(), free: self.free.ref_time(), gr_reserve_gas: self.gr_reserve_gas.ref_time(), gr_unreserve_gas: self.gr_unreserve_gas.ref_time(), @@ -954,7 +958,11 @@ impl Default for HostFnWeights { gr_reply_push_input: to_weight!(cost_batched!(gr_reply_push_input)), gr_reply_push_input_per_byte: to_weight!(cost_byte!(gr_reply_push_input_per_kb)), - alloc: to_weight!(cost_batched!(alloc)), + // Alloc benchmark causes grow memory calls so we subtract it here as grow is charged separately. + alloc: to_weight!(cost_batched!(alloc)) + .saturating_sub(to_weight!(cost_batched!(alloc_per_page))) + .saturating_sub(to_weight!(cost_batched!(mem_grow))), + alloc_per_page: to_weight!(cost_batched!(alloc_per_page)), free: to_weight!(cost_batched!(free)), gr_reserve_gas: to_weight!(cost!(gr_reserve_gas)), gr_system_reserve_gas: to_weight!(cost_batched!(gr_system_reserve_gas)), @@ -1066,7 +1074,7 @@ impl Default for MemoryWeights { .saturating_add(T::DbWeight::get().writes(1).ref_time())), // TODO: make benches to calculate static page cost and mem grow cost (issue #2226) static_page: Weight::from_parts(100, 0), - mem_grow: Weight::from_parts(100, 0), + mem_grow: to_weight!(cost_batched!(mem_grow)), // TODO: make it non-zero for para-chains (issue #2225) parachain_read_heuristic: Weight::zero(), _phantom: PhantomData, diff --git a/pallets/gear/src/weights.rs b/pallets/gear/src/weights.rs index 39082005a94..9408a0339af 100644 --- a/pallets/gear/src/weights.rs +++ b/pallets/gear/src/weights.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_gear //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-07-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("gear-dev"), DB CACHE: 1024 @@ -56,6 +56,7 @@ pub trait WeightInfo { fn alloc_in_handle(q: u32, ) -> Weight; fn reinstrument_per_kb(c: u32, ) -> Weight; fn alloc(r: u32, ) -> Weight; + fn alloc_per_page(p: u32, ) -> Weight; fn free(r: u32, ) -> Weight; fn gr_reserve_gas(r: u32, ) -> Weight; fn gr_unreserve_gas(r: u32, ) -> Weight; @@ -128,6 +129,7 @@ pub trait WeightInfo { fn lazy_pages_host_func_read(p: u32, ) -> Weight; fn lazy_pages_host_func_write(p: u32, ) -> Weight; fn lazy_pages_host_func_write_after_read(p: u32, ) -> Weight; + fn mem_grow(r: u32, ) -> Weight; fn instr_i64load(r: u32, ) -> Weight; fn instr_i32load(r: u32, ) -> Weight; fn instr_i64store(r: u32, ) -> Weight; @@ -452,10 +454,20 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 83_351_000 picoseconds. - Weight::from_parts(111_337_720, 0) - // Standard Error: 455_985 - .saturating_add(Weight::from_parts(163_069_244, 0).saturating_mul(r.into())) + // Minimum execution time: 88_275_000 picoseconds. + Weight::from_parts(89_733_000, 0) + // Standard Error: 3_987_023 + .saturating_add(Weight::from_parts(669_872_725, 0).saturating_mul(r.into())) + } + /// The range of component `p` is `[1, 512]`. + fn alloc_per_page(p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 413_044_000 picoseconds. + Weight::from_parts(343_710_210, 0) + // Standard Error: 8_256 + .saturating_add(Weight::from_parts(31_367_607, 0).saturating_mul(p.into())) } /// The range of component `r` is `[0, 20]`. fn free(r: u32, ) -> Weight { @@ -467,6 +479,16 @@ impl WeightInfo for SubstrateWeight { // Standard Error: 397_100 .saturating_add(Weight::from_parts(163_114_248, 0).saturating_mul(r.into())) } + /// The range of component `r` is `[0, 20]`. + fn mem_grow(r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_265_000 picoseconds. + Weight::from_parts(3_465_198, 0) + // Standard Error: 8_582 + .saturating_add(Weight::from_parts(22_066_748, 0).saturating_mul(r.into())) + } /// The range of component `r` is `[0, 256]`. fn gr_reserve_gas(r: u32, ) -> Weight { // Proof Size summary in bytes: @@ -2301,10 +2323,20 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 83_351_000 picoseconds. - Weight::from_parts(111_337_720, 0) - // Standard Error: 455_985 - .saturating_add(Weight::from_parts(163_069_244, 0).saturating_mul(r.into())) + // Minimum execution time: 88_275_000 picoseconds. + Weight::from_parts(89_733_000, 0) + // Standard Error: 3_987_023 + .saturating_add(Weight::from_parts(669_872_725, 0).saturating_mul(r.into())) + } + /// The range of component `p` is `[1, 512]`. + fn alloc_per_page(p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 413_044_000 picoseconds. + Weight::from_parts(343_710_210, 0) + // Standard Error: 8_256 + .saturating_add(Weight::from_parts(31_367_607, 0).saturating_mul(p.into())) } /// The range of component `r` is `[0, 20]`. fn free(r: u32, ) -> Weight { @@ -2316,6 +2348,16 @@ impl WeightInfo for () { // Standard Error: 397_100 .saturating_add(Weight::from_parts(163_114_248, 0).saturating_mul(r.into())) } + /// The range of component `r` is `[0, 20]`. + fn mem_grow(r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_265_000 picoseconds. + Weight::from_parts(3_465_198, 0) + // Standard Error: 8_582 + .saturating_add(Weight::from_parts(22_066_748, 0).saturating_mul(r.into())) + } /// The range of component `r` is `[0, 256]`. fn gr_reserve_gas(r: u32, ) -> Weight { // Proof Size summary in bytes: diff --git a/runtime/gear/src/tests.rs b/runtime/gear/src/tests.rs index 8785dc3691b..3ff63c03950 100644 --- a/runtime/gear/src/tests.rs +++ b/runtime/gear/src/tests.rs @@ -145,7 +145,7 @@ fn page_costs_heuristic_test() { load_page_data: 8_700_000.into(), upload_page_data: 104_000_000.into(), static_page: 100.into(), - mem_grow: 100.into(), + mem_grow: 276_000.into(), parachain_load_heuristic: 0.into(), }; diff --git a/runtime/gear/src/weights/pallet_gear.rs b/runtime/gear/src/weights/pallet_gear.rs index 38bfa7ddbdc..42ae49ff712 100644 --- a/runtime/gear/src/weights/pallet_gear.rs +++ b/runtime/gear/src/weights/pallet_gear.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_gear //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-07-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("gear-dev"), DB CACHE: 1024 @@ -56,13 +56,13 @@ pub trait WeightInfo { fn alloc_in_handle(q: u32, ) -> Weight; fn reinstrument_per_kb(c: u32, ) -> Weight; fn alloc(r: u32, ) -> Weight; + fn alloc_per_page(p: u32, ) -> Weight; fn free(r: u32, ) -> Weight; fn gr_reserve_gas(r: u32, ) -> Weight; fn gr_unreserve_gas(r: u32, ) -> Weight; fn gr_system_reserve_gas(r: u32, ) -> Weight; fn gr_message_id(r: u32, ) -> Weight; fn gr_origin(r: u32, ) -> Weight; - fn gr_pay_program_rent(r: u32, ) -> Weight; fn gr_program_id(r: u32, ) -> Weight; fn gr_source(r: u32, ) -> Weight; fn gr_value(r: u32, ) -> Weight; @@ -122,6 +122,7 @@ pub trait WeightInfo { fn gr_create_program_per_kb(p: u32, s: u32, ) -> Weight; fn gr_create_program_wgas(r: u32, ) -> Weight; fn gr_create_program_wgas_per_kb(p: u32, s: u32, ) -> Weight; + fn gr_pay_program_rent(r: u32, ) -> Weight; fn lazy_pages_signal_read(p: u32, ) -> Weight; fn lazy_pages_signal_write(p: u32, ) -> Weight; fn lazy_pages_signal_write_after_read(p: u32, ) -> Weight; @@ -129,6 +130,7 @@ pub trait WeightInfo { fn lazy_pages_host_func_read(p: u32, ) -> Weight; fn lazy_pages_host_func_write(p: u32, ) -> Weight; fn lazy_pages_host_func_write_after_read(p: u32, ) -> Weight; + fn mem_grow(r: u32, ) -> Weight; fn instr_i64load(r: u32, ) -> Weight; fn instr_i32load(r: u32, ) -> Weight; fn instr_i64store(r: u32, ) -> Weight; @@ -453,10 +455,20 @@ impl pallet_gear::WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 83_351_000 picoseconds. - Weight::from_parts(111_337_720, 0) - // Standard Error: 455_985 - .saturating_add(Weight::from_parts(163_069_244, 0).saturating_mul(r.into())) + // Minimum execution time: 88_275_000 picoseconds. + Weight::from_parts(89_733_000, 0) + // Standard Error: 3_987_023 + .saturating_add(Weight::from_parts(669_872_725, 0).saturating_mul(r.into())) + } + /// The range of component `p` is `[1, 512]`. + fn alloc_per_page(p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 413_044_000 picoseconds. + Weight::from_parts(343_710_210, 0) + // Standard Error: 8_256 + .saturating_add(Weight::from_parts(31_367_607, 0).saturating_mul(p.into())) } /// The range of component `r` is `[0, 20]`. fn free(r: u32, ) -> Weight { @@ -468,6 +480,16 @@ impl pallet_gear::WeightInfo for SubstrateWeight { // Standard Error: 397_100 .saturating_add(Weight::from_parts(163_114_248, 0).saturating_mul(r.into())) } + /// The range of component `r` is `[0, 20]`. + fn mem_grow(r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_265_000 picoseconds. + Weight::from_parts(3_465_198, 0) + // Standard Error: 8_582 + .saturating_add(Weight::from_parts(22_066_748, 0).saturating_mul(r.into())) + } /// The range of component `r` is `[0, 256]`. fn gr_reserve_gas(r: u32, ) -> Weight { // Proof Size summary in bytes: @@ -2302,10 +2324,20 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 83_351_000 picoseconds. - Weight::from_parts(111_337_720, 0) - // Standard Error: 455_985 - .saturating_add(Weight::from_parts(163_069_244, 0).saturating_mul(r.into())) + // Minimum execution time: 88_275_000 picoseconds. + Weight::from_parts(89_733_000, 0) + // Standard Error: 3_987_023 + .saturating_add(Weight::from_parts(669_872_725, 0).saturating_mul(r.into())) + } + /// The range of component `p` is `[1, 512]`. + fn alloc_per_page(p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 413_044_000 picoseconds. + Weight::from_parts(343_710_210, 0) + // Standard Error: 8_256 + .saturating_add(Weight::from_parts(31_367_607, 0).saturating_mul(p.into())) } /// The range of component `r` is `[0, 20]`. fn free(r: u32, ) -> Weight { @@ -2317,6 +2349,16 @@ impl WeightInfo for () { // Standard Error: 397_100 .saturating_add(Weight::from_parts(163_114_248, 0).saturating_mul(r.into())) } + /// The range of component `r` is `[0, 20]`. + fn mem_grow(r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 3_265_000 picoseconds. + Weight::from_parts(3_465_198, 0) + // Standard Error: 8_582 + .saturating_add(Weight::from_parts(22_066_748, 0).saturating_mul(r.into())) + } /// The range of component `r` is `[0, 256]`. fn gr_reserve_gas(r: u32, ) -> Weight { // Proof Size summary in bytes: diff --git a/runtime/vara/src/tests.rs b/runtime/vara/src/tests.rs index 88d78461888..5ef949a4c4a 100644 --- a/runtime/vara/src/tests.rs +++ b/runtime/vara/src/tests.rs @@ -145,7 +145,7 @@ fn page_costs_heuristic_test() { load_page_data: 8_700_000.into(), upload_page_data: 104_000_000.into(), static_page: 100.into(), - mem_grow: 100.into(), + mem_grow: 277_000.into(), parachain_load_heuristic: 0.into(), }; diff --git a/runtime/vara/src/weights/pallet_gear.rs b/runtime/vara/src/weights/pallet_gear.rs index 66d55efd782..fa4d8fc8813 100644 --- a/runtime/vara/src/weights/pallet_gear.rs +++ b/runtime/vara/src/weights/pallet_gear.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_gear //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-07-10, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("vara-dev"), DB CACHE: 1024 @@ -56,13 +56,13 @@ pub trait WeightInfo { fn alloc_in_handle(q: u32, ) -> Weight; fn reinstrument_per_kb(c: u32, ) -> Weight; fn alloc(r: u32, ) -> Weight; + fn alloc_per_page(p: u32, ) -> Weight; fn free(r: u32, ) -> Weight; fn gr_reserve_gas(r: u32, ) -> Weight; fn gr_unreserve_gas(r: u32, ) -> Weight; fn gr_system_reserve_gas(r: u32, ) -> Weight; fn gr_message_id(r: u32, ) -> Weight; fn gr_origin(r: u32, ) -> Weight; - fn gr_pay_program_rent(r: u32, ) -> Weight; fn gr_program_id(r: u32, ) -> Weight; fn gr_source(r: u32, ) -> Weight; fn gr_value(r: u32, ) -> Weight; @@ -122,6 +122,7 @@ pub trait WeightInfo { fn gr_create_program_per_kb(p: u32, s: u32, ) -> Weight; fn gr_create_program_wgas(r: u32, ) -> Weight; fn gr_create_program_wgas_per_kb(p: u32, s: u32, ) -> Weight; + fn gr_pay_program_rent(r: u32, ) -> Weight; fn lazy_pages_signal_read(p: u32, ) -> Weight; fn lazy_pages_signal_write(p: u32, ) -> Weight; fn lazy_pages_signal_write_after_read(p: u32, ) -> Weight; @@ -129,6 +130,7 @@ pub trait WeightInfo { fn lazy_pages_host_func_read(p: u32, ) -> Weight; fn lazy_pages_host_func_write(p: u32, ) -> Weight; fn lazy_pages_host_func_write_after_read(p: u32, ) -> Weight; + fn mem_grow(r: u32, ) -> Weight; fn instr_i64load(r: u32, ) -> Weight; fn instr_i32load(r: u32, ) -> Weight; fn instr_i64store(r: u32, ) -> Weight; @@ -453,10 +455,20 @@ impl pallet_gear::WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 80_995_000 picoseconds. - Weight::from_parts(116_749_019, 0) - // Standard Error: 462_464 - .saturating_add(Weight::from_parts(160_737_989, 0).saturating_mul(r.into())) + // Minimum execution time: 84_723_000 picoseconds. + Weight::from_parts(86_836_000, 0) + // Standard Error: 4_212_669 + .saturating_add(Weight::from_parts(686_247_352, 0).saturating_mul(r.into())) + } + /// The range of component `p` is `[1, 512]`. + fn alloc_per_page(p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 411_787_000 picoseconds. + Weight::from_parts(355_328_520, 0) + // Standard Error: 7_364 + .saturating_add(Weight::from_parts(32_355_462, 0).saturating_mul(p.into())) } /// The range of component `r` is `[0, 20]`. fn free(r: u32, ) -> Weight { @@ -468,6 +480,16 @@ impl pallet_gear::WeightInfo for SubstrateWeight { // Standard Error: 372_314 .saturating_add(Weight::from_parts(150_482_259, 0).saturating_mul(r.into())) } + /// The range of component `r` is `[0, 20]`. + fn mem_grow(r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_293_000 picoseconds. + Weight::from_parts(1_403_924, 0) + // Standard Error: 11_364 + .saturating_add(Weight::from_parts(22_072_117, 0).saturating_mul(r.into())) + } /// The range of component `r` is `[0, 256]`. fn gr_reserve_gas(r: u32, ) -> Weight { // Proof Size summary in bytes: @@ -2302,10 +2324,20 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 80_995_000 picoseconds. - Weight::from_parts(116_749_019, 0) - // Standard Error: 462_464 - .saturating_add(Weight::from_parts(160_737_989, 0).saturating_mul(r.into())) + // Minimum execution time: 84_723_000 picoseconds. + Weight::from_parts(86_836_000, 0) + // Standard Error: 4_212_669 + .saturating_add(Weight::from_parts(686_247_352, 0).saturating_mul(r.into())) + } + /// The range of component `p` is `[1, 512]`. + fn alloc_per_page(p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 411_787_000 picoseconds. + Weight::from_parts(355_328_520, 0) + // Standard Error: 7_364 + .saturating_add(Weight::from_parts(32_355_462, 0).saturating_mul(p.into())) } /// The range of component `r` is `[0, 20]`. fn free(r: u32, ) -> Weight { @@ -2317,6 +2349,16 @@ impl WeightInfo for () { // Standard Error: 372_314 .saturating_add(Weight::from_parts(150_482_259, 0).saturating_mul(r.into())) } + /// The range of component `r` is `[0, 20]`. + fn mem_grow(r: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_293_000 picoseconds. + Weight::from_parts(1_403_924, 0) + // Standard Error: 11_364 + .saturating_add(Weight::from_parts(22_072_117, 0).saturating_mul(r.into())) + } /// The range of component `r` is `[0, 256]`. fn gr_reserve_gas(r: u32, ) -> Weight { // Proof Size summary in bytes: diff --git a/utils/regression-analysis/src/main.rs b/utils/regression-analysis/src/main.rs index 72214985ebb..c409ae27ede 100644 --- a/utils/regression-analysis/src/main.rs +++ b/utils/regression-analysis/src/main.rs @@ -307,6 +307,7 @@ fn weights(kind: WeightsKind, input_file: PathBuf, output_file: PathBuf) { HostFnWeights { _phantom, alloc, + alloc_per_page, free, gr_gas_available, gr_message_id,