Skip to content
Snippets Groups Projects

Fix weight accounting

Merged Benjamin Gallois requested to merge 167-fix-remove-member-weight into master

The problem is slightly different from the previously raised issue due to the deletion of instance pallets. Currently, the problem lies in having two tuple handlers (OnIdtyChange and Event). The weight of the function calling these handlers is the sum of each implementation. If these functions are not called in hooks, it will be possible to take the worst possible path as an approximation. However, some are called in on_initialize, and the worst case is close to 7% of a block, approximately 10 times the average path.

  • Add weight return in OnIdtyChange and Event handlers.
  • Account for the weight where these handlers are called.
  • Replace all +=, -= by saturating_add and saturating_sub for consistency.
  • Closes #163 (closed).
  • Closes #203 (closed)

Note: Some handlers are difficult to benchmark using a benchmark function, so the accounting is performed by counting reads and writes, inspired by the staking pallet from Substrate.

Closes #167 (closed)

Edited by Benjamin Gallois

Merge request reports

Merge request pipeline #36579 passed

Merge request pipeline passed for ab5524f5

Merged by Hugo TrentesauxHugo Trentesaux 1 year ago (Mar 20, 2024 10:02pm UTC)

Loading

Pipeline #36584 passed

Pipeline passed for 07bb8814 on master

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading