Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add benchmarks to pipeline #1074

Merged
merged 35 commits into from
Apr 12, 2022
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
af3cca0
[Do not merge] add benchmarks to pipeline
alvicsam Mar 9, 2022
fd948a5
disable jobs for test
alvicsam Mar 9, 2022
7d3c3f2
Revert "[Do not merge] add benchmarks to pipeline"
alvicsam Mar 11, 2022
070612b
add weights tag
alvicsam Mar 11, 2022
19af064
add stage
alvicsam Mar 11, 2022
11803a6
empty before_script for benches
alvicsam Mar 11, 2022
4b8e1fe
run benchmarks on ci6
alvicsam Mar 11, 2022
8f1621f
disable cargo target dir
alvicsam Mar 11, 2022
13e062d
disable pre-cache
alvicsam Mar 11, 2022
2b18fda
add CARGO_TARGET_DIR var to bench script
alvicsam Mar 11, 2022
b216617
debug
alvicsam Mar 11, 2022
9336c60
debug
alvicsam Mar 22, 2022
8a3a20a
fix script path
alvicsam Mar 22, 2022
d698436
divide build and benchmark into 2 jobs
alvicsam Mar 23, 2022
ecf057c
fix bench build
alvicsam Mar 23, 2022
5594fde
small fix
alvicsam Mar 23, 2022
89b7b99
reduce benchmark output log
alvicsam Mar 23, 2022
99d750a
add push github
alvicsam Mar 30, 2022
d672528
add push gh
alvicsam Mar 31, 2022
dab0fcf
add after_script
alvicsam Mar 31, 2022
70b7ed0
typo fix
alvicsam Mar 31, 2022
cd1cac2
typo fix
alvicsam Mar 31, 2022
1092e12
fix curl
alvicsam Mar 31, 2022
291fd83
fix git config
alvicsam Mar 31, 2022
05a777d
add title and body to pr
alvicsam Apr 1, 2022
c1b2db6
final check that everything works
alvicsam Apr 4, 2022
8ac053e
final check that everything works
alvicsam Apr 4, 2022
5a4f338
return jobs back
alvicsam Apr 4, 2022
2246b0c
fix rules
alvicsam Apr 4, 2022
463a3ae
cancel changes benchmarks.sh
alvicsam Apr 4, 2022
3a40468
Apply suggestions from code review
alvicsam Apr 4, 2022
886ab0c
rename job
alvicsam Apr 4, 2022
ea26a59
change benches jobs to run on release-parachains-v*
alvicsam Apr 11, 2022
df176a3
Merge branch 'master' into as-benches
alvicsam Apr 11, 2022
2a37653
remove master refs
alvicsam Apr 11, 2022
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
97 changes: 78 additions & 19 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,68 @@
stages:
- test
- publish
- benchmarks-build
- benchmarks-run

variables: &default-vars
default:
interruptible: true
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure

variables:
GIT_STRATEGY: fetch
GIT_DEPTH: 100
CARGO_INCREMENTAL: 0
CI_IMAGE: "paritytech/ci-linux:production"
DOCKER_OS: "debian:stretch"
ARCH: "x86_64"

.collect-artifacts: &collect-artifacts
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
when: on_success
expire_in: 1 days
paths:
- ./artifacts/

.rust-info-script: &rust-info-script
- rustup show
- cargo --version
- rustup +nightly show
- cargo +nightly --version
- bash --version
- sccache -s

.publish-refs: &publish-refs
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1

# run benchmarks manually only on release-parachains-v* branch
.benchmarks-manual-refs: &benchmarks-manual-refs
rules:
- if: $CI_COMMIT_REF_NAME =~ /^release-parachains-v[0-9]+\.[0-9]+.*$/ # i.e. release-parachains-v1.0, release-parachains-v2.1rc1
when: manual

# run benchmarks only on release-parachains-v* branch
.benchmarks-refs: &benchmarks-refs
rules:
- if: $CI_COMMIT_REF_NAME =~ /^release-parachains-v[0-9]+\.[0-9]+.*$/ # i.e. release-parachains-v1.0, release-parachains-v2.1rc1
when: manual

.docker-env: &docker-env
image: "${CI_IMAGE}"
before_script:
- *rust-info-script
- sccache -s
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
interruptible: true
tags:
- linux-docker

.kubernetes-env: &kubernetes-env
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
interruptible: true
image: "${CI_IMAGE}"
tags:
- kubernetes-parity-build

Expand Down Expand Up @@ -84,7 +100,6 @@ test-linux-stable:
- if: $CI_PIPELINE_SOURCE == "schedule"
<<: *collect-artifacts
variables:
<<: *default-vars
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
Expand Down Expand Up @@ -136,7 +151,6 @@ check-rustdoc:
stage: test
<<: *docker-env
variables:
<<: *default-vars
SKIP_WASM_BUILD: 1
RUSTDOCFLAGS: "-Dwarnings"
script:
Expand Down Expand Up @@ -169,3 +183,48 @@ publish-s3:
after_script:
- aws s3 ls s3://${BUCKET}/${PREFIX}/latest/
--recursive --human-readable --summarize

#### stage: benchmarks
# Work only on release-parachains-v* branches

benchmarks-build:
stage: benchmarks-build
<<: *docker-env
<<: *collect-artifacts
<<: *benchmarks-manual-refs
script:
- time cargo build --profile production --locked --features runtime-benchmarks
- mkdir artifacts
- cp $CARGO_TARGET_DIR/production/polkadot-collator ./artifacts/

benchmarks:
stage: benchmarks-run
before_script:
- *rust-info-script
<<: *collect-artifacts
<<: *benchmarks-refs
script:
- ./scripts/benchmarks-ci.sh statemine > ./artifacts/bench-statemine.log
- ./scripts/benchmarks-ci.sh statemint > ./artifacts/bench-statemint.log
- ./scripts/benchmarks-ci.sh westmint > ./artifacts/bench-westmint.log
- git status
- export BRANCHNAME="${CI_COMMIT_BRANCH}-weights"
# Set git config
- rm -rf .git/config
- git config --global user.email "${GITHUB_EMAIL}"
- git config --global user.name "${GITHUB_USER}"
- git config remote.origin.url "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com:/paritytech/${CI_PROJECT_NAME}.git"
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
# push results to github
- git checkout -b $BRANCHNAME
- git add polkadot-parachains/*
- git commit -m "[benchmarks] pr with wieghts"
- git push origin $BRANCHNAME
# create PR
- curl -u ${GITHUB_USER}:${GITHUB_TOKEN}
-d '{"title":"[benchmarks] Update weights","body":"This PR is generated automatically by CI.","head":"'$BRANCHNAME'","base":"'${CI_COMMIT_BRANCH}'"}'
-X POST https://api.github.com/repos/paritytech/${CI_PROJECT_NAME}/pulls
after_script:
- rm -rf .git/config
tags:
- weights
37 changes: 37 additions & 0 deletions scripts/benchmarks-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

steps=50
repeat=20
chainName=$1

benhcmarkOutput=./polkadot-parachains/$chainName/src/weights
benhcmarkChainName="$chainName-dev"

pallets=(
pallet_assets
pallet_balances
pallet_collator_selection
pallet_multisig
pallet_proxy
pallet_session
pallet_timestamp
pallet_utility
pallet_uniques
cumulus_pallet_xcmp_queue
frame_system
)

for p in ${pallets[@]}
do
./artifacts/polkadot-collator benchmark \
--chain=$benhcmarkChainName \
--execution=wasm \
--wasm-execution=compiled \
--pallet=$p \
--extrinsic='*' \
--steps=$steps \
--repeat=$repeat \
--json \
--header=./file_header.txt \
--output=$benhcmarkOutput
done