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

LAst resort - dind - vm #59

Closed
wants to merge 59 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
26c668f
trying to backport the old benches
mordamax Oct 20, 2024
a026544
Update cmd.py
mordamax Oct 21, 2024
a465d8b
Update cmd.py
mordamax Oct 21, 2024
58dab0f
Update cmd.py
mordamax Oct 21, 2024
7cc592f
Update cmd.py
mordamax Oct 21, 2024
a29d714
Update cmd.py
mordamax Oct 21, 2024
97e62a0
Update cmd.py
mordamax Oct 21, 2024
f5ae184
[skip ci] add build log
mordamax Oct 21, 2024
cc5de90
[skip ci] disable forklift add --locked
mordamax Oct 21, 2024
73e18fc
Update cmd.py
mordamax Oct 22, 2024
ed66cff
Update from mordamax running command 'bench-old --runtime westend --p…
actions-user Oct 22, 2024
d500d8e
Update from mordamax running command 'bench-old --runtime westend --p…
actions-user Oct 22, 2024
c616ea1
add machine test to old
mordamax Oct 22, 2024
27ad977
Update from mordamax running command 'bench --runtime westend --palle…
actions-user Oct 22, 2024
2e4537e
Merge branch 'master' of https://github.com/paritytech/polkadot-sdk i…
Oct 22, 2024
c9d4dc8
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Oct 22, 2024
237128b
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Oct 22, 2024
7ba35b4
disable docker in docker
mordamax Oct 25, 2024
2443f92
move checkout earlier
mordamax Oct 25, 2024
10ea752
Update cmd.yml
mordamax Oct 25, 2024
695b8cc
Update cmd.yml
mordamax Oct 25, 2024
3ccada6
add cache and remove forklift
mordamax Oct 25, 2024
f704741
oldlinux
mordamax Oct 29, 2024
6094201
cmd-bot-vm
mordamax Oct 29, 2024
872a020
cmd-bot-vm - production
mordamax Oct 29, 2024
4639b82
[pallet-revive] fix fixture build path (#6174)
pgherveou Oct 22, 2024
adf4b5e
`fatxpool`: `LocalTransactionPool` implemented (#6104)
michalkucharczyk Oct 22, 2024
1360dba
Use bool::then instead of then_some with function calls (#6156)
tmpolaczyk Oct 22, 2024
34f471d
Assets in pool with native can be used in `query_weight_to_asset_fee`…
franciscoaguirre Oct 22, 2024
6ee3538
[pallet-revive] Add pallet to AH westend (#5502)
pgherveou Oct 23, 2024
74bb59a
Polkadot OmniNode Docs (#6094)
kianenigma Oct 23, 2024
88f4306
Fix `zombienet-bridges-0001-asset-transfer-works` (#6175)
serban300 Oct 24, 2024
6e31925
[pallet-revive] fix hardcoded gas in tests (#6192)
pgherveou Oct 24, 2024
79ec5ae
Added Trusted Query API implementation for Westend and Rococo relay c…
x3c41a Oct 24, 2024
4f6ec7c
Snowbridge: PNA Audit Better Documentation and minor Refactorings (#6…
alistair-singh Oct 24, 2024
83cd90e
Enable approval-voting-parallel by default on kusama (#6218)
alexggh Oct 24, 2024
1cb818b
pallet macro: Support instantiable pallets in tasks (#5194)
gui1117 Oct 24, 2024
4a867ab
Disable tests reported in #6062 (#6064)
pepoviola Oct 24, 2024
ac8f907
Fix a tiny typo (#6229)
jasl Oct 24, 2024
197faa8
pallet-message-queue: Fix max message size calculation (#6205)
bkchr Oct 24, 2024
ae2102c
`RuntimeGenesiConfig`: json macro added (#5813)
michalkucharczyk Oct 25, 2024
d3f9220
substrate-offchain: upgrade hyper to v1 (#5919)
ShoyuVanilla Oct 25, 2024
5482b6b
pallet-revive: Add stateful address mapping (#6096)
athei Oct 25, 2024
807dc3b
Fix migrations for pallet-xcm (#6148)
bkontur Oct 25, 2024
ce09c20
asset-hubs: simplify xcm-config (#6222)
acatangiu Oct 25, 2024
3d11c7f
Switch node side to v2 candidate receipts (#5679)
sandreim Oct 25, 2024
0e4bcce
Fix a flaky zombienet test - 0004-coretime-smoke-test (#6236)
tdimitrov Oct 28, 2024
2d03832
fix experimental-ump-signals tests (#6214)
alindima Oct 28, 2024
7d04b0b
remove parachains_assigner code (#6171)
alindima Oct 28, 2024
5f95c0b
[pallet-revive] Add Ethereum JSON-RPC server (#6147)
pgherveou Oct 28, 2024
a3b51c4
[pallet-revive] Update typeInfo (#6263)
pgherveou Oct 28, 2024
e9184b6
pallet-revive: Trade code size for call stack depth (#6264)
athei Oct 28, 2024
ecc9520
[pallet-revive] implement tx origin API (#6105)
xermicus Oct 29, 2024
f7d40ab
Use frame umbrella crate in `pallet-proxy` and `pallet-multisig` (#5995)
kianenigma Oct 29, 2024
65ee481
Migrate pallet-vesting benchmark to v2 (#6254)
aurexav Oct 29, 2024
b41419a
Migrate pallet-timestamp benchmark to v2 (#6258)
aurexav Oct 29, 2024
f5bfe01
[Identity] Decouple usernames from identities (#5554)
georgepisaltu Oct 29, 2024
17eee37
pallet-revive: Use custom target to build test fixtures (#6266)
athei Oct 29, 2024
c852c6c
Update README.md
mordamax Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .github/env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
IMAGE="docker.io/paritytech/ci-unified:bullseye-1.81.0-2024-09-11-v202409111034"
RUST_NIGHTLY_VERSION="2024-09-11"
216 changes: 204 additions & 12 deletions .github/scripts/cmd/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import argparse
import _help
import importlib.util
import re

_HelpAction = _help._HelpAction

Expand Down Expand Up @@ -40,20 +41,20 @@ def setup_logging():
setup_logging()

"""
BENCH
BENCH
"""

bench_example = '''**Examples**:
Runs all benchmarks
Runs all benchmarks
%(prog)s

Runs benchmarks for pallet_balances and pallet_multisig for all runtimes which have these pallets. **--quiet** makes it to output nothing to PR but reactions
%(prog)s --pallet pallet_balances pallet_xcm_benchmarks::generic --quiet

Runs bench for all pallets for westend runtime and fails fast on first failed benchmark
%(prog)s --runtime westend --fail-fast
Does not output anything and cleans up the previous bot's & author command triggering comments in PR

Does not output anything and cleans up the previous bot's & author command triggering comments in PR
%(prog)s --runtime westend rococo --pallet pallet_balances pallet_multisig --quiet --clean
'''

Expand All @@ -66,15 +67,44 @@ def setup_logging():
parser_bench.add_argument('--pallet', help='Pallet(s) space separated', nargs='*', default=[])
parser_bench.add_argument('--fail-fast', help='Fail fast on first failed benchmark', action='store_true')


"""
FMT
BENCH OLD
"""

bench_example = '''**Examples**:
Runs all benchmarks
%(prog)s

Runs benchmarks for pallet_balances and pallet_multisig for all runtimes which have these pallets. **--quiet** makes it to output nothing to PR but reactions
%(prog)s --pallet pallet_balances pallet_xcm_benchmarks::generic --quiet

Runs bench for all pallets for westend runtime and fails fast on first failed benchmark
%(prog)s --runtime westend --fail-fast

Does not output anything and cleans up the previous bot's & author command triggering comments in PR
%(prog)s --runtime westend rococo --pallet pallet_balances pallet_multisig --quiet --clean
'''

parser_bench_old = subparsers.add_parser('bench-old', help='Runs benchmarks (Old CLI)', epilog=bench_example, formatter_class=argparse.RawDescriptionHelpFormatter)

for arg, config in common_args.items():
parser_bench_old.add_argument(arg, **config)

parser_bench_old.add_argument('--runtime', help='Runtime(s) space separated', choices=runtimeNames, nargs='*', default=runtimeNames)
parser_bench_old.add_argument('--pallet', help='Pallet(s) space separated', nargs='*', default=[])
parser_bench_old.add_argument('--fail-fast', help='Fail fast on first failed benchmark', action='store_true')


"""
FMT
"""
parser_fmt = subparsers.add_parser('fmt', help='Formats code (cargo +nightly-VERSION fmt) and configs (taplo format)')
for arg, config in common_args.items():
parser_fmt.add_argument(arg, **config)

"""
Update UI
Update UI
"""
parser_ui = subparsers.add_parser('update-ui', help='Updates UI tests')
for arg, config in common_args.items():
Expand Down Expand Up @@ -102,7 +132,7 @@ def main():
failed_benchmarks = {}
successful_benchmarks = {}

profile = "release"
profile = "production"

print(f'Provided runtimes: {args.runtime}')
# convert to mapped dict
Expand All @@ -112,11 +142,22 @@ def main():

# loop over remaining runtimes to collect available pallets
for runtime in runtimesMatrix.values():
os.system(f"forklift cargo build -p {runtime['package']} --profile {profile} --features={runtime['bench_features']}")
build_command = f"cargo build -p {runtime['package']} --profile {profile} --features={runtime['bench_features']}"
print(f'-- building "{runtime["name"]}" with `{build_command}`')
os.system(build_command)
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} {runtime['bench_flags']}").read()
list_command = f"frame-omni-bencher v1 benchmark pallet " \
f"--no-csv-header " \
f"--no-storage-info " \
f"--no-min-squares " \
f"--no-median-slopes " \
f"--all " \
f"--list " \
f"--runtime={wasm_file} " \
f"{runtime['bench_flags']}"
print(f'-- running: {list_command}')
output = os.popen(list_command).read()
raw_pallets = output.strip().split('\n')

all_pallets = set()
Expand Down Expand Up @@ -175,7 +216,15 @@ def main():
print(f'-- package_dir: {package_dir}')
print(f'-- manifest_path: {manifest_path}')
output_path = os.path.join(package_dir, "src", "weights.rs")
# TODO: we can remove once all pallets in dev runtime are migrated to polkadot-sdk-frame
try:
uses_polkadot_sdk_frame = "true" in os.popen(f"cargo metadata --locked --format-version 1 --no-deps | jq -r '.packages[] | select(.name == \"{pallet.replace('_', '-')}\") | .dependencies | any(.name == \"polkadot-sdk-frame\")'").read()
# Empty output from the previous os.popen command
except StopIteration:
uses_polkadot_sdk_frame = False
template = config['template']
if uses_polkadot_sdk_frame and re.match(r"frame-(:?umbrella-)?weight-template\.hbs", os.path.normpath(template).split(os.path.sep)[-1]):
template = "substrate/.maintain/frame-umbrella-weight-template.hbs"
else:
default_path = f"./{config['path']}/src/weights"
xcm_path = f"./{config['path']}/src/weights/xcm"
Expand Down Expand Up @@ -221,6 +270,149 @@ def main():
print_and_log('✅ Successful benchmarks of runtimes/pallets:')
for runtime, pallets in successful_benchmarks.items():
print_and_log(f'-- {runtime}: {pallets}')

if args.command == 'bench-old':
runtime_pallets_map = {}
failed_benchmarks = {}
successful_benchmarks = {}

profile = "release"

print(f'Provided runtimes: {args.runtime}')
# convert to mapped dict
runtimesMatrix = list(filter(lambda x: x['name'] in args.runtime, runtimesMatrix))
runtimesMatrix = {x['name']: x for x in runtimesMatrix}
print(f'Filtered out runtimes: {runtimesMatrix}')

# loop over remaining runtimes to collect available pallets
for runtime in runtimesMatrix.values():
build_command = f"cargo build -p {runtime['old_package']} --profile {profile} --features={runtime['bench_features']} --locked"
print(f'-- building {runtime["name"]} with `{build_command}`')
os.system(build_command)

chain = runtime['name'] if runtime == 'dev' else f"{runtime['name']}-dev"

machine_test = f"target/{profile}/{runtime['old_bin']} benchmark machine --chain={chain}"
print(f"Running machine test for `{machine_test}`")
os.system(machine_test)

print(f'-- listing pallets for benchmark for {chain}')
list_command = f"target/{profile}/{runtime['old_bin']} " \
f"benchmark pallet " \
f"--no-csv-header " \
f"--no-storage-info " \
f"--no-min-squares " \
f"--no-median-slopes " \
f"--all " \
f"--list " \
f"--chain={chain}"
print(f'-- running: {list_command}')
output = os.popen(list_command).read()
raw_pallets = output.strip().split('\n')

all_pallets = set()
for pallet in raw_pallets:
if pallet:
all_pallets.add(pallet.split(',')[0].strip())

pallets = list(all_pallets)
print(f'Pallets in {runtime["name"]}: {pallets}')
runtime_pallets_map[runtime['name']] = pallets

print(f'\n')

# filter out only the specified pallets from collected runtimes/pallets
if args.pallet:
print(f'Pallets: {args.pallet}')
new_pallets_map = {}
# keep only specified pallets if they exist in the runtime
for runtime in runtime_pallets_map:
if set(args.pallet).issubset(set(runtime_pallets_map[runtime])):
new_pallets_map[runtime] = args.pallet

runtime_pallets_map = new_pallets_map

print(f'Filtered out runtimes & pallets: {runtime_pallets_map}\n')

if not runtime_pallets_map:
if args.pallet and not args.runtime:
print(f"No pallets {args.pallet} found in any runtime")
elif args.runtime and not args.pallet:
print(f"{args.runtime} runtime does not have any pallets")
elif args.runtime and args.pallet:
print(f"No pallets {args.pallet} found in {args.runtime}")
else:
print('No runtimes found')
sys.exit(1)

for runtime in runtime_pallets_map:
for pallet in runtime_pallets_map[runtime]:
config = runtimesMatrix[runtime]
header_path = os.path.abspath(config['header'])
template = None

chain = runtime['name'] if runtime == 'dev' else f"{config['name']}-dev"

print(f'-- config: {config}')
if runtime == 'dev':
# to support sub-modules (https://github.com/paritytech/command-bot/issues/275)
search_manifest_path = f"cargo metadata --locked --format-version 1 --no-deps | jq -r '.packages[] | select(.name == \"{pallet.replace('_', '-')}\") | .manifest_path'"
print(f'-- running: {search_manifest_path}')
manifest_path = os.popen(search_manifest_path).read()
if not manifest_path:
print(f'-- pallet {pallet} not found in dev runtime')
if args.fail_fast:
print_and_log(f'Error: {pallet} not found in dev runtime')
sys.exit(1)
package_dir = os.path.dirname(manifest_path)
print(f'-- package_dir: {package_dir}')
print(f'-- manifest_path: {manifest_path}')
output_path = os.path.join(package_dir, "src", "weights.rs")
template = config['template']
else:
default_path = f"./{config['path']}/src/weights"
xcm_path = f"./{config['path']}/src/weights/xcm"
output_path = default_path
if pallet.startswith("pallet_xcm_benchmarks"):
template = config['template']
output_path = xcm_path

print(f'-- benchmarking {pallet} in {runtime} into {output_path}')
cmd = f"target/{profile}/{config['old_bin']} benchmark pallet " \
f"--extrinsic=* " \
f"--chain={chain} " \
f"--pallet={pallet} " \
f"--header={header_path} " \
f"--output={output_path} " \
f"--wasm-execution=compiled " \
f"--steps=50 " \
f"--repeat=20 " \
f"--heap-pages=4096 " \
f"{f'--template={template} ' if template else ''}" \
f"--no-storage-info --no-min-squares --no-median-slopes "
print(f'-- Running: {cmd} \n')
status = os.system(cmd)

if status != 0 and args.fail_fast:
print_and_log(f'❌ Failed to benchmark {pallet} in {runtime}')
sys.exit(1)

# Otherwise collect failed benchmarks and print them at the end
# push failed pallets to failed_benchmarks
if status != 0:
failed_benchmarks[f'{runtime}'] = failed_benchmarks.get(f'{runtime}', []) + [pallet]
else:
successful_benchmarks[f'{runtime}'] = successful_benchmarks.get(f'{runtime}', []) + [pallet]

if failed_benchmarks:
print_and_log('❌ Failed benchmarks of runtimes/pallets:')
for runtime, pallets in failed_benchmarks.items():
print_and_log(f'-- {runtime}: {pallets}')

if successful_benchmarks:
print_and_log('✅ Successful benchmarks of runtimes/pallets:')
for runtime, pallets in successful_benchmarks.items():
print_and_log(f'-- {runtime}: {pallets}')

elif args.command == 'fmt':
command = f"cargo +nightly fmt"
Expand Down Expand Up @@ -251,4 +443,4 @@ def main():
print('🚀 Done')

if __name__ == '__main__':
main()
main()
37 changes: 29 additions & 8 deletions .github/workflows/cmd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ jobs:
fi

if [[ $BODY == "/cmd bench"* ]]; then
echo "RUNNER=parity-weights" >> $GITHUB_OUTPUT
echo "RUNNER=cmd-bot-vm" >> $GITHUB_OUTPUT
elif [[ $BODY == "/cmd update-ui"* ]]; then
echo "RUNNER=parity-large" >> $GITHUB_OUTPUT
else
Expand Down Expand Up @@ -284,9 +284,29 @@ jobs:
JOB_NAME: "cmd"
runs-on: ${{ needs.set-image.outputs.RUNNER }}
timeout-minutes: 4320 # 72 hours -> 3 days; as it could take a long time to run all the runtimes/pallets
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Install updates and protobuf-compiler
run: |
sudo apt update && sudo apt install --assume-yes \
openssl pkg-config g++ make cmake protobuf-compiler curl libssl-dev libclang-dev libudev-dev git jq python3 python3-pip

- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ needs.get-pr-branch.outputs.repo }}
ref: ${{ needs.get-pr-branch.outputs.pr-branch }}

- name: Set rust version via common env file
run: |
cat .github/env >> $GITHUB_ENV

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
targets: "wasm32-unknown-unknown,x86_64-unknown-linux-musl"
components: "rust-src rustfmt clippy"
toolchain: "nightly-${{env.RUST_NIGHTLY_VERSION}}"

- name: Get command
uses: actions-ecosystem/action-regex-match@v2
id: get-pr-comment
Expand Down Expand Up @@ -340,12 +360,12 @@ jobs:
repo: context.repo.repo,
body: `Command "${{ steps.get-pr-comment.outputs.group2 }}" has started 🚀 [See logs here](${job_url})`
})

- name: Checkout
uses: actions/checkout@v4

- name: Cache Rust dependencies
if: startsWith(steps.get-pr-comment.outputs.group2, 'bench')
uses: Swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab # v2.7.5
with:
repository: ${{ needs.get-pr-branch.outputs.repo }}
ref: ${{ needs.get-pr-branch.outputs.pr-branch }}
cache-on-failure: true

- name: Install dependencies for bench
if: startsWith(steps.get-pr-comment.outputs.group2, 'bench')
Expand All @@ -364,6 +384,7 @@ jobs:
# Fixes "detected dubious ownership" error in the ci
git config --global --add safe.directory '*'
git remote -v
cat /proc/cpuinfo
python3 -m pip install -r .github/scripts/generate-prdoc.requirements.txt
python3 .github/scripts/cmd/cmd.py $CMD $PR_ARG
git status
Expand Down
Loading
Loading