Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3779: [ADP-2811] Create `api` benchmark r=HeinrichApfelmus a=HeinrichApfelmus ### Overview This pull request adds a benchmark `api` and includes it in the `nightly` queue. The idea of this benchmark is to load wallet states from a directory of database file and measure the running times of various API calls. These wallets are not synchronized to the chain. Here, "API" refers to the exports of `Cardano.Wallet`, which often mirror the HTTP endpoints, but do not coincide with it. The `restore` benchmark uses a similar approach. ### Comments * Eventually, we may want to remove the timing measurements of the API calls from the `restore` benchmark, and replicate them in this benchmark instead. 🤔 The advantage of the `api` benchmark is that it has a much faster turnaround time and can be used for wallet UTxO distributions that look different from those generated by the `restore` benchmark ones. n this way, it can be used to debug performance issues. ### Issue number ADP-2811 Co-authored-by: Heinrich Apfelmus <heinrich.apfelmus@iohk.io>
- Loading branch information
Showing
15 changed files
with
952 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://stackoverflow.com/a/63751678>. | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.