Skip to content

Commit

Permalink
Move benchmarks to cicero
Browse files Browse the repository at this point in the history
  • Loading branch information
zeme-wana committed Nov 30, 2022
1 parent 4e327d5 commit ad517bb
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -118,3 +118,4 @@ plutus-pab/test-node/alonzo-purple/db
*.timelog
*.stacks
.nvimrc
out
1 change: 1 addition & 0 deletions nix/cells/cloud/actions.nix
Expand Up @@ -49,6 +49,7 @@
// There is no documentation for this yet. Ask SRE if you have trouble changing this.
let github = {
#target: "zeme-iohk/benchmarking"
#input: "GitHub event"
#repo: "input-output-hk/plutus"
}
Expand Down
9 changes: 9 additions & 0 deletions nix/cells/cloud/packages.nix
@@ -0,0 +1,9 @@
# TODO(std) delete this file before merging
{ cell, inputs }:
{
test-run-plutus-benchmark = cell.library.plutus-benchmark-runner {
PR_NUMBER = "4956";
PR_COMMIT_SHA = "c6c6cd04c0d3ea6e6d041ff7f75ab9b92467dbef";
BENCHMARK_NAME = "nofib";
};
}
4 changes: 4 additions & 0 deletions nix/cells/cloud/packages/default.nix
@@ -0,0 +1,4 @@
{ inputs, cell }@block:
{
plutus-benchmark-runner = import ./plutus-benchmark-runner.nix block;
}
13 changes: 13 additions & 0 deletions nix/cells/cloud/packages/plutus-benchmark-runner.nix
@@ -0,0 +1,13 @@
{ cell, inputs }:

{ PR_NUMBER, PR_COMMIT_SHA, BENCHMARK_NAME }:

let
inherit (inputs.cells.plutus.library) pkgs;
in

pkgs.writeShellApplication {
name = "plutus-benchmark-runner";
runtimeInputs = [ pkgs.nix pkgs.git pkgs.jq pkgs.curl ];
text = "${./plutus-benchmark-runner.sh} ${PR_NUMBER} ${PR_COMMIT_SHA} ${BENCHMARK_NAME}";
}
Expand Up @@ -3,9 +3,6 @@
# ci-plutus-benchmark: Run benchmarks on 2 branches, compare the results and
# add a comment on the corresponding PR on GitHub.
#
# This script is supposed to be executed by https://buildkite.com/input-output-hk/plutus-benchmark
# which itself is triggered through the GitHub workflow ./.github/workflows/benchmark.yaml
#
# USAGE:
# In order to trigger benchmarking for an open PR, add `/benchmark` as a comment to
# the PR. The command will be acknowledged with a :rocket: reaction and when done a bot will
Expand All @@ -25,49 +22,51 @@

set -e

PR_NUMBER=4956
BENCHMARK_NAME=nofib
PR_NUMBER=$1
PR_COMMIT_SHA=$2
BENCHMARK_NAME=$3

if [ -z "$PR_NUMBER" ] ; then
echo "[ci-plutus-benchmark]: 'PR_NUMBER' is not set! Exiting"
exit 1
fi
if [ -z "$PR_COMMIT_SHA" ] ; then
echo "[ci-plutus-benchmark]: 'PR_COMMIT_SHA' is not set! Exiting"
exit 1
fi
if [ -z "$BENCHMARK_NAME" ] ; then
echo "[ci-plutus-benchmark]: 'BENCHMARK_NAME' is not set! Exiting"
exit 1
fi

PR_BRANCH_REF=$(git rev-parse --short $PR_COMMIT_SHA)

echo "[ci-plutus-benchmark]: Cloning the plutus repository"
git init
git remote add origin git@github.com:input-output-hk/plutus.git
git fetch --depth 1 origin $PR_COMMIT_SHA
git checkout $PR_COMMIT_SHA

echo "[ci-plutus-benchmark]: Processing benchmark comparison for benchmark '$BENCHMARK_NAME' on PR $PR_NUMBER"
PR_BRANCH_REF=$(git rev-parse --short HEAD)

echo "[ci-plutus-benchmark]: Updating cabal database ..."
cabal update

echo "[ci-plutus-benchmark]: Clearing caches with cabal clean ..."
cabal clean
nix develop --command cabal update

echo "[ci-plutus-benchmark]: Running benchmark for PR branch ..."
# nix-shell --run "cabal bench $BENCHMARK_NAME >bench-PR.log 2>&1"
# TODO(std) check that this works
# nix develop --command "cabal bench $BENCHMARK_NAME >bench-PR.log 2>&1"
cabal bench $BENCHMARK_NAME >bench-PR.log 2>&1
nix develop --command cabal bench $BENCHMARK_NAME >bench-PR.log 2>&1

echo "[ci-plutus-benchmark]: fetching origin ..."
git fetch origin
git fetch --depth 1 origin master

echo "[ci-plutus-benchmark]: Switching branches ..."
git checkout "$(git merge-base HEAD origin/master)"
BASE_BRANCH_REF=$(git rev-parse --short HEAD)


echo "[ci-plutus-benchmark]: Clearing caches with cabal clean ..."
cabal clean
nix develop --command cabal clean

echo "[ci-plutus-benchmark]: Running benchmark for base branch ..."
# nix-shell --run "cabal bench $BENCHMARK_NAME >bench-base.log 2>&1"
# TODO(std) check that this works
# nix develop --command "cabal bench $BENCHMARK_NAME >bench-base.log 2>&1"
cabal bench $BENCHMARK_NAME >bench-base.log 2>&1
nix develop --command cabal bench $BENCHMARK_NAME >bench-base.log 2>&1

git checkout "$PR_BRANCH_REF" # .. so we use the most recent version of the comparison script

Expand All @@ -86,10 +85,8 @@ EOF
echo -e "</details>"
} > bench-compare-result.log

# nix-shell -p jq --run "jq -Rs '.' bench-compare-result.log >bench-compare.json"
# TODO(std) check that this works
# nix develop --command "jq -Rs '.' bench-compare-result.log >bench-compare.json"
jq -Rs '.' bench-compare-result.log >bench-compare.json

echo "[ci-plutus-benchmark]: Posting results to GitHub ..."
# TODO(std) we'll need to change this
curl -s -H "Authorization: token $(</run/keys/buildkite-github-token)" -X POST -d "{\"body\": $(<bench-compare.json)}" "https://api.github.com/repos/input-output-hk/plutus/issues/${PR_NUMBER}/comments"
23 changes: 11 additions & 12 deletions nix/cells/cloud/pipelines.nix
Expand Up @@ -56,19 +56,18 @@ let

ciTasksSeq = taskSequence "ci/" ciTasks (__attrNames ciTasks);

benchmark = { config, ... }: {
preset = {
nix.enable = true;
benchmark = { config, ... }:
let
runner = cell.library.plutus-benchmark-runner {
PR_NUMBER = "4956";
PR_COMMIT_SHA = "c6c6cd04c0d3ea6e6d041ff7f75ab9b92467dbef";
BENCHMARK_NAME = "nofib";
};
in
{
preset.nix.enable = true;
command.text = "${runner}/bin/plutus-benchmark-runner";
};
command.runtimeInputs = [
];
command.text = ''
echo TESTSTSTSTSSTSSTSTSTS
ls -la
pwd
nix develop --command "bash ${inputs.self + /scripts/ci-plutus-benchmark.sh}"
'';
};

in
if system == "x86_64-linux" then
Expand Down

0 comments on commit ad517bb

Please sign in to comment.