Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revive: Rework the instruction benchmark #7721

Merged
merged 14 commits into from
Mar 3, 2025
Merged

revive: Rework the instruction benchmark #7721

merged 14 commits into from
Mar 3, 2025

Conversation

athei
Copy link
Member

@athei athei commented Feb 25, 2025

Fixes #6157

This fixes the last remaining benchmark that was not correct since it was too low level to be written in Rust. Instead, we opted.

This PR changes the benchmark that determines the scaling from ref_time to PolkaVM Gas by benchmarking the absolute worst case of an instruction: One that causes two cache misses by touching two cache lines.

The Contract itself is designed to be as simple as possible. It does random unaligned reads in a loop until the r (repetition) number is reached. The randomness is fully generated by the host and written to the guests memory before the benchmark is run. This allows the benchmark to determine the influence of one loop iteration via linear regression.

@athei athei marked this pull request as ready for review February 26, 2025 07:53
@athei athei added the T7-smart_contracts This PR/Issue is related to smart contracts. label Feb 26, 2025
@athei
Copy link
Member Author

athei commented Feb 26, 2025

/cmd bench --runtime dev --pallet pallet_revive --clean

@github-actions github-actions bot deleted a comment from athei Feb 26, 2025
@github-actions github-actions bot deleted a comment from athei Feb 26, 2025
@github-actions github-actions bot deleted a comment from athei Feb 26, 2025
@github-actions github-actions bot deleted a comment from athei Feb 26, 2025
Copy link
Contributor

Command "bench --runtime dev --pallet pallet_revive --clean" has started 🚀 See logs here

Copy link
Contributor

Command "bench --runtime dev --pallet pallet_revive --clean" has finished ✅ See logs here

Subweight results:
File Extrinsic Old New Change [%]
substrate/frame/revive/src/weights.rs instr 742.93us 1.31ms +76.30
substrate/frame/revive/src/weights.rs seal_origin 272.00ns 308.00ns +13.24
substrate/frame/revive/src/weights.rs seal_value_transferred 276.00ns 308.00ns +11.59
substrate/frame/revive/src/weights.rs seal_call_data_size 261.00ns 287.00ns +9.96
substrate/frame/revive/src/weights.rs seal_caller 273.00ns 300.00ns +9.89
substrate/frame/revive/src/weights.rs seal_balance 4.45us 4.83us +8.73
substrate/frame/revive/src/weights.rs seal_return_data_size 260.00ns 280.00ns +7.69
substrate/frame/revive/src/weights.rs seal_caller_is_origin 318.00ns 342.00ns +7.55
substrate/frame/revive/src/weights.rs set_transient_storage_full 1.73us 1.84us +6.71
substrate/frame/revive/src/weights.rs seal_gas_limit 397.00ns 423.00ns +6.55
substrate/frame/revive/src/weights.rs seal_ecdsa_recover 47.34us 49.80us +5.20
substrate/frame/revive/src/weights.rs seal_minimum_balance 294.00ns 277.00ns -5.78
substrate/frame/revive/src/weights.rs seal_caller_is_root 290.00ns 272.00ns -6.21
substrate/frame/revive/src/weights.rs seal_address 287.00ns 264.00ns -8.01
substrate/frame/revive/src/weights.rs instr_empty_loop 7.32ms Added
cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/pallet_message_queue.rs set_service_head 131.21us Added
cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/pallet_message_queue.rs service_queue_base 127.86us Added
cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/pallet_message_queue.rs service_page_item 505.09us Added
cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/pallet_message_queue.rs service_page_base_no_completion 130.00us Added
cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/pallet_message_queue.rs service_page_base_completion 129.87us Added
cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/pallet_message_queue.rs reap_page 374.70us Added
cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/pallet_message_queue.rs ready_ring_unknit 387.70us Added
cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/pallet_message_queue.rs ready_ring_knit 289.26us Added
cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/pallet_message_queue.rs execute_overweight_page_updated 467.36us Added
cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/pallet_message_queue.rs execute_overweight_page_removed 403.02us Added
cumulus/parachains/runtimes/contracts/contracts-rococo/src/weights/pallet_message_queue.rs bump_service_head 157.66us Added
Command output:

✅ Successful benchmarks of runtimes/pallets:
-- dev: ['pallet_revive']

@athei athei enabled auto-merge March 3, 2025 11:00
@paritytech-workflow-stopper
Copy link

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

@athei athei added this pull request to the merge queue Mar 3, 2025
Merged via the queue into master with commit 4b39ff0 Mar 3, 2025
243 of 253 checks passed
@athei athei deleted the at/instr-weights branch March 3, 2025 12:38
athei added a commit that referenced this pull request Mar 3, 2025
Fixes #6157

This fixes the last remaining benchmark that was not correct since it
was too low level to be written in Rust. Instead, we opted.

This PR changes the benchmark that determines the scaling from
`ref_time` to PolkaVM `Gas` by benchmarking the absolute worst case of
an instruction: One that causes two cache misses by touching two cache
lines.

The Contract itself is designed to be as simple as possible. It does
random unaligned reads in a loop until the `r` (repetition) number is
reached. The randomness is fully generated by the host and written to
the guests memory before the benchmark is run. This allows the benchmark
to determine the influence of one loop iteration via linear regression.

---------

Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: xermicus <[email protected]>
Co-authored-by: PG Herveou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T7-smart_contracts This PR/Issue is related to smart contracts.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix the sized and instruction benchmarks
4 participants