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

[omni-bencher] Make all runtimes work #5872

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
3631111
Set genesis state after each benchmark run
ggwpez Sep 9, 2024
a2cc75a
Add test
ggwpez Sep 9, 2024
50ce303
Add PrDoc (auto generated)
ggwpez Sep 9, 2024
6e87e57
Use DEV_RUNTIME_PRESET instead of hard-coding
ggwpez Sep 10, 2024
9aa865f
INSTALL WITH LOCKED FFS
ggwpez Sep 10, 2024
6bb2cb5
Revert "INSTALL WITH LOCKED FFS"
ggwpez Sep 10, 2024
c846cf5
Only test in std
ggwpez Sep 13, 2024
8809ce5
omni-bencher: Fix runtime genesis generation
ggwpez Sep 13, 2024
a9ec975
Update substrate/utils/frame/benchmarking-cli/src/pallet/command.rs
ggwpez Sep 16, 2024
f205230
Update substrate/utils/frame/benchmarking-cli/src/pallet/command.rs
ggwpez Sep 16, 2024
669c88a
Update substrate/utils/frame/benchmarking-cli/src/pallet/command.rs
ggwpez Sep 16, 2024
a539e2a
Update substrate/utils/frame/benchmarking-cli/src/pallet/command.rs
ggwpez Sep 16, 2024
f641517
Stay backwards compatible
ggwpez Sep 16, 2024
1da1213
Rename to GenesisBuilderPolicy
ggwpez Sep 20, 2024
b98d341
Merge branch 'master' into oty-omni-bencher-fix
ggwpez Sep 20, 2024
68413fa
clippy
ggwpez Sep 21, 2024
8b97944
clippy
ggwpez Sep 21, 2024
41cb2bf
clippy
ggwpez Sep 21, 2024
b3e8e15
fix bench test
ggwpez Sep 21, 2024
f7bfa0a
Merge branch 'master' into oty-omni-bencher-fix
bkontur Sep 22, 2024
4fd7581
Enable also new GHA for short-benchmarks
bkontur Sep 22, 2024
516ca5c
use correct runner for benches
alvicsam Sep 23, 2024
26d9379
Merge branch 'master' into bko-enable-gha-short-benchmarks
bkontur Sep 25, 2024
96540cb
[omni-bencher] Make work with --runtime and genesis-builder-policy=none
ggwpez Sep 30, 2024
f5f67d6
[omni-bencher] Add --exclude-pallets option
ggwpez Sep 30, 2024
2256664
CI use matrix for args
ggwpez Sep 30, 2024
59fc11f
Merge remote-tracking branch 'origin/bko-enable-gha-short-benchmarks'…
ggwpez Sep 30, 2024
d18d0a7
post merge fixes
ggwpez Sep 30, 2024
30ee680
Merge branch 'master' into oty-omni-bencher-fix2
ggwpez Sep 30, 2024
82a1ca8
fix ci
ggwpez Sep 30, 2024
e836ab4
fix ci
ggwpez Sep 30, 2024
f7e6a1d
fix ci
ggwpez Sep 30, 2024
c667d9c
fix ci
ggwpez Sep 30, 2024
f25e1f1
quiet
ggwpez Sep 30, 2024
710723c
fix
ggwpez Sep 30, 2024
aab1444
Fix missing
ggwpez Sep 30, 2024
3a42eb4
Fix missing
ggwpez Sep 30, 2024
1c70dd5
Add PrDoc (auto generated)
ggwpez Sep 30, 2024
0a8ae23
Remove old migration and fix benchmarks
ggwpez Oct 1, 2024
f4fd151
Dont exclude pallet-contracts anymore
ggwpez Oct 1, 2024
c2c4894
Merge remote-tracking branch 'origin/master' into oty-omni-bencher-fix2
ggwpez Oct 1, 2024
69d6321
add bench_flags to /cmd
mordamax Oct 1, 2024
00f7e9d
prdoc
ggwpez Oct 2, 2024
5d0d5ab
dont canonicalize path
ggwpez Oct 7, 2024
2ec7f9e
Apply suggestions from code review
ggwpez Oct 7, 2024
1235303
Merge branch 'master' into oty-omni-bencher-fix2
ggwpez Oct 7, 2024
63125fe
Add log target and better error message
ggwpez Oct 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/scripts/cmd/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def main():
print(f'-- listing pallets for benchmark for {runtime["name"]}')
wasm_file = f"target/{profile}/wbuild/{runtime['package']}/{runtime['package'].replace('-', '_')}.wasm"
output = os.popen(
f"frame-omni-bencher v1 benchmark pallet --no-csv-header --no-storage-info --no-min-squares --no-median-slopes --all --list --runtime={wasm_file}").read()
f"frame-omni-bencher v1 benchmark pallet --no-csv-header --no-storage-info --no-min-squares --no-median-slopes --all --list --runtime={wasm_file} {runtime['bench_flags']}").read()
raw_pallets = output.strip().split('\n')

all_pallets = set()
Expand Down Expand Up @@ -182,7 +182,8 @@ def main():
f"--repeat=20 " \
f"--heap-pages=4096 " \
f"{f'--template={template} ' if template else ''}" \
f"--no-storage-info --no-min-squares --no-median-slopes"
f"--no-storage-info --no-min-squares --no-median-slopes " \
f"{config['bench_flags']}"
print(f'-- Running: {cmd} \n')
status = os.system(cmd)
if status != 0 and not args.continue_on_fail:
Expand Down
169 changes: 131 additions & 38 deletions .github/scripts/cmd/test_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,54 @@

# Mock data for runtimes-matrix.json
mock_runtimes_matrix = [
{"name": "dev", "package": "kitchensink-runtime", "path": "substrate/frame", "header": "substrate/HEADER-APACHE2", "template": "substrate/.maintain/frame-weight-template.hbs", "bench_features": "runtime-benchmarks,riscv"},
{"name": "westend", "package": "westend-runtime", "path": "polkadot/runtime/westend", "header": "polkadot/file_header.txt", "template": "polkadot/xcm/pallet-xcm-benchmarks/template.hbs", "bench_features": "runtime-benchmarks"},
{"name": "rococo", "package": "rococo-runtime", "path": "polkadot/runtime/rococo", "header": "polkadot/file_header.txt", "template": "polkadot/xcm/pallet-xcm-benchmarks/template.hbs", "bench_features": "runtime-benchmarks"},
{"name": "asset-hub-westend", "package": "asset-hub-westend-runtime", "path": "cumulus/parachains/runtimes/assets/asset-hub-westend", "header": "cumulus/file_header.txt", "template": "cumulus/templates/xcm-bench-template.hbs", "bench_features": "runtime-benchmarks"},
{
"name": "dev",
"package": "kitchensink-runtime",
"path": "substrate/frame",
"header": "substrate/HEADER-APACHE2",
"template": "substrate/.maintain/frame-weight-template.hbs",
"bench_features": "runtime-benchmarks,riscv",
"bench_flags": "--flag1 --flag2"
},
{
"name": "westend",
"package": "westend-runtime",
"path": "polkadot/runtime/westend",
"header": "polkadot/file_header.txt",
"template": "polkadot/xcm/pallet-xcm-benchmarks/template.hbs",
"bench_features": "runtime-benchmarks",
"bench_flags": "--flag3 --flag4"
},
{
"name": "rococo",
"package": "rococo-runtime",
"path": "polkadot/runtime/rococo",
"header": "polkadot/file_header.txt",
"template": "polkadot/xcm/pallet-xcm-benchmarks/template.hbs",
"bench_features": "runtime-benchmarks",
"bench_flags": ""
},
{
"name": "asset-hub-westend",
"package": "asset-hub-westend-runtime",
"path": "cumulus/parachains/runtimes/assets/asset-hub-westend",
"header": "cumulus/file_header.txt",
"template": "cumulus/templates/xcm-bench-template.hbs",
"bench_features": "runtime-benchmarks",
"bench_flags": "--flag7 --flag8"
}
]

def get_mock_bench_output(runtime, pallets, output_path, header, template = None):
def get_mock_bench_output(runtime, pallets, output_path, header, bench_flags, template = None):
return f"frame-omni-bencher v1 benchmark pallet --extrinsic=* " \
f"--runtime=target/release/wbuild/{runtime}-runtime/{runtime.replace('-', '_')}_runtime.wasm " \
f"--pallet={pallets} --header={header} " \
f"--output={output_path} " \
f"--wasm-execution=compiled " \
f"--steps=50 --repeat=20 --heap-pages=4096 " \
f"{f'--template={template} ' if template else ''}" \
f"--no-storage-info --no-min-squares --no-median-slopes"
f"--no-storage-info --no-min-squares --no-median-slopes " \
f"{bench_flags}"

class TestCmd(unittest.TestCase):

Expand Down Expand Up @@ -89,10 +122,29 @@ def test_bench_command_normal_execution_all_runtimes(self):
call("forklift cargo build -p rococo-runtime --profile release --features=runtime-benchmarks"),
call("forklift cargo build -p asset-hub-westend-runtime --profile release --features=runtime-benchmarks"),

call(get_mock_bench_output('kitchensink', 'pallet_balances', './substrate/frame/balances/src/weights.rs', os.path.abspath('substrate/HEADER-APACHE2'), "substrate/.maintain/frame-weight-template.hbs")),
call(get_mock_bench_output('westend', 'pallet_balances', './polkadot/runtime/westend/src/weights', os.path.abspath('polkadot/file_header.txt'))),
call(get_mock_bench_output(
runtime='kitchensink',
pallets='pallet_balances',
output_path='./substrate/frame/balances/src/weights.rs',
header=os.path.abspath('substrate/HEADER-APACHE2'),
bench_flags='--flag1 --flag2',
template="substrate/.maintain/frame-weight-template.hbs"
)),
call(get_mock_bench_output(
runtime='westend',
pallets='pallet_balances',
output_path='./polkadot/runtime/westend/src/weights',
header=os.path.abspath('polkadot/file_header.txt'),
bench_flags='--flag3 --flag4'
)),
# skips rococo benchmark
call(get_mock_bench_output('asset-hub-westend', 'pallet_balances', './cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights', os.path.abspath('cumulus/file_header.txt'))),
call(get_mock_bench_output(
runtime='asset-hub-westend',
pallets='pallet_balances',
output_path='./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights',
header=os.path.abspath('cumulus/file_header.txt'),
bench_flags='--flag7 --flag8'
)),
]
self.mock_system.assert_has_calls(expected_calls, any_order=True)

Expand Down Expand Up @@ -121,8 +173,20 @@ def test_bench_command_normal_execution(self):
call("forklift cargo build -p westend-runtime --profile release --features=runtime-benchmarks"),

# Westend runtime calls
call(get_mock_bench_output('westend', 'pallet_balances', './polkadot/runtime/westend/src/weights', header_path)),
call(get_mock_bench_output('westend', 'pallet_staking', './polkadot/runtime/westend/src/weights', header_path)),
call(get_mock_bench_output(
runtime='westend',
pallets='pallet_balances',
output_path='./polkadot/runtime/westend/src/weights',
header=header_path,
bench_flags='--flag3 --flag4'
)),
call(get_mock_bench_output(
runtime='westend',
pallets='pallet_staking',
output_path='./polkadot/runtime/westend/src/weights',
header=header_path,
bench_flags='--flag3 --flag4'
)),
]
self.mock_system.assert_has_calls(expected_calls, any_order=True)

Expand Down Expand Up @@ -153,11 +217,12 @@ def test_bench_command_normal_execution_xcm(self):

# Westend runtime calls
call(get_mock_bench_output(
'westend',
'pallet_xcm_benchmarks::generic',
'./polkadot/runtime/westend/src/weights/xcm',
header_path,
"polkadot/xcm/pallet-xcm-benchmarks/template.hbs"
runtime='westend',
pallets='pallet_xcm_benchmarks::generic',
output_path='./polkadot/runtime/westend/src/weights/xcm',
header=header_path,
bench_flags='--flag3 --flag4',
template="polkadot/xcm/pallet-xcm-benchmarks/template.hbs"
)),
]
self.mock_system.assert_has_calls(expected_calls, any_order=True)
Expand Down Expand Up @@ -188,11 +253,35 @@ def test_bench_command_two_runtimes_two_pallets(self):
call("forklift cargo build -p westend-runtime --profile release --features=runtime-benchmarks"),
call("forklift cargo build -p rococo-runtime --profile release --features=runtime-benchmarks"),
# Westend runtime calls
call(get_mock_bench_output('westend', 'pallet_staking', './polkadot/runtime/westend/src/weights', header_path)),
call(get_mock_bench_output('westend', 'pallet_balances', './polkadot/runtime/westend/src/weights', header_path)),
call(get_mock_bench_output(
runtime='westend',
pallets='pallet_staking',
output_path='./polkadot/runtime/westend/src/weights',
header=header_path,
bench_flags='--flag3 --flag4'
)),
call(get_mock_bench_output(
runtime='westend',
pallets='pallet_balances',
output_path='./polkadot/runtime/westend/src/weights',
header=header_path,
bench_flags='--flag3 --flag4'
)),
# Rococo runtime calls
call(get_mock_bench_output('rococo', 'pallet_staking', './polkadot/runtime/rococo/src/weights', header_path)),
call(get_mock_bench_output('rococo', 'pallet_balances', './polkadot/runtime/rococo/src/weights', header_path)),
call(get_mock_bench_output(
runtime='rococo',
pallets='pallet_staking',
output_path='./polkadot/runtime/rococo/src/weights',
header=header_path,
bench_flags=''
)),
call(get_mock_bench_output(
runtime='rococo',
pallets='pallet_balances',
output_path='./polkadot/runtime/rococo/src/weights',
header=header_path,
bench_flags=''
)),
]
self.mock_system.assert_has_calls(expected_calls, any_order=True)

Expand Down Expand Up @@ -223,11 +312,12 @@ def test_bench_command_one_dev_runtime(self):
call("forklift cargo build -p kitchensink-runtime --profile release --features=runtime-benchmarks,riscv"),
# Westend runtime calls
call(get_mock_bench_output(
'kitchensink',
'pallet_balances',
manifest_dir + "/src/weights.rs",
header_path,
"substrate/.maintain/frame-weight-template.hbs"
runtime='kitchensink',
pallets='pallet_balances',
output_path=manifest_dir + "/src/weights.rs",
header=header_path,
bench_flags='--flag1 --flag2',
template="substrate/.maintain/frame-weight-template.hbs"
)),
]
self.mock_system.assert_has_calls(expected_calls, any_order=True)
Expand Down Expand Up @@ -257,10 +347,11 @@ def test_bench_command_one_cumulus_runtime(self):
call("forklift cargo build -p asset-hub-westend-runtime --profile release --features=runtime-benchmarks"),
# Asset-hub-westend runtime calls
call(get_mock_bench_output(
'asset-hub-westend',
'pallet_assets',
'./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights',
header_path
runtime='asset-hub-westend',
pallets='pallet_assets',
output_path='./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights',
header=header_path,
bench_flags='--flag7 --flag8'
)),
]

Expand Down Expand Up @@ -291,17 +382,19 @@ def test_bench_command_one_cumulus_runtime_xcm(self):
call("forklift cargo build -p asset-hub-westend-runtime --profile release --features=runtime-benchmarks"),
# Asset-hub-westend runtime calls
call(get_mock_bench_output(
'asset-hub-westend',
'pallet_xcm_benchmarks::generic',
'./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm',
header_path,
"cumulus/templates/xcm-bench-template.hbs"
runtime='asset-hub-westend',
pallets='pallet_xcm_benchmarks::generic',
output_path='./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights/xcm',
header=header_path,
bench_flags='--flag7 --flag8',
template="cumulus/templates/xcm-bench-template.hbs"
)),
call(get_mock_bench_output(
'asset-hub-westend',
'pallet_assets',
'./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights',
header_path
runtime='asset-hub-westend',
pallets='pallet_assets',
output_path='./cumulus/parachains/runtimes/assets/asset-hub-westend/src/weights',
header=header_path,
bench_flags='--flag7 --flag8'
)),
]

Expand Down
57 changes: 33 additions & 24 deletions .github/workflows/check-frame-omni-bencher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@ env:
ARTIFACTS_NAME: frame-omni-bencher-artifacts

jobs:

preflight:
# TODO: remove once migration is complete or this workflow is fully stable
if: contains(github.event.label.name, 'GHA-migration')
uses: ./.github/workflows/reusable-preflight.yml

quick-benchmarks-omni:
runs-on: ${{ needs.preflight.outputs.RUNNER }}
runs-on: parity-benchmark
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
needs: [preflight]
if: ${{ needs.preflight.outputs.changes_rust }}
env:
RUSTFLAGS: "-C debug-assertions"
RUST_BACKTRACE: "full"
WASM_BUILD_NO_COLOR: 1
WASM_BUILD_RUSTFLAGS: "-C debug-assertions"
RUST_LOG: "frame_omni_bencher=info,polkadot_sdk_frame=info"
timeout-minutes: 30
container:
image: ${{ needs.preflight.outputs.IMAGE }}
Expand All @@ -42,33 +40,41 @@ jobs:
forklift cargo build --locked --quiet --release -p asset-hub-westend-runtime --features runtime-benchmarks
forklift cargo run --locked --release -p frame-omni-bencher --quiet -- v1 benchmark pallet --runtime target/release/wbuild/asset-hub-westend-runtime/asset_hub_westend_runtime.compact.compressed.wasm --all --steps 2 --repeat 1 --quiet

runtime-matrix:
runs-on: ubuntu-latest
needs: [preflight]
if: ${{ needs.preflight.outputs.changes_rust }}
timeout-minutes: 30
outputs:
runtime: ${{ steps.runtime.outputs.runtime }}
container:
image: ${{ needs.preflight.outputs.IMAGE }}
name: Extract runtimes from matrix
steps:
- uses: actions/checkout@v4
- id: runtime
run: |
RUNTIMES=$(jq '[.[] | select(.package != null)]' .github/workflows/runtimes-matrix.json)

RUNTIMES=$(echo $RUNTIMES | jq -c .)
echo "runtime=$RUNTIMES"
echo "runtime=$RUNTIMES" >> $GITHUB_OUTPUT

run-frame-omni-bencher:
runs-on: ${{ needs.preflight.outputs.RUNNER }}
needs: [preflight] # , build-frame-omni-bencher ]
runs-on: parity-benchmark
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
needs: [preflight, runtime-matrix]
if: ${{ needs.preflight.outputs.changes_rust }}
timeout-minutes: 30
strategy:
fail-fast: false # keep running other workflows even if one fails, to see the logs of all possible failures
matrix:
runtime:
[
westend-runtime,
rococo-runtime,
asset-hub-rococo-runtime,
asset-hub-westend-runtime,
bridge-hub-rococo-runtime,
bridge-hub-westend-runtime,
collectives-westend-runtime,
coretime-rococo-runtime,
coretime-westend-runtime,
people-rococo-runtime,
people-westend-runtime,
glutton-westend-runtime,
]
runtime: ${{ fromJSON(needs.runtime-matrix.outputs.runtime) }}
container:
image: ${{ needs.preflight.outputs.IMAGE }}
env:
PACKAGE_NAME: ${{ matrix.runtime }}
PACKAGE_NAME: ${{ matrix.runtime.package }}
FLAGS: ${{ matrix.runtime.bench_flags }}
RUST_LOG: "frame_omni_bencher=info,polkadot_sdk_frame=info"
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -77,10 +83,13 @@ jobs:
run: |
RUNTIME_BLOB_NAME=$(echo $PACKAGE_NAME | sed 's/-/_/g').compact.compressed.wasm
RUNTIME_BLOB_PATH=./target/release/wbuild/$PACKAGE_NAME/$RUNTIME_BLOB_NAME
forklift cargo build --release --locked -p $PACKAGE_NAME -p frame-omni-bencher --features runtime-benchmarks
forklift cargo build --release --locked -p $PACKAGE_NAME -p frame-omni-bencher --features runtime-benchmarks --quiet
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
echo "Running short benchmarking for PACKAGE_NAME=$PACKAGE_NAME and RUNTIME_BLOB_PATH=$RUNTIME_BLOB_PATH"
ls -lrt $RUNTIME_BLOB_PATH
./target/release/frame-omni-bencher v1 benchmark pallet --runtime $RUNTIME_BLOB_PATH --all --steps 2 --repeat 1

cmd="./target/release/frame-omni-bencher v1 benchmark pallet --runtime $RUNTIME_BLOB_PATH --all --steps 2 --repeat 1 $FLAGS"
echo "Running command: $cmd"
eval "$cmd"
confirm-frame-omni-benchers-passed:
runs-on: ubuntu-latest
name: All benchmarks passed
Expand Down
Loading
Loading