Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/schedule-rust-bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ jobs:
run: |
echo -e "\e[34mRunning rust benchmarks on dedicated machine fr1-spm15!\e[0m"

CRITERION_HOME=$(mktemp -d)
trap "rm -rf $CRITERION_HOME" INT TERM EXIT

while IFS= read -r tgt; do
bazel run "$tgt"
bazel run "$tgt" -- --criterion-home "$CRITERION_HOME"
done < <(bazel query "attr(tags, 'rust_bench', ${{ matrix.target }})")

while IFS= read -r bench_dir; do
Expand All @@ -82,6 +85,6 @@ jobs:
>report.json
curl --fail --retry 2 -sS -o /dev/null -X POST -H 'Content-Type: application/json' --data @report.json \
"https://elasticsearch.testnet.dfinity.network/ci-performance-test/_doc"
done < <(find -L ./bazel-out -type d -path '*/new')
done < <(find -L "$CRITERION_HOME" -type d -path '*/new')

echo -e "\e[34mRust benchmarks on dedicated machine fr1-spm15 finished.\e[0m"
26 changes: 25 additions & 1 deletion bazel/generic_rust_bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

set -euo pipefail

# criterion supports specifying a "home" where it places its benchmark result tree.
# at the time of writing, our bazel version (.bazelversion) is outdated and sh_binary
# does not support `env_inherit` so add (or rather intercept) a new CLI argument
# `--criterion-home` which we convert into `CRITERION_HOME`, which is read by
# criterion.rs.
#
# https://github.com/criterion-rs/criterion.rs/blob/950c3b727a09d10067ea686e2ac6f1f23569168f/src/lib.rs#L142-L142

# store passthru args
args=()
while [[ $# -gt 0 ]]; do
case $1 in
--criterion-home)
shift
export CRITERION_HOME="$1"
;;
*)
# passthru
args+=("$1")
shift
;;
esac
done

# When Cargo runs benchmarks, it passes the --bench or --test command-line arguments to
# the benchmark executables. Criterion.rs looks for these arguments and tries to either
# run benchmarks or run in test mode. In particular, when you run cargo test --benches
Expand All @@ -11,7 +35,7 @@ set -euo pipefail
# present, or when --bench and --test are both present.
#
# https://bheisler.github.io/criterion.rs/book/faq.html#when-i-run-benchmark-executables-directly-without-using-cargo-they-just-print-success-why
CMD="${BAZEL_DEFS_BENCH_PREFIX}${BAZEL_DEFS_BENCH_BIN} --bench $@"
CMD="${BAZEL_DEFS_BENCH_PREFIX}${BAZEL_DEFS_BENCH_BIN} --bench ${args[@]}"

echo "running ${CMD}"
${CMD}
Loading