Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
219094c
intro bench all
mordamax Feb 2, 2023
ca8427e
fix
mordamax Feb 5, 2023
744dec8
standardize the runtime names accross repos
mordamax Feb 6, 2023
bc8586a
fix backward compatibility
mordamax Feb 6, 2023
1ebe58b
add cumulus all command for bench
mordamax Feb 6, 2023
7637e81
Update bench-all-substrate.sh
mordamax Feb 14, 2023
366cd21
fix the artifacts dir
mordamax Feb 15, 2023
242adbe
add merge&rebase to help
mordamax Feb 15, 2023
c1c3e89
Update merge.cmd.json
mordamax Feb 15, 2023
05863eb
add bench-bm as a fallback
mordamax Feb 20, 2023
91b06af
add flags to reduce output during bench
mordamax Feb 20, 2023
f42572d
RUST_LOG = warn by default
mordamax Feb 20, 2023
498410f
move overhead to the top
mordamax Feb 21, 2023
89c36e0
fix realpath
mordamax Feb 21, 2023
55e8abd
Update bench-bm.sh
mordamax Feb 21, 2023
c47c5d8
Update bench-bm.sh
mordamax Feb 21, 2023
319ec58
Update bench-bm.sh
mordamax Feb 21, 2023
617e5a5
Update bench-bm.sh
mordamax Feb 21, 2023
a5a7c62
Update bench-bm.sh
mordamax Feb 21, 2023
f907dad
Update bench-all-polkadot.sh
mordamax Feb 21, 2023
9d15a17
Update bench-all-substrate.sh
mordamax Feb 21, 2023
4c5f503
Update bench-all-substrate.sh
mordamax Feb 21, 2023
0caa775
fix bin path
mordamax Feb 21, 2023
b6aa75c
swap vm with bm tags, fix cumulus, change log level, test substrate w…
mordamax Feb 22, 2023
f13f05b
hack for CARGO_TARGET_DIR
mordamax Feb 22, 2023
95673cd
Update bench.sh
mordamax Feb 22, 2023
c20f3f4
separate bench-all from bench, so they can be run on separate tags
mordamax Feb 23, 2023
69db68f
Update bench-all-substrate.sh
mordamax Mar 1, 2023
0835ae4
Update commands/bench/lib/bench-all-substrate.sh
mordamax Mar 1, 2023
6fcd438
Update commands/bench/lib/bench-all-polkadot.sh
mordamax Mar 1, 2023
28da730
Update commands/bench/lib/bench-all-cumulus.sh
mordamax Mar 1, 2023
b62ffdf
Update bench-all.cmd.json
mordamax Mar 1, 2023
8e81903
Merge branch 'mak/bench-all' of https://github.com/paritytech/command…
mordamax Mar 1, 2023
05518d8
Update bench.cmd.json
mordamax Mar 1, 2023
6943cf7
add example field for custom string
mordamax Mar 1, 2023
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
For now just copy existing command and modify. Later there will be more ways to do this easier from the bot itself or here via CLI.

- Run `yarn --immutable` to install `command-bot` dependency, which includes the actual supported schema for commands validation.
If you develop in parallel with `command-bot` then use something like `yarn link`
- Copy any existing command which looks the most similar.
- Change the name of command. The structure should be `/commands/<command_name>/<command_name>.cmd.json` and `/commands/<command_name>/<command_name>.sh`, because the `command_name` will be used to build a path from command to script.
- Test it in your PR:
- when running a new command - add specific flag (-v PIPELINE_SCRIPTS_REF=your-branch) to test it before merge.
Example: `/cmd queue -v PIPELINE_SCRIPTS_REF=your-branch -c new-command $ some arguments`
Example: `bot new-command -v PIPELINE_SCRIPTS_REF=your-branch $ some arguments`
- In PR with your new command - add test evidence links to your PR with the result of your command and merge after approval.
- That's it

Expand All @@ -17,4 +18,4 @@ For now just copy existing command and modify. Later there will be more ways to
To make a context of companion you need to specify it with special env variable `-v PATCH_<repo_name>=<repo_PR_number>`, for example: `-v PATCH_substrate=11649`

Example:
`/cmd queue -v PATCH_substrate=11649 -c try-runtime $ polkadot`
`bot try-runtime -v PATCH_substrate=11649 $ polkadot`
33 changes: 33 additions & 0 deletions commands/bench-all/bench-all.cmd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"$schema": "../../node_modules/command-bot/src/schema/schema.cmd.json",
"command": {
"description": "This is a wrapper to run `bench` for all pallets within BM4,5,6 runners",
"configuration": {
"gitlab": {
"job": {
"tags": [
"weights"
],
"variables": {}
}
}
},
"presets": {
"substrate-all": {
"description": "Pallet + Overhead + Machine Benchmark for Substrate for all pallets",
"repos": ["substrate"]
},
"polkadot-all": {
"description": "Pallet + Overhead Benchmark for Polkadot",
"repos": ["polkadot"],
"args": {
"runtime": { "label": "Runtime", "type_one_of": ["kusama", "polkadot", "rococo", "westend"] }
}
},
"cumulus-all": {
"description": "Pallet Benchmark for Cumulus",
"repos": ["cumulus"]
}
}
}
}
7 changes: 7 additions & 0 deletions commands/bench-all/bench-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -eu -o pipefail
shopt -s inherit_errexit

# this is a fallback for `bench` command running on BM4,5,6 machines
. "$(dirname "${BASH_SOURCE[0]}")/../bench/bench.sh" all "$@"
16 changes: 16 additions & 0 deletions commands/bench-vm/bench-vm.cmd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "../../node_modules/command-bot/src/schema/schema.cmd.json",
"command": {
"description": "This is a testing for `bench` command running on VM machine",
"configuration": {
"gitlab": {
"job": {
"tags": [
"weights-vm"
],
"variables": {}
}
}
}
}
}
7 changes: 7 additions & 0 deletions commands/bench-vm/bench-vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -eu -o pipefail
shopt -s inherit_errexit

# this is a fallback for `bench` command running on BM3 machine
. "$(dirname "${BASH_SOURCE[0]}")/../bench/bench.sh" "$@"
85 changes: 48 additions & 37 deletions commands/bench/bench.cmd.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,102 +5,113 @@
"configuration": {
"gitlab": {
"job": {
"tags": ["weights-vm"],
"tags": ["bench-bot"],
"variables": {}
}
}
},
"presets": {
"substrate": {
"description": "Pallet Benchmark for Substrate",
"substrate-pallet": {
"description": "Pallet Benchmark for Substrate for specific pallet",
"repos": ["substrate"],
"args": {
"type": { "label": "Type of bench", "type_one_of": [ "pallet" ] },
"runtime": { "label": "Runtime", "type_one_of": ["dev"] },
"pallet": { "label": "pallet", "type_rule": "/^([a-z_]+)([:]{2}[a-z_]+)?$/" }
"subcommand": { "label": "Subcommand", "type_one_of": [ "pallet" ] },
"runtime": { "label": "Runtime", "type_one_of": ["dev"] },
"pallet": { "label": "pallet", "type_rule": "/^([a-z_]+)([:]{2}[a-z_]+)?$/", "example": "pallet_name" }
}
},
"polkadot": {
"description": "Pallet Benchmark for Polkadot",
"polkadot-pallet": {
"description": "Pallet Benchmark for Polkadot for specific pallet",
"repos": ["polkadot"],
"args": {
"type": { "label": "Type of bench", "type_one_of": ["runtime", "xcm"] },
"runtime": { "label": "Runtime", "type_one_of": ["dev", "kusama-dev", "polkadot-dev", "rococo-dev", "westend-dev"] },
"pallet": { "label": "Pallet", "type_rule": "/^([a-z_]+)([:]{2}[a-z_]+)?$/" }
"subcommand": { "label": "Subcommand", "type_one_of": ["runtime", "xcm"] },
"runtime": { "label": "Runtime", "type_one_of": ["dev", "kusama", "polkadot", "rococo", "westend"] },
"pallet": { "label": "Pallet", "type_rule": "/^([a-z_]+)([:]{2}[a-z_]+)?$/", "example": "pallet_name" }
}
},
"cumulus-assets": {
"description": "Pallet Benchmark for Cumulus [assets]",
"repos": ["cumulus"],
"args": {
"type": { "label": "Type of bench", "type_one_of": ["xcm", "pallet"] },
"runtime": { "label": "Runtime", "type_one_of": ["statemine", "statemint", "test-utils", "westmint"] },
"kind": { "label": "Kind", "type_one_of": ["asset"] },
"pallet": { "label": "Pallet", "type_rule": "/^([a-z_]+)([:]{2}[a-z_]+)?$/" }
"subcommand": { "label": "Subcommand", "type_one_of": ["xcm", "pallet"] },
"runtime": { "label": "Runtime", "type_one_of": ["statemine", "statemint", "test-utils", "westmint"] },
"kind": { "label": "Kind", "type_one_of": ["asset"] },
"pallet": { "label": "Pallet", "type_rule": "/^([a-z_]+)([:]{2}[a-z_]+)?$/", "example": "pallet_name" }
}
},
"cumulus-collectives": {
"description": "Pallet Benchmark for Cumulus [collectives]",
"repos": ["cumulus"],
"args": {
"type": { "label": "Type of bench", "type_one_of": ["xcm", "pallet"] },
"runtime": { "label": "Runtime", "type_one_of": ["collectives-polkadot"] },
"kind": { "label": "Kind", "type_one_of": ["collectives"] },
"pallet": { "label": "Pallet", "type_rule": "/^([a-z_]+)([:]{2}[a-z_]+)?$/" }
"subcommand": { "label": "Subcommand", "type_one_of": ["xcm", "pallet"] },
"runtime": { "label": "Runtime", "type_one_of": ["collectives-polkadot"] },
"kind": { "label": "Kind", "type_one_of": ["collectives"] },
"pallet": { "label": "Pallet", "type_rule": "/^([a-z_]+)([:]{2}[a-z_]+)?$/", "example": "pallet_name" }
}
},
"cumulus-bridge-hubs": {
"description": "Pallet Benchmark for Cumulus [bridge-hubs]",
"repos": ["cumulus"],
"args": {
"subcommand": { "label": "Subcommand", "type_one_of": ["xcm", "pallet"] },
"runtime": { "label": "Runtime", "type_one_of": ["bridge-hub-polkadot", "bridge-hub-kusama", "bridge-hub-rococo"] },
"kind": { "label": "Kind", "type_one_of": ["bridge-hubs"] },
"pallet": { "label": "Pallet", "type_rule": "/^([a-z_]+)([:]{2}[a-z_]+)?$/", "example": "pallet_name" }
}
},
"cumulus-contracts": {
"description": "Pallet Benchmark for Cumulus [contracts]",
"repos": ["cumulus"],
"args": {
"type": { "label": "Type of bench", "type_one_of": ["xcm", "pallet"] },
"runtime": { "label": "Runtime", "type_one_of": ["contracts-rococo"] },
"kind": { "label": "Kind", "type_one_of": ["contracts"] },
"pallet": { "label": "Pallet", "type_rule": "/^([a-z_]+)([:]{2}[a-z_]+)?$/" }
"subcommand": { "label": "Subcommand", "type_one_of": ["xcm", "pallet"] },
"runtime": { "label": "Runtime", "type_one_of": ["contracts-rococo"] },
"kind": { "label": "Kind", "type_one_of": ["contracts"] },
"pallet": { "label": "Pallet", "type_rule": "/^([a-z_]+)([:]{2}[a-z_]+)?$/", "example": "pallet_name" }
}
},
"cumulus-starters": {
"description": "Pallet Benchmark for Cumulus [starters]",
"repos": ["cumulus"],
"args": {
"type": { "label": "Type of bench", "type_one_of": ["xcm", "pallet"] },
"runtime": { "label": "Runtime", "type_one_of": ["seedling", "shell"] },
"kind": { "label": "Kind", "type_one_of": ["starters"] },
"pallet": { "label": "Pallet", "type_rule": "/^([a-z_]+)([:]{2}[a-z_]+)?$/" }
"subcommand": { "label": "Subcommand", "type_one_of": ["xcm", "pallet"] },
"runtime": { "label": "Runtime", "type_one_of": ["seedling", "shell"] },
"kind": { "label": "Kind", "type_one_of": ["starters"] },
"pallet": { "label": "Pallet", "type_rule": "/^([a-z_]+)([:]{2}[a-z_]+)?$/", "example": "pallet_name" }
}
},
"cumulus-testing": {
"description": "Pallet Benchmark for Cumulus [testing]",
"repos": ["cumulus"],
"args": {
"type": { "label": "Type of bench", "type_one_of": ["xcm", "pallet"] },
"runtime": { "label": "Runtime", "type_one_of": ["penpal", "rococo-parachain"] },
"kind": { "label": "Kind", "type_one_of": ["testing"] },
"pallet": { "label": "Pallet", "type_rule": "/^([a-z_]+)([:]{2}[a-z_]+)?$/" }
"subcommand": { "label": "Subcommand", "type_one_of": ["xcm", "pallet"] },
"runtime": { "label": "Runtime", "type_one_of": ["penpal", "rococo-parachain"] },
"kind": { "label": "Kind", "type_one_of": ["testing"] },
"pallet": { "label": "Pallet", "type_rule": "/^([a-z_]+)([:]{2}[a-z_]+)?$/", "example": "pallet_name"
}
}
},
"substrate-overhead": {
"description": "Runs `benchmark overhead` and commits back to PR the updated `extrinsic_weights.rs` files",
"repos": ["substrate"],
"args": {
"type": { "label": "Type of bench", "type_one_of": ["overhead"] }
"subcommand": { "label": "Subcommand", "type_one_of": ["overhead"] }
}
},
"polkadot-overhead": {
"description": "Runs `benchmark overhead` and commits back to PR the updated `extrinsic_weights.rs` files",
"repos": ["polkadot"],
"args": {
"type": { "label": "Type of bench", "type_one_of": ["overhead"] },
"runtime":{ "label": "Runtime", "type_one_of": ["kusama-dev", "polkadot-dev", "rococo-dev", "westend-dev"] }
"subcommand": { "label": "Subcommand", "type_one_of": ["overhead"] },
"runtime": { "label": "Runtime", "type_one_of": ["kusama-dev", "polkadot-dev", "rococo-dev", "westend-dev"] }
}
},
"cumulus-overhead": {
"description": "Runs `benchmark overhead` and commits back to PR the updated `extrinsic_weights.rs` files",
"repos": ["cumulus"],
"args": {
"type": { "label": "Type of bench", "type_one_of": ["overhead"] },
"kind": { "label": "Kind", "type_one_of": ["asset"] },
"runtime":{ "label": "Runtime", "type_one_of": ["statemine", "statemint", "test-utils", "westmint"] }
"subcommand": { "label": "Subcommand", "type_one_of": ["overhead"] },
"kind": { "label": "Kind", "type_one_of": ["asset"] },
"runtime": { "label": "Runtime", "type_one_of": ["statemine", "statemint", "test-utils", "westmint"] }
}
}
}
Expand Down
50 changes: 47 additions & 3 deletions commands/bench/bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,31 @@
set -eu -o pipefail
shopt -s inherit_errexit

. "$(dirname "${BASH_SOURCE[0]}")/../cmd_runner.sh"
# realpath allows to reuse the current
BENCH_ROOT_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")")

. "$BENCH_ROOT_DIR/../utils.sh"
. "$BENCH_ROOT_DIR/../cmd_runner.sh"

cargo_run_benchmarks="cargo run --quiet --profile=production"
current_folder="$(basename "$PWD")"

get_arg optional --repo "$@"
repository="${out:=$current_folder}"

echo "Repo: $repository"

cargo_run() {
echo "Running $cargo_run_benchmarks" "${args[@]}"

# if not patched with PATCH_something=123 then use --locked
if [[ -z "${BENCH_PATCHED:-}" ]]; then
cargo_run_benchmarks+=" --locked"
fi

$cargo_run_benchmarks "${args[@]}"
}


main() {
cmd_runner_setup
Expand Down Expand Up @@ -49,8 +73,28 @@ main() {
cmd_runner_apply_patches

set -x
# Runs the command to generate the weights
. "$(dirname "${BASH_SOURCE[0]}")/build-bench-args.sh" "$@"

local subcommand="$1"
shift

case "$subcommand" in
runtime|pallet|xcm)
echo 'Running bench_pallet'
. "$BENCH_ROOT_DIR/lib/bench-pallet.sh" "$subcommand" "$@"
;;
overhead)
echo 'Running bench_overhead'
. "$BENCH_ROOT_DIR/lib/bench-overhead.sh" "$subcommand" "$@"
;;
all)
echo "Running all-$repository"
. "$BENCH_ROOT_DIR/lib/bench-all-${repository}.sh" "$@"
;;
*)
die "Invalid subcommand $subcommand to process_args"
;;
esac

set +x

# in case we used diener to patch some dependency during benchmark execution,
Expand Down
Loading