Skip to content

benchmarking: fix DB read/write counts#10947

Merged
sigurpol merged 14 commits intomasterfrom
sigurpol-benchmark-fix-read-write-count
Feb 3, 2026
Merged

benchmarking: fix DB read/write counts#10947
sigurpol merged 14 commits intomasterfrom
sigurpol-benchmark-fix-read-write-count

Conversation

@sigurpol
Copy link
Copy Markdown
Contributor

@sigurpol sigurpol commented Jan 30, 2026

PR #10802 added reset_read_write_count() at the end of commit_db() to prevent warmup operations from appearing in benchmarking results. However, commit_db is called twice: one on on_before_start() closure before benchmark, and one after benchmark execution after benchmark.
This PR whitelists the warmup key used in commit_db so that it doesn't appear in the read/write count.

We also regenerated staking-async weights (wrongly benchmarked in #10802) and conviction-voting to check both v1 and v2 benchmarking.

Driven-by: update try-runtime-cli to v0.10.1 as an attempt to fix the issue for which CI regularly fails in the check-migration (WAH) job in ./try-runtime create-snapshot --uri wss://westend-asset-hub-rpc.polkadot.io:443 snapshot.raw`

PR #10802 added `reset_read_write_count()` at the end of commit_db() to
prevent warmup operations from appearing in benchmarking results.
However, commit_db is called twice: one on_before_start() closure before
benchmark, and one after benchmark execution after benchmark.

This PR moves read_write_count() call before the post-benchmark
commit_db() call.
@sigurpol sigurpol requested a review from a team as a code owner January 30, 2026 13:46
@sigurpol sigurpol added T12-benchmarks This PR/Issue is related to benchmarking and weights. A4-backport-stable2512 Pull request must be backported to the stable2512 release branch labels Jan 30, 2026
@sigurpol
Copy link
Copy Markdown
Contributor Author

/cmd prdoc --audience runtime_dev --bump patch

@paritytech-workflow-stopper
Copy link
Copy Markdown

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/21518053752
Failed job name: check-runtime-compatibility

Comment thread substrate/frame/benchmarking/src/v1.rs
Comment thread substrate/frame/benchmarking/src/v1.rs Outdated
Comment thread substrate/frame/benchmarking/src/v1.rs
@sigurpol
Copy link
Copy Markdown
Contributor Author

Tested via target/release/frame-omni-bencher v1 benchmark pallet --runtime ./target/release/wbuild/asset-hub-westend-runtime/asset_hub_westend_runtime.compact.compressed.wasm --pallet pallet_staking_async --extrinsic "force_apply_min_commission" --steps 2 --repeat 1:

Pallet: "pallet_staking_async", Extrinsic: "force_apply_min_commission", Lowest values: [], Highest values: [], Steps: 2, Repeat: 1
Raw Storage Info
========
Storage: `Staking::MinCommission` (r:1 w:0)
Proof: `Staking::MinCommission` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
Storage: `Staking::Validators` (r:1 w:1)
Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `MaxEncodedLen`)

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=    58.33
              µs

Reads = 2
Writes = 1
Recorded proof Size = 640

Min Squares Analysis
========
-- Extrinsic Time --

Model:
Time ~=    58.33
              µs

Reads = 2
Writes = 1
Recorded proof Size = 640

Seems we are back on track @mertwole , @ggwpez

Copy link
Copy Markdown
Contributor

@mertwole mertwole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aldo the pallet-staking-async weights need to be benched again as #10802 removed DB read/write weights there

@sigurpol
Copy link
Copy Markdown
Contributor Author

Aldo the pallet-staking-async weights need to be benched again as #10802 removed DB read/write weights there

Fair - I was not sure if doing it in a follow-up PR or here, but seems reasonable to do it here. Lemme

@sigurpol
Copy link
Copy Markdown
Contributor Author

/cmd bench --pallet pallet_staking_async --runtime asset-hub-westend

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --pallet pallet_staking_async --runtime asset-hub-westend" has started 🚀 See logs here

@ggwpez
Copy link
Copy Markdown
Member

ggwpez commented Jan 30, 2026

/cmd bench --pallet pallet_conviction_voting --runtime asset-hub-westend
(to also check V1)

@github-actions
Copy link
Copy Markdown
Contributor

Command "bench --pallet pallet_conviction_voting --runtime asset-hub-westend" has started 🚀 See logs here

@sigurpol
Copy link
Copy Markdown
Contributor Author

/cmd bench --pallet pallet_conviction_voting --runtime asset-hub-westend (to also check V1)

let me add that to the prdoc too 😄

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 2, 2026
@sigurpol sigurpol added this pull request to the merge queue Feb 3, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Feb 3, 2026
@sigurpol sigurpol added this pull request to the merge queue Feb 3, 2026
@sigurpol sigurpol removed this pull request from the merge queue due to a manual request Feb 3, 2026
@sigurpol sigurpol enabled auto-merge February 3, 2026 15:17
@sigurpol sigurpol added this pull request to the merge queue Feb 3, 2026
Merged via the queue into master with commit a78b18a Feb 3, 2026
245 of 248 checks passed
@sigurpol sigurpol deleted the sigurpol-benchmark-fix-read-write-count branch February 3, 2026 19:10
@paritytech-release-backport-bot
Copy link
Copy Markdown

Created backport PR for stable2512:

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin backport-10947-to-stable2512
git worktree add --checkout .worktree/backport-10947-to-stable2512 backport-10947-to-stable2512
cd .worktree/backport-10947-to-stable2512
git reset --hard HEAD^
git cherry-pick -x a78b18a5cc547141bfd5c10eb17593239e1e2509
git push --force-with-lease

sigurpol added a commit that referenced this pull request Feb 4, 2026
Backport #10947 into `stable2512` from sigurpol.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

---------

Co-authored-by: Paolo La Camera <paolo@parity.io>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
arturgontijo pushed a commit to moonbeam-foundation/polkadot-sdk that referenced this pull request Apr 1, 2026
Backport paritytech#10947 into `stable2512` from sigurpol.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

---------

Co-authored-by: Paolo La Camera <paolo@parity.io>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A4-backport-stable2512 Pull request must be backported to the stable2512 release branch T12-benchmarks This PR/Issue is related to benchmarking and weights.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants