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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

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']


// Create all possible addresses and shuffle them. This makes sure
// the accesses are random but no address is accessed more than once.
// we skip the first address since it is out entry point
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// we skip the first address since it is out entry point
// we skip the first address since it is our entry point

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
3 participants