ci: separate bench tests (#31763)

* ci: separate bench tests

* use readable names
This commit is contained in:
Yihau Chen 2023-05-25 21:39:17 +08:00 committed by GitHub
parent 0e93090520
commit 8cb30d0693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 139 additions and 2 deletions

View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -e
here=$(dirname "$0")
# shellcheck source=.buildkite/scripts/common.sh
source "$here"/common.sh
agent="${1-solana}"
build_steps() {
cat <<EOF
{
"name": "$1",
"command": "$2",
"timeout_in_minutes": 30,
"agent": "$agent",
"retry": 3
}
EOF
}
# shellcheck disable=SC2016
group "bench" \
"$(build_steps "bench-part-1" "ci/bench/part1.sh")" \
"$(build_steps "bench-part-2" "ci/bench/part2.sh")"

View File

@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -e
here=$(dirname "$0")
# shellcheck source=.buildkite/scripts/func-assert-eq.sh
source "$here"/func-assert-eq.sh
want=$(
cat <<'EOF'
- group: "bench"
steps:
- name: "bench-part-1"
command: "ci/bench/part1.sh"
timeout_in_minutes: 30
agents:
queue: "solana"
retry:
automatic:
- limit: 3
- name: "bench-part-2"
command: "ci/bench/part2.sh"
timeout_in_minutes: 30
agents:
queue: "solana"
retry:
automatic:
- limit: 3
EOF
)
# shellcheck source=.buildkite/scripts/build-bench.sh
got=$(source "$here"/build-bench.sh)
assert_eq "test build bench steps" "$want" "$got"

28
ci/bench/common.sh Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
here="$(dirname "$0")"
#shellcheck source=ci/_
source "$here"/../_
#shellcheck source=ci/upload-ci-artifact.sh
source "$here"/../upload-ci-artifact.sh
#shellcheck source=ci/rust-version.sh
source "$here"/../rust-version.sh nightly
export RUST_BACKTRACE=1
export UPLOAD_METRICS=""
export TARGET_BRANCH=$CI_BRANCH
if [[ -z $CI_BRANCH ]] || [[ -n $CI_PULL_REQUEST ]]; then
TARGET_BRANCH=$EDGE_CHANNEL
else
UPLOAD_METRICS="upload"
fi
export BENCH_FILE=bench_output.log
export BENCH_ARTIFACT=current_bench_results.log
# Ensure all dependencies are built
_ cargo +"$rust_nightly" build --release

19
ci/bench/part1.sh Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -eo pipefail
here="$(dirname "$0")"
#shellcheck source=ci/bench/common.sh
source "$here"/common.sh
# Run core benches
_ cargo +"$rust_nightly" bench --manifest-path core/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
# Run gossip benches
_ cargo +"$rust_nightly" bench --manifest-path gossip/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
# Run poh benches
_ cargo +"$rust_nightly" bench --manifest-path poh/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"

29
ci/bench/part2.sh Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -eo pipefail
here="$(dirname "$0")"
#shellcheck source=ci/bench/common.sh
source "$here"/common.sh
# Run sdk benches
_ cargo +"$rust_nightly" bench --manifest-path sdk/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
# Run runtime benches
_ cargo +"$rust_nightly" bench --manifest-path runtime/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
(
# solana-keygen required when building C programs
_ cargo build --manifest-path=keygen/Cargo.toml
export PATH="$PWD/target/debug":$PATH
# Run sbf benches
_ cargo +"$rust_nightly" bench --manifest-path programs/sbf/Cargo.toml ${V:+--verbose} --features=sbf_c \
-- -Z unstable-options --format=json --nocapture | tee -a "$BENCH_FILE"
)
# Run banking/accounts bench. Doesn't require nightly, but use since it is already built.
_ cargo +"$rust_nightly" run --release --manifest-path banking-bench/Cargo.toml ${V:+--verbose} | tee -a "$BENCH_FILE"
_ cargo +"$rust_nightly" run --release --manifest-path accounts-bench/Cargo.toml ${V:+--verbose} -- --num_accounts 10000 --num_slots 4 | tee -a "$BENCH_FILE"

View File

@ -264,7 +264,7 @@ EOF
^ci/test-coverage.sh \
^ci/test-bench.sh \
; then
command_step bench "ci/test-bench.sh" 40
.buildkite/scripts/build-bench.sh >> "$output_file"
else
annotate --style info --context test-bench \
"Bench skipped as no .rs files were modified"

View File

@ -250,7 +250,7 @@ EOF
^ci/test-coverage.sh \
^ci/test-bench.sh \
; then
command_step bench "ci/test-bench.sh" 40
.buildkite/scripts/build-bench.sh sol-private >> "$output_file"
else
annotate --style info --context test-bench \
"Bench skipped as no .rs files were modified"