2023-05-01 17:15:42 +00:00
|
|
|
name: Benchmark
|
|
|
|
|
2023-05-30 18:44:47 +00:00
|
|
|
on:
|
2023-08-03 09:55:06 +00:00
|
|
|
workflow_dispatch:
|
2023-05-30 18:44:47 +00:00
|
|
|
push:
|
2023-08-03 09:55:06 +00:00
|
|
|
branches:
|
|
|
|
- main
|
2023-05-01 17:15:42 +00:00
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
2023-11-18 13:55:01 +00:00
|
|
|
#
|
|
|
|
# The bench jobs will:
|
|
|
|
# 1. Run the benchmark and save the results as a baseline named "current"
|
|
|
|
# 2. Download the following baselines from S3
|
|
|
|
# - The latest baseline from the main branch
|
|
|
|
# - The latest baseline from the current branch
|
|
|
|
# 3. Compare the current benchmark results vs the baselines
|
|
|
|
# 4. Save the comparison as an artifact
|
|
|
|
# 5. Upload the current benchmark results as a new baseline and update the latest baseline for the current branch
|
|
|
|
#
|
|
|
|
|
2023-05-01 17:15:42 +00:00
|
|
|
jobs:
|
2023-11-18 13:55:01 +00:00
|
|
|
common:
|
|
|
|
name: Bench common
|
|
|
|
runs-on:
|
|
|
|
- self-hosted
|
|
|
|
- benches
|
|
|
|
timeout-minutes: 60
|
2023-05-01 17:15:42 +00:00
|
|
|
steps:
|
|
|
|
- name: Install stable toolchain
|
2023-09-06 13:51:33 +00:00
|
|
|
uses: dtolnay/rust-toolchain@stable
|
2023-08-24 16:33:57 +00:00
|
|
|
with:
|
2024-01-11 21:29:58 +00:00
|
|
|
toolchain: 1.75.0
|
2023-05-01 17:15:42 +00:00
|
|
|
|
2023-11-18 13:55:01 +00:00
|
|
|
- name: Configure AWS credentials
|
|
|
|
uses: aws-actions/configure-aws-credentials@v4
|
|
|
|
with:
|
|
|
|
aws-region: us-east-1
|
|
|
|
|
2023-05-01 17:15:42 +00:00
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
sudo apt-get -qq -y update
|
2023-11-18 13:55:01 +00:00
|
|
|
sudo apt-get -qq -y install clang curl
|
2023-11-20 11:49:35 +00:00
|
|
|
cargo install --quiet --locked critcmp cargo-make
|
2023-05-01 17:15:42 +00:00
|
|
|
|
2023-11-18 13:55:01 +00:00
|
|
|
- name: Checkout changes
|
2023-12-05 11:52:09 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-11-18 13:55:01 +00:00
|
|
|
|
|
|
|
- name: Run benchmark
|
|
|
|
run: |
|
|
|
|
cargo make ci-bench -- --save-baseline current
|
|
|
|
|
|
|
|
- name: Copy results from AWS S3 bucket
|
|
|
|
run: |
|
|
|
|
BRANCH_NAME=$(echo ${{ github.head_ref || github.ref_name }} | sed 's/[^a-zA-Z0-9]/-/g')
|
|
|
|
|
|
|
|
aws s3 sync s3://${{ secrets.AWS_S3_GITHUB_ACTIONS_BUCKET_NAME }}/bench-results/${{ github.job }}/main/latest bench-results-main || true
|
|
|
|
aws s3 sync s3://${{ secrets.AWS_S3_GITHUB_ACTIONS_BUCKET_NAME }}/bench-results/${{ github.job }}/$BRANCH_NAME/latest bench-results-previous || true
|
|
|
|
|
|
|
|
- name: Compare current benchmark results vs baseline
|
|
|
|
run: |
|
|
|
|
mkdir -p bench-results
|
|
|
|
critcmp current bench-results-main/${{ matrix.target }}.json bench-results-previous/${{ matrix.target }}.json | tee bench-results/${{ github.job }}-comparison.txt
|
|
|
|
|
|
|
|
# Create a summary of the comparison
|
|
|
|
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
|
|
cat bench-results/${{ github.job }}-comparison.txt >> $GITHUB_STEP_SUMMARY
|
|
|
|
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
|
|
|
|
|
|
- name: Save results as artifact
|
2024-03-18 09:29:19 +00:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-05-01 17:15:42 +00:00
|
|
|
with:
|
2023-11-18 13:55:01 +00:00
|
|
|
name: ${{ github.job }}-comparison.txt
|
|
|
|
path: bench-results/${{ github.job }}-comparison.txt
|
2023-05-01 17:15:42 +00:00
|
|
|
|
2023-11-18 13:55:01 +00:00
|
|
|
- name: Copy results to AWS S3 bucket
|
|
|
|
run: |
|
|
|
|
BRANCH_NAME=$(echo ${{ github.head_ref || github.ref_name }} | sed 's/[^a-zA-Z0-9]/-/g')
|
2023-05-01 17:15:42 +00:00
|
|
|
|
2023-11-18 13:55:01 +00:00
|
|
|
cargo make ci-bench -- --load-baseline current --save-baseline previous
|
|
|
|
critcmp --export previous > bench-results/${{ matrix.target }}.json
|
2023-05-02 08:28:36 +00:00
|
|
|
|
2023-11-18 13:55:01 +00:00
|
|
|
aws s3 sync bench-results s3://${{ secrets.AWS_S3_GITHUB_ACTIONS_BUCKET_NAME }}/bench-results/${{ github.job }}/$BRANCH_NAME/${{ github.run_id }}
|
|
|
|
aws s3 sync bench-results s3://${{ secrets.AWS_S3_GITHUB_ACTIONS_BUCKET_NAME }}/bench-results/${{ github.job }}/$BRANCH_NAME/latest
|
|
|
|
|
|
|
|
engines:
|
|
|
|
name: Benchmark engines
|
|
|
|
runs-on:
|
|
|
|
- self-hosted
|
|
|
|
- benches
|
|
|
|
timeout-minutes: 60
|
|
|
|
permissions:
|
|
|
|
id-token: write
|
|
|
|
contents: read
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- target: "lib-mem"
|
|
|
|
features: "kv-mem"
|
|
|
|
- target: "lib-rocksdb"
|
|
|
|
features: "kv-rocksdb"
|
|
|
|
- target: "lib-fdb"
|
|
|
|
features: "kv-fdb-7_1"
|
|
|
|
- target: "sdk-mem"
|
|
|
|
features: "kv-mem"
|
|
|
|
- target: "sdk-rocksdb"
|
|
|
|
features: "kv-rocksdb"
|
|
|
|
- target: "sdk-fdb"
|
|
|
|
features: "kv-fdb-7_1"
|
|
|
|
# This one fails because the server consumes too much memory and the kernel kills it. I tried with instances up to 16GB of RAM.
|
|
|
|
# - target: "sdk-ws"
|
|
|
|
# features: "protocol-ws"
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2023-12-05 11:52:09 +00:00
|
|
|
uses: actions/checkout@v4
|
2023-05-01 17:15:42 +00:00
|
|
|
|
2023-11-18 13:55:01 +00:00
|
|
|
- name: Install stable toolchain
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
with:
|
2024-01-11 21:29:58 +00:00
|
|
|
toolchain: 1.75.0
|
2023-11-18 13:55:01 +00:00
|
|
|
|
|
|
|
- name: Setup cache
|
|
|
|
uses: Swatinem/rust-cache@v2
|
|
|
|
with:
|
|
|
|
save-if: ${{ github.ref == 'refs/heads/main' }}
|
|
|
|
|
|
|
|
- name: Configure AWS credentials
|
|
|
|
uses: aws-actions/configure-aws-credentials@v4
|
|
|
|
with:
|
|
|
|
aws-region: us-east-1
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
sudo apt-get -qq -y update
|
|
|
|
sudo apt-get -qq -y install clang curl
|
2023-11-20 11:49:35 +00:00
|
|
|
cargo install --quiet --locked critcmp cargo-make
|
2023-11-18 13:55:01 +00:00
|
|
|
|
|
|
|
# Install FoundationDB if needed
|
|
|
|
- name: Setup FoundationDB
|
|
|
|
uses: foundationdb-rs/foundationdb-actions-install@v2.1.0
|
|
|
|
if: ${{ matrix.target == 'lib-fdb' || matrix.target == 'sdk-fdb' }}
|
|
|
|
with:
|
|
|
|
version: "7.1.30"
|
|
|
|
|
|
|
|
# Run SurrealDB in the background if needed
|
|
|
|
- name: Build and start SurrealDB
|
|
|
|
if: ${{ matrix.target == 'sdk-ws' }}
|
|
|
|
run: |
|
|
|
|
cargo make build
|
|
|
|
|
|
|
|
# Kill any potential previous instance of the server. The runner may be reused.
|
|
|
|
pkill -9 surreal || true
|
|
|
|
./target/release/surreal start 2>&1 >surrealdb.log &
|
|
|
|
|
|
|
|
set +e
|
|
|
|
echo "Waiting for surreal to be ready..."
|
|
|
|
tries=0
|
|
|
|
while [[ $tries < 5 ]]; do
|
|
|
|
./target/release/surreal is-ready 2>/dev/null && echo "Ready!" && exit 0 || sleep 1
|
|
|
|
tries=$((tries + 1))
|
|
|
|
done
|
2023-05-01 17:15:42 +00:00
|
|
|
|
2023-11-18 13:55:01 +00:00
|
|
|
echo "#####"
|
|
|
|
echo "SurrealDB server failed to start!"
|
|
|
|
echo "#####"
|
|
|
|
cat surrealdb.log
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
- name: Run benchmark
|
|
|
|
env:
|
|
|
|
BENCH_FEATURES: "${{ matrix.features }}"
|
|
|
|
BENCH_DURATION: 60
|
|
|
|
BENCH_WORKER_THREADS: 2
|
|
|
|
run: |
|
|
|
|
cargo make bench-${{ matrix.target }} -- --save-baseline current
|
|
|
|
|
|
|
|
# Kill surreal server if it's running
|
|
|
|
pkill -9 surreal || true
|
|
|
|
|
|
|
|
- name: Copy results from AWS S3 bucket
|
|
|
|
run: |
|
|
|
|
BRANCH_NAME=$(echo ${{ github.head_ref || github.ref_name }} | sed 's/[^a-zA-Z0-9]/-/g')
|
|
|
|
|
|
|
|
aws s3 sync s3://${{ secrets.AWS_S3_GITHUB_ACTIONS_BUCKET_NAME }}/bench-results/${{ github.job }}/main/latest bench-results-main || true
|
|
|
|
aws s3 sync s3://${{ secrets.AWS_S3_GITHUB_ACTIONS_BUCKET_NAME }}/bench-results/${{ github.job }}/$BRANCH_NAME/latest bench-results-previous || true
|
|
|
|
|
|
|
|
- name: Compare current benchmark results vs baseline
|
|
|
|
run: |
|
|
|
|
mkdir -p bench-results
|
|
|
|
critcmp current bench-results-main/${{ matrix.target }}.json bench-results-previous/${{ matrix.target }}.json | tee bench-results/${{ matrix.target }}-comparison.txt
|
|
|
|
|
|
|
|
# Create a summary of the comparison
|
|
|
|
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
|
|
cat bench-results/${{ matrix.target }}-comparison.txt >> $GITHUB_STEP_SUMMARY
|
|
|
|
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
2023-05-01 17:15:42 +00:00
|
|
|
|
|
|
|
- name: Save results as artifact
|
2024-03-18 09:29:19 +00:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-05-01 17:15:42 +00:00
|
|
|
with:
|
2023-11-18 13:55:01 +00:00
|
|
|
name: ${{ matrix.target }}-comparison.txt
|
|
|
|
path: bench-results/${{ matrix.target }}-comparison.txt
|
|
|
|
|
|
|
|
- name: Copy results to AWS S3 bucket
|
|
|
|
env:
|
|
|
|
BENCH_FEATURES: "${{ matrix.features }}"
|
|
|
|
run: |
|
|
|
|
BRANCH_NAME=$(echo ${{ github.head_ref || github.ref_name }} | sed 's/[^a-zA-Z0-9]/-/g')
|
|
|
|
|
|
|
|
cargo make bench-${{ matrix.target }} -- --load-baseline current --save-baseline previous
|
|
|
|
critcmp --export previous > bench-results/${{ matrix.target }}.json
|
|
|
|
|
|
|
|
aws s3 sync bench-results s3://${{ secrets.AWS_S3_GITHUB_ACTIONS_BUCKET_NAME }}/bench-results/${{ github.job }}/$BRANCH_NAME/${{ github.run_id }}
|
|
|
|
aws s3 sync bench-results s3://${{ secrets.AWS_S3_GITHUB_ACTIONS_BUCKET_NAME }}/bench-results/${{ github.job }}/$BRANCH_NAME/latest
|