Skip to content

Commit

Permalink
Buildkite: Run DB bench in the nightly pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Jul 12, 2019
1 parent c23d7e6 commit 19be65c
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 21 deletions.
29 changes: 29 additions & 0 deletions .buildkite/bench-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p nix coreutils buildkite-agent

set -euo pipefail

bench_name=bench-db

rm -rf $bench_name

echo "--- Build"
nix-build -A benchmarks.cardano-wallet-core.db -o $bench_name

echo "+++ Run benchmark"

./$bench_name/cardano-wallet-core*/db --json $bench_name.json -o $bench_name.html | tee $bench_name.txt

printf 'Link to \033]1339;url=artifact://'$bench_name.html';content='"Benchmark Report"'\a\n'

echo "--- Upload report"

if [ -n "${BUILDKITE:-}" ]; then
buildkite-agent artifact upload "$bench_name.html"
buildkite-agent artifact upload "$bench_name.json"

# Requires buildkite-agent 3.x
# cat << EOF | buildkite-agent annotate --style "info"
# Read the <a href="artifact://$bench_name.html">benchmark results</a>
# EOF
fi
35 changes: 35 additions & 0 deletions .buildkite/bench-restore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p nix coreutils gnugrep gawk time haskellPackages.hp2pretty buildkite-agent

set -euo pipefail

target=http-bridge
artifact_name=restore-$target-$NETWORK
log=restore.log
results=restore-$target-$NETWORK.txt
total_time=restore-time.txt

echo "--- Build"
nix-build -A benchmarks.cardano-wallet-$target.restore -o bench-$target-restore
bench=./bench-$target-restore/bin/restore

echo "--- Run benchmarks - $target - $NETWORK"
command time -o $total_time -v $bench "$NETWORK" +RTS -N2 -qg -A1m -I0 -T -M8G -h -RTS 2>&1 | tee $log

grep -v INFO $log | awk '/All results/,EOF { print $0 }' > $results

echo "+++ Results - $target - $NETWORK"

cat $results

mv restore.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 $results

echo "+++ Heap profile"
printf '\033]1338;url='"artifact://$artifact_name.svg"';alt='"Heap profile"'\a\n'
fi
19 changes: 0 additions & 19 deletions .buildkite/benchmark.sh

This file was deleted.

10 changes: 8 additions & 2 deletions .buildkite/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@ env:
NIX_PATH: "channel:nixos-19.03"
steps:
- label: 'Restore benchmark - testnet'
command: "./.buildkite/benchmark.sh"
command: "./.buildkite/bench-restore.sh"
timeout_in_minutes: 60
agents:
system: x86_64-linux
env:
NETWORK: testnet
- label: 'Restore benchmark - mainnet'
command: "./.buildkite/benchmark.sh"
command: "./.buildkite/bench-restore.sh"
timeout_in_minutes: 90
agents:
system: x86_64-linux
env:
NETWORK: mainnet

- label: 'Database benchmark'
command: "./.buildkite/bench-db.sh"
timeout_in_minutes: 60
agents:
system: x86_64-linux
11 changes: 11 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ let
integration.build-tools = [ jormungandr ];
unit.build-tools = [ jormungandr ];
};

packages.cardano-wallet-http-bridge.components.benchmarks.restore = {
build-tools = [ pkgs.makeWrapper ];
postInstall = ''
makeWrapper \
$out/cardano-wallet-*/restore \
$out/bin/restore \
--prefix PATH : ${cardano-http-bridge}/bin
'';
};
packages.cardano-wallet-http-bridge.components.all.postInstall = pkgs.lib.mkForce "";
}

# Misc. build fixes for dependencies
Expand Down

0 comments on commit 19be65c

Please sign in to comment.