-
Notifications
You must be signed in to change notification settings - Fork 293
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
[ci] add gitlab pipeline for criterion benchmarks #422
Changes from 33 commits
eccb2ea
410c90c
d2c7401
55cd0af
9c39f52
ddcb3fa
0341a77
27c855d
8ba2dfe
ed08dfd
9b119d6
9f26a68
89f75ec
d0d9037
07e3001
2104958
880312d
22b5ad2
0127464
66d3699
5fb1be0
e00c1d2
173cadb
ae857eb
e4367b9
2b616e2
aafb623
8e88798
a318e4c
aad4cae
c8fa34d
0582356
bdfa811
e916aec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# paritytech/wasmi | ||
|
||
stages: | ||
- benchmark | ||
|
||
default: | ||
retry: | ||
max: 2 | ||
when: | ||
- runner_system_failure | ||
- unknown_failure | ||
- api_failure | ||
|
||
.rust-info-script: &rust-info-script | ||
- rustup show | ||
- cargo --version | ||
- rustup +nightly show | ||
- cargo +nightly --version | ||
- cargo spellcheck --version | ||
- bash --version | ||
- sccache -s | ||
|
||
.kubernetes-env: &kubernetes-env | ||
image: "paritytech/ci-linux:production" | ||
tags: | ||
- kubernetes-parity-build | ||
|
||
.docker-env: &docker-env | ||
image: "paritytech/ci-linux:production" | ||
before_script: | ||
- *rust-info-script | ||
interruptible: true | ||
tags: | ||
- linux-docker | ||
|
||
# benchmark | ||
criterion-benchmark: | ||
stage: benchmark | ||
rules: | ||
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs | ||
<<: *docker-env | ||
script: | ||
- git fetch | ||
- git submodule update --init --recursive | ||
- git checkout master | ||
# on master | ||
- cargo bench --bench benches -- --noplot --save-baseline master | tee bench-report-master.txt | ||
# on PR | ||
- git checkout $CI_COMMIT_SHA | ||
- cargo bench --bench benches -- --noplot --baseline master | tee bench-report-pr.txt | ||
- bash ./scripts/ci/benchmarks-report.sh bench-report-master.txt bench-report-pr.txt |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/bin/bash | ||
|
||
# Takes raw reports from | ||
# "cargo bench --bench benches -- --noplot --save-baseline master" output as 1st argument | ||
# "cargo bench --bench benches -- --noplot --baseline master" output as 2nd argument | ||
# Parses them to json and posts formatted results to PR on a GitHub as a comment | ||
set -eu | ||
set -o pipefail | ||
|
||
PR_COMMENTS_URL="https://api.github.com/repos/paritytech/wasmi/issues/${CI_COMMIT_BRANCH}/comments" | ||
|
||
# master report to json | ||
echo "PARSING MASTER REPORT" | ||
sed -e 's/^Found.*//g' \ | ||
-e 's/^\s\+[[:digit:]].*$//g' \ | ||
-e 's/\//_/g' \ | ||
-e 's/^[a-z0-9_]\+/"&": {/g' \ | ||
-e 's/time:\s\+\[.\{10\}/"time": "/g' \ | ||
-e 's/.\{10\}\]/"},/g' \ | ||
-e '1s/^/{\n/g' \ | ||
-e '/^$/d' \ | ||
-e 's/ */ /g' \ | ||
-e 's/^ *\(.*\) *$/\1/' $1 \ | ||
| sed -z 's/.$//' \ | ||
| sed -e '$s/.$/}/g' \ | ||
| tee target/criterion/output_master.json | ||
Comment on lines
+13
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a follow up to this PR we should try to make this part more readable. I will merge this PR and propose a follow-up PR for you. :) Is that okay with you? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree. My homegrown parsing "engine" looks ugly. And definitely can be improved. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Upd: tried to install and use
Double checked There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem with raw command line output compared to the JSON output (or genreally machine readable output) is that the former is subject to change whereas the latter is kinda guaranteed to be stable to not break dependents. Therefore as a long term non-brittle solution we really really want to read output that is intended to be machine readable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You are probably doing this in the root directory instead of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right. Now it works, at first glance json's produced by |
||
|
||
# PR report to json | ||
sed -e 's/^Found.*//g' \ | ||
-e 's/^\s\+[[:digit:]].*//g' \ | ||
-e 's/\//_/g' \ | ||
-e 's/^[a-z0-9_]\+/"&": {/g' \ | ||
-e 's/time:\s\+\[.\{10\}/"time": "/g' \ | ||
-e 's/.\{10\}\]$/",/g' \ | ||
-e 's/change:\s.\{10\}/"change":"/g' \ | ||
-e 's/\s[-+].*$/",/g' \ | ||
-e 's/\(No\|Ch\).*$/"perf_change":":white_circle:"},/' \ | ||
-e 's/Performance has regressed./"perf_change":":red_circle:"},/' \ | ||
-e 's/Performance has improved./"perf_change":":green_circle:"},/' \ | ||
-e '1s/^/{\n/g' \ | ||
-e '/^$/d' \ | ||
-e 's/ */ /g' \ | ||
-e 's/^ *\(.*\) *$/\1/' $2 \ | ||
| sed -z 's/.$//' \ | ||
| sed -e '$s/.$/}/g' \ | ||
| tee target/criterion/output_pr.json | ||
|
||
cd target/criterion | ||
|
||
# Prepare report table | ||
for d in */; do | ||
d=${d::-1} | ||
echo -n "| \`${d}\` "\ | ||
"| $(cat output_master.json | jq .${d}.time | tr -d '"') "\ | ||
"| $(cat output_pr.json | jq .${d}.time | tr -d '"') "\ | ||
"| $(cat output_pr.json | jq .${d}.perf_change | tr -d '"') "\ | ||
"$(cat output_pr.json | jq .${d}.change | tr -d '"') |\n" >> bench-final-report.txt | ||
done | ||
|
||
RESULT=$(cat bench-final-report.txt) | ||
|
||
# Check whether comment from paritytech-cicd-pr already exists | ||
EXISTING_COMMENT_URL=$(curl --silent $PR_COMMENTS_URL \ | ||
| jq -r ".[] \ | ||
| select(.user.login == \"paritytech-cicd-pr\") \ | ||
| .url" \ | ||
| head -n1) | ||
|
||
# If there is already a comment by the user `paritytech-cicd-pr` in the PR which triggered | ||
# this run, then we can just edit this comment (using `PATCH` instead of `POST`). | ||
REQUEST_TYPE="POST" | ||
if [ ! -z "$EXISTING_COMMENT_URL" ]; then | ||
REQUEST_TYPE="PATCH"; | ||
PR_COMMENTS_URL="$EXISTING_COMMENT_URL" | ||
fi | ||
|
||
echo "Comment will be posted here $PR_COMMENTS_URL" | ||
|
||
# POST/PATCH comment to the PR | ||
curl -X ${REQUEST_TYPE} ${PR_COMMENTS_URL} -v \ | ||
-H "Cookie: logged_in=no" \ | ||
-H "Authorization: token ${GITHUB_PR_TOKEN}" \ | ||
-H "Content-Type: application/json; charset=utf-8" \ | ||
-d $"{ \ | ||
\"body\": \ | ||
\"## CRITERION BENCHMARKS ## \n\n \ | ||
|BENCHMARK|MASTER|PR|Diff|\n \ | ||
|---|---|---|---|\n \ | ||
${RESULT}\n\n \ | ||
[Link to pipeline](${CI_JOB_URL}) \" \ | ||
}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It's just debug info. Will remove later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this line for merge