benchmark-systab #556
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
name: Systab Benchmarks | |
on: | |
repository_dispatch: | |
types: [ benchmark-systab ] | |
env: | |
BENCH_DIR: 'go/performance/sysbench' | |
RESULT_TABLE_NAME: 'sysbench_results' | |
DOLTHUB_DB: 'import-perf/systab-perf' | |
jobs: | |
bench: | |
name: Benchmark | |
defaults: | |
run: | |
shell: bash | |
strategy: | |
fail-fast: true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Go 1.x | |
id: go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ^1.21 | |
- name: Dolt version | |
id: version | |
run: | | |
version=${{ github.event.client_payload.version }} | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.client_payload.version }} | |
- name: install sysbench | |
run: | | |
curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh | sudo bash | |
sudo apt -y install sysbench | |
- name: Install dolt | |
working-directory: ./go | |
run: go install ./cmd/dolt | |
- name: Clone sysbench scripts | |
run: | | |
scripts=$GITHUB_WORKSPACE/scripts | |
git clone https://github.com/dolthub/systab-sysbench-scripts.git "$scripts" | |
- name: Run bench | |
id: bench | |
working-directory: go/ | |
run: | | |
out="$GITHUB_WORKSPACE/results.sql" | |
testspec="../${{ env.BENCH_DIR }}/testdata/${{ github.event.client_payload.run_file }}" | |
config="../${{ env.BENCH_DIR }}/testdata/default-config.yaml" | |
scripts="$GITHUB_WORKSPACE/scripts" | |
go run \ | |
"github.com/dolthub/dolt/${{ env.BENCH_DIR }}/cmd" \ | |
-run "$testspec" \ | |
-config "$config" \ | |
-script-dir "$scripts" \ | |
-out "$out" | |
echo "::set-output name=result_path::$out" | |
- name: Report | |
id: report | |
run: | | |
gw=$GITHUB_WORKSPACE | |
in="${{ steps.bench.outputs.result_path }}" | |
query="$(pwd)/${{ env.BENCH_DIR }}/reporting/${{ github.event.client_payload.report }}" | |
summaryq="$(pwd)/${{ env.BENCH_DIR }}/reporting/${{ github.event.client_payload.summary }}" | |
out="$gw/results.csv" | |
dolt_dir="$gw/systab-perf" | |
dolt config --global --add user.email "[email protected]" | |
dolt config --global --add user.name "systab-perf" | |
echo '${{ secrets.DOLTHUB_IMPORT_PERF_CREDS_VALUE }}' | dolt creds import | |
dolt clone ${{ env.DOLTHUB_DB }} "$dolt_dir" | |
cd "$dolt_dir" | |
branch="${{ github.event.client_payload.commit_to_branch }}" | |
# checkout branch | |
if [ -z $(dolt sql -q "select 1 from dolt_branches where name = '$branch';") ]; then | |
dolt checkout -b $branch | |
else | |
dolt checkout $branch | |
fi | |
dolt sql -q "drop table if exists sysbench_results" | |
# load results | |
dolt sql < "$in" | |
# push results to dolthub | |
dolt add sysbench_results | |
dolt commit -m "CI commit" | |
dolt push -f origin $branch | |
# generate report | |
dolt sql -r csv < "$query" > "$out" | |
cat "$out" | |
echo "::set-output name=report_path::$out" | |
avg=$(dolt sql -r csv < "$summaryq" | tail -1) | |
echo "::set-output name=avg::$avg" | |
- name: Format Results | |
id: html | |
if: ${{ github.event.client_payload.email_recipient }} != "" | |
run: | | |
gw="$GITHUB_WORKSPACE" | |
in="${{ steps.report.outputs.report_path }}" | |
out="$gw/results.html" | |
echo "<table>" > "$out" | |
print_header=true | |
while read line; do | |
if "$print_header"; then | |
echo " <tr><th>${line//,/</th><th>}</th></tr>" >> "$out" | |
print_header=false | |
continue | |
fi | |
echo " <tr><td>${line//,/</td><td>}</td></tr>" >> "$out" | |
done < "$in" | |
echo "</table>" >> "$out" | |
avg="${{ steps.report.outputs.avg }}" | |
echo "<table><tr><th>Average</th></tr><tr><td>$avg</tr></td></table>" >> "$out" | |
cat "$out" | |
echo "::set-output name=html::$(echo $out)" | |
- name: Configure AWS Credentials | |
if: ${{ github.event.client_payload.email_recipient }} != "" | |
uses: aws-actions/[email protected] | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-west-2 | |
- name: Send Email | |
uses: ./.github/actions/ses-email-action | |
if: ${{ github.event.client_payload.email_recipient }} != "" | |
with: | |
region: us-west-2 | |
toAddresses: '["${{ github.event.client_payload.email_recipient }}"]' | |
subject: 'System Table Performance Benchmarks: ${{ github.event.client_payload.version }}' | |
bodyPath: ${{ steps.html.outputs.html }} | |
template: 'SysbenchTemplate' | |
- name: Read CSV | |
if: ${{ github.event.client_payload.issue_id }} != "" | |
id: csv | |
uses: juliangruber/read-file-action@v1 | |
with: | |
path: "${{ steps.report.outputs.report_path }}" | |
- name: Create MD | |
if: ${{ github.event.client_payload.issue_id }} != "" | |
uses: petems/csv-to-md-table-action@master | |
id: md | |
with: | |
csvinput: ${{ steps.csv.outputs.content }} | |
- uses: mshick/add-pr-comment@v2 | |
if: ${{ github.event.client_payload.issue_id }} != "" | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
issue: ${{ github.event.client_payload.issue_id }} | |
message-failure: systab benchmark failed | |
message-cancelled: systab benchmark cancelled | |
allow-repeats: true | |
message: | | |
@${{ github.event.client_payload.actor }} __DOLT__ | |
${{ steps.md.outputs.markdown-table }} |