Skip to content

Commit

Permalink
fix benchmarks for greater than 256 (#135)
Browse files Browse the repository at this point in the history
Co-authored-by: Justin Zhou <[email protected]>
  • Loading branch information
justinzhou93 and Justin Zhou authored May 3, 2022
1 parent 1ef34a4 commit 6180a0f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
14 changes: 7 additions & 7 deletions pallets/automation-time/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn schedule_notify_tasks<T: Config>(owner: T::AccountId, times: Vec<u64>, count:
let mut task_id: T::Hash = T::Hash::default();

for i in 0..count {
let provided_id: Vec<u8> = vec![i.try_into().unwrap()];
let provided_id: Vec<u8> = vec![(i/256).try_into().unwrap(), (i%256).try_into().unwrap()];
task_id =
AutomationTime::<T>::schedule_task(owner.clone(), provided_id.clone(), times.clone()).unwrap();
let task = Task::<T>::create_event_task(owner.clone(), provided_id, times.clone().try_into().unwrap(), vec![4, 5, 6]);
Expand All @@ -56,7 +56,7 @@ fn schedule_transfer_tasks<T: Config>(owner: T::AccountId, time: u64, count: u32
T::NativeTokenExchange::minimum_balance().saturating_mul(ED_MULTIPLIER.into());

for i in 0..count {
let provided_id: Vec<u8> = vec![i.try_into().unwrap()];
let provided_id: Vec<u8> = vec![(i/256).try_into().unwrap(), (i%256).try_into().unwrap()];
task_id =
AutomationTime::<T>::schedule_task(owner.clone(), provided_id.clone(), vec![time]).unwrap();
let task = Task::<T>::create_native_transfer_task(
Expand Down Expand Up @@ -94,10 +94,10 @@ benchmarks! {
}

let task_id: T::Hash = schedule_notify_tasks::<T>(caller.clone(), times.clone(), T::MaxTasksPerSlot::get() - 1);
let provided_id = (T::MaxTasksPerSlot::get()).saturated_into::<u8>();
let provided_id: Vec<u8> = vec![(T::MaxTasksPerSlot::get()/256).try_into().unwrap(), (T::MaxTasksPerSlot::get()%256).try_into().unwrap()];
let transfer_amount = T::NativeTokenExchange::minimum_balance().saturating_mul(ED_MULTIPLIER.into());
T::NativeTokenExchange::deposit_creating(&caller, transfer_amount.clone());
}: schedule_notify_task(RawOrigin::Signed(caller), vec![provided_id], times, vec![4, 5])
}: schedule_notify_task(RawOrigin::Signed(caller), provided_id, times, vec![4, 5])

schedule_native_transfer_task_empty{
let caller: T::AccountId = account("caller", 0, SEED);
Expand All @@ -124,8 +124,8 @@ benchmarks! {
}

let task_id: T::Hash = schedule_notify_tasks::<T>(caller.clone(), times.clone(), T::MaxTasksPerSlot::get() - 1);
let provided_id = (T::MaxTasksPerSlot::get()).saturated_into::<u8>();
}: schedule_native_transfer_task(RawOrigin::Signed(caller), vec![provided_id], times, recipient, transfer_amount)
let provided_id: Vec<u8> = vec![(T::MaxTasksPerSlot::get()/256).try_into().unwrap(), (T::MaxTasksPerSlot::get()%256).try_into().unwrap()];
}: schedule_native_transfer_task(RawOrigin::Signed(caller), provided_id, times, recipient, transfer_amount)

cancel_scheduled_task_full {
let caller: T::AccountId = account("caller", 0, SEED);
Expand Down Expand Up @@ -290,7 +290,7 @@ benchmarks! {
let current_time = 10800;

for i in 0..T::MaxTasksPerSlot::get() {
let provided_id: Vec<u8> = vec![i.saturated_into::<u8>()];
let provided_id: Vec<u8> = vec![(i/256).try_into().unwrap(), (i%256).try_into().unwrap()];
let task_id = AutomationTime::<T>::schedule_task(caller.clone(), provided_id.clone(), vec![current_time.into()]).unwrap();
let task = Task::<T>::create_event_task(caller.clone(), provided_id, vec![current_time.into()].try_into().unwrap(), vec![4, 5, 6]);
<Tasks<T>>::insert(task_id, task);
Expand Down
46 changes: 23 additions & 23 deletions pallets/automation-time/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ impl<T: frame_system::Config> WeightInfo for AutomationWeight<T> {
// Storage: AutomationTime Tasks (r:1 w:1)
// Storage: AutomationTime ScheduledTasks (r:1 w:1)
fn schedule_notify_task_full(v: u32, ) -> Weight {
(42_160_000 as Weight)
// Standard Error: 78_000
.saturating_add((22_915_000 as Weight).saturating_mul(v as Weight))
(87_989_000 as Weight)
// Standard Error: 81_000
.saturating_add((45_338_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight)))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
Expand All @@ -84,7 +84,7 @@ impl<T: frame_system::Config> WeightInfo for AutomationWeight<T> {
// Storage: AutomationTime Tasks (r:1 w:1)
// Storage: AutomationTime ScheduledTasks (r:1 w:1)
fn schedule_native_transfer_task_empty() -> Weight {
(39_000_000 as Weight)
(38_000_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
Expand All @@ -93,9 +93,9 @@ impl<T: frame_system::Config> WeightInfo for AutomationWeight<T> {
// Storage: AutomationTime Tasks (r:1 w:1)
// Storage: AutomationTime ScheduledTasks (r:1 w:1)
fn schedule_native_transfer_task_full(v: u32, ) -> Weight {
(51_637_000 as Weight)
// Standard Error: 59_000
.saturating_add((21_815_000 as Weight).saturating_mul(v as Weight))
(39_985_000 as Weight)
// Standard Error: 52_000
.saturating_add((47_930_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight)))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
Expand All @@ -106,7 +106,7 @@ impl<T: frame_system::Config> WeightInfo for AutomationWeight<T> {
// Storage: AutomationTime LastTimeSlot (r:1 w:0)
// Storage: AutomationTime ScheduledTasks (r:24 w:24)
fn cancel_scheduled_task_full() -> Weight {
(542_000_000 as Weight)
(1_192_000_000 as Weight)
.saturating_add(T::DbWeight::get().reads(27 as Weight))
.saturating_add(T::DbWeight::get().writes(25 as Weight))
}
Expand All @@ -124,7 +124,7 @@ impl<T: frame_system::Config> WeightInfo for AutomationWeight<T> {
// Storage: AutomationTime LastTimeSlot (r:1 w:0)
// Storage: AutomationTime ScheduledTasks (r:24 w:24)
fn force_cancel_scheduled_task_full() -> Weight {
(524_000_000 as Weight)
(1_203_000_000 as Weight)
.saturating_add(T::DbWeight::get().reads(27 as Weight))
.saturating_add(T::DbWeight::get().writes(25 as Weight))
}
Expand All @@ -133,39 +133,39 @@ impl<T: frame_system::Config> WeightInfo for AutomationWeight<T> {
}
// Storage: System Account (r:2 w:2)
fn run_native_transfer_task() -> Weight {
(26_000_000 as Weight)
(27_000_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
// Storage: AutomationTime Tasks (r:1 w:1)
fn run_missed_tasks_many_found(v: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 0
.saturating_add((11_000_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 86_000
.saturating_add((10_625_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight)))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(v as Weight)))
}
// Storage: AutomationTime Tasks (r:1 w:0)
fn run_missed_tasks_many_missing(v: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 0
.saturating_add((9_000_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 59_000
.saturating_add((8_875_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight)))
}
// Storage: AutomationTime Tasks (r:1 w:1)
// Storage: System Account (r:2 w:2)
fn run_tasks_many_found(v: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 0
.saturating_add((30_000_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 31_000
.saturating_add((29_969_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight)))
.saturating_add(T::DbWeight::get().writes((3 as Weight).saturating_mul(v as Weight)))
}
// Storage: AutomationTime Tasks (r:1 w:0)
fn run_tasks_many_missing(v: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 31_000
.saturating_add((8_969_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 0
.saturating_add((9_000_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight)))
}
// Storage: Timestamp Now (r:1 w:0)
Expand All @@ -176,9 +176,9 @@ impl<T: frame_system::Config> WeightInfo for AutomationWeight<T> {
// Storage: AutomationTime MissedQueue (r:1 w:1)
// Storage: AutomationTime ScheduledTasks (r:1 w:1)
fn append_to_missed_tasks(v: u32, ) -> Weight {
(1_469_000 as Weight)
// Standard Error: 105_000
.saturating_add((1_812_000 as Weight).saturating_mul(v as Weight))
(1_401_000 as Weight)
// Standard Error: 112_000
.saturating_add((1_797_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight)))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
Expand All @@ -188,13 +188,13 @@ impl<T: frame_system::Config> WeightInfo for AutomationWeight<T> {
// Storage: AutomationTime MissedQueue (r:1 w:1)
// Storage: AutomationTime ScheduledTasks (r:1 w:1)
fn update_scheduled_task_queue() -> Weight {
(25_000_000 as Weight)
(48_000_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
// Storage: AutomationTime ScheduledTasks (r:1 w:1)
fn shift_missed_tasks() -> Weight {
(10_000_000 as Weight)
(19_000_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/neumann/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ impl pallet_democracy::Config for Runtime {
}

parameter_types! {
pub const MaxTasksPerSlot: u32 = 256;
pub const MaxTasksPerSlot: u32 = 576;
pub const MaxExecutionTimes: u32 = 24;
pub const MaxScheduleSeconds: u64 = 7 * 24 * 60 * 60;
pub const MaxBlockWeight: Weight = MAXIMUM_BLOCK_WEIGHT;
Expand Down

0 comments on commit 6180a0f

Please sign in to comment.