Skip to content

Commit

Permalink
Split the script to use nix shell to bring the node executable in s…
Browse files Browse the repository at this point in the history
…cope.
  • Loading branch information
paolino committed Jul 17, 2023
1 parent bf3b5de commit 8541590
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 26 deletions.
51 changes: 25 additions & 26 deletions .buildkite/bench-memory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,48 @@
#! nix-shell -i bash -p coreutils gnugrep gawk time haskellPackages.hp2pretty buildkite-agent

set -euo pipefail
echo "------------------------ Setup ------------------------------------------"
TMPDIR="${TMPDIR:-/tmp}"
export TMPDIR="/$TMPDIR/bench/memory"
mkdir -p $TMPDIR
echo "TMPDIR: $TMPDIR"

artifact_name=memory
echo "artifact_name: $artifact_name"

export TMPDIR="/$TMPDIR/bench/memory"
mkdir -p $TMPDIR
export log="$artifact_name.log"
echo "log: $log"

echo "------------------------ Build ------------------------------------------"
nix build -o bench-wallet
# nix build # packages.x86_64-linux.cardano-node -o node
echo "------------------------Build done --------------------------------------"
echo "------------------------ Run --------------------------------------------"
wallet_exe="`pwd`/bench-wallet/bin/cardano-wallet"
echo "wallet_exe: $wallet_exe"
#node_exe="`pwd`/cardano-node/bin/cardano-node"
node_exe="`which cardano-node`"
echo "node_exe: $node_exe"
node_db="`pwd`/lib/wallet-benchmarks/data/membench-snapshot.tgz"
echo "node_db: $node_db"
work_dir=`pwd`
echo "work_dir: $work_dir"
bench="cabal bench cardano-wallet-benchmarks:bench:memory \
--benchmark-option=--snapshot=$node_db \
--benchmark-option=--wallet=$wallet_exe \
--benchmark-option=--node=$node_exe \
--benchmark-option=--work-dir=$work_dir "
echo "bench: $bench"
$bench
echo "------------------------ Run done ---------------------------------------"
export error_log="$artifact_name.error.log"
echo "error_log: $error_log"

echo "------------------------ Results ----------------------------------------"
echo "------------------------ Setup done -------------------------------------"

echo "------------------------ Nix call ---------------------------------------"
nix shell \
'.#ci.benchmarks.memory' \
'.#cardano-node' \
'.#cardano-wallet' \
-c "scripts/bench-memory.sh"

echo "------------------------ Nix call done ----------------------------------"

echo "------------------------ Results ----------------------------------------"
mv cardano-wallet.hp $artifact_name.hp
hp2pretty $artifact_name.hp

if [ -n "${BUILDKITE:-}" ]; then
echo "--- Upload"
buildkite-agent artifact upload $artifact_name.svg
buildkite-agent artifact upload $log
buildkite-agent artifact upload $error_log

echo "+++ Heap profile"
printf '\033]1338;url='"artifact://$artifact_name.svg"';alt='"Heap profile"'\a\n'

fi
echo "------------------------ Results done -----------------------------------"

echo "------------------------ Cleanup ----------------------------------------"

rm -rf $TMPDIR
echo "------------------------ Cleanup done -----------------------------------"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ memory-time.txt
memory.log
memory
memory.svg
bench-restore
restore-time.txt
restore.log
22 changes: 22 additions & 0 deletions scripts/bench-memory.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#! /usr/bin/env bash
echo "------------------------ Setup nix ---------------------------------------"
wallet_exe="`which cardano-wallet`"
echo "wallet_exe: $wallet_exe"
node_exe="`which cardano-node`"
echo "node_exe: $node_exe"
node_db="`pwd`/lib/wallet-benchmarks/data/membench-snapshot.tgz"
echo "node_db: $node_db"
work_dir=`pwd`
echo "work_dir: $work_dir"
bench="memory \
--snapshot=$node_db \
--wallet=$wallet_exe \
--node=$node_exe \
--work-dir=$work_dir "
echo "bench command: $bench"
echo "------------------------ Setup nix done ---------------------------------"

echo "------------------------ Run --------------------------------------------"
echo "log: $log"
$bench 2>$error_log 1>$log
echo "------------------------ Run done ---------------------------------------"

0 comments on commit 8541590

Please sign in to comment.