From 1ce391d0a44639a0e8d5b22252e87b699d05a658 Mon Sep 17 00:00:00 2001 From: Heinrich Apfelmus Date: Wed, 8 Mar 2023 17:45:23 +0100 Subject: [PATCH] Add api benchmark to nightly.yml --- .buildkite/bench-api.sh | 65 +++++++++++++++++++++++++++++++++++++++++ .buildkite/nightly.yml | 8 +++++ 2 files changed, 73 insertions(+) create mode 100755 .buildkite/bench-api.sh diff --git a/.buildkite/bench-api.sh b/.buildkite/bench-api.sh new file mode 100755 index 00000000000..4f215795140 --- /dev/null +++ b/.buildkite/bench-api.sh @@ -0,0 +1,65 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i bash -p nix coreutils gnugrep gawk buildkite-agent + +set -euo pipefail + +# C.UTF-8 = UTF-8 based locale that is not associated with a natural language. +# This seems necessary so that programs compiled with GHC don't choke, +# see also . +export LANG=C.UTF-8 + +if [ -n "${SCRATCH_DIR:-}" ]; then + mkdir -pv "$SCRATCH_DIR" + export TMPDIR="$SCRATCH_DIR/tmp" + mkdir -pv "$TMPDIR" +fi + +bench=api +log=api.log +results=api.txt +total_time=api-time.txt + +echo "--- Build" + +nix build .#ci.benchmarks.api -o bench-api +bench="./bench-api/bin/api lib/wallet/test/data/api-bench" + +echo "--- Run benchmark" + +$bench +RTS -N2 -qg -A1m -I0 -T -M16G -RTS 2>&1 | tee $log +# Reminder on GHC RTS options: +# -N ⟨x⟩ +# Use ⟨x⟩ simultaneous threads when running the program. +# -qg ⟨gen⟩ +# Use parallel GC in generation ⟨gen⟩ and higher. +# Omitting ⟨gen⟩ turns off the parallel GC completely, +# reverting to sequential GC. +# -A allocation area size used by the garbage collector +# -I0 disables the idle GC. +# -T produce runtime-system statistics, such as +# the amount of time spent executing the program +# and in the garbage collector. +# -T collects the data, but produces no output. +# -M ⟨size⟩ +# Set the maximum heap size to ⟨size⟩ bytes. +# -h Generates a basic heap profile, in the file prog.hp. + +echo "--- Results" + +grep -v INFO $log | awk '/All results/,EOF { print $0 }' >$results +cat $results + +if [ -n "${BUILDKITE:-}" ]; then + echo "--- Upload" + buildkite-agent artifact upload $results + + for file in *.json; do + buildkite-agent artifact upload $file + done +fi + +if [ -z "$(cat $results)" ]; then + echo "+++ Bad news" + echo "FAILED - Missing results" >/dev/stderr + exit 1 +fi diff --git a/.buildkite/nightly.yml b/.buildkite/nightly.yml index 059da1efc78..70ff44fa886 100644 --- a/.buildkite/nightly.yml +++ b/.buildkite/nightly.yml @@ -36,6 +36,14 @@ steps: queue: benchmark if: 'build.env("step") == null || build.env("step") =~ /restore-mainnet/' + - label: 'API benchmark' + command: "./.buildkite/bench-api.sh" + timeout_in_minutes: 210 + agents: + system: x86_64-linux + queue: benchmark + if: 'build.env("step") == null || build.env("step") =~ /bench-api/' + - label: 'Database benchmark' command: "./.buildkite/bench-db.sh" timeout_in_minutes: 210