Skip to content

feat(sql): Speed up LatestForecast, enable pg_cron #172

feat(sql): Speed up LatestForecast, enable pg_cron

feat(sql): Speed up LatestForecast, enable pg_cron #172

Workflow file for this run

# Workflow to run benchmarking.
# * Runs on new semantic tags, pushes to main, and pull requests to main.
name: Benchmark
on:
push:
tags: ['v*']
branches: ['main']
paths-ignore: ['README.md', 'examples/**', '.github/workflows/test.yml', '.github/workflows/build.yml']
pull_request:
branches: ['main']
paths-ignore: ['README.md', 'examples/**', '.github/workflows/test.yml', '.github/workflows/build.yml']
env:
PROTOC_VERSION: '3.15.8'
jobs:
bench:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- name: Get go paths
id: gopaths
run: echo "path=$(go env GOPATH)" >> "$GITHUB_OUTPUT"
- name: Restore gobin cache
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
${{ steps.gopaths.outputs.path }}/bin
${{ steps.gopaths.outputs.path }}/include
key: ${{ runner.os }}-gobin-${{ hashfiles('Makefile') }}
- name: Generate code
run: make gen
- name: Get benchmark filename for base branch
id: base-benchfile
if: github.event_name == 'pull_request'
run: |
BASE_BENCHFILE="${{ github.event.pull_request.base.ref }}"
echo "name=bench-${BASE_BENCHFILE////-}.txt" >> "$GITHUB_OUTPUT"
- name: Get benchmark filename for head branch
id: head-benchfile
run: |
HEAD_BENCHFILE="${{ github.head_ref || github.ref_name }}"
echo "name=bench-${HEAD_BENCHFILE////-}.txt" >> "$GITHUB_OUTPUT"
- name: Restore PR base branch benchmarks
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
id: cache-base-bench
if: github.event_name == 'pull_request'
with:
path: ${{ steps.base-benchfile.outputs.name }}
key: ${{ runner.os }}-bench-${{ steps.base-benchfile.outputs.name }}
- name: Run benchmarks
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
make bench > ${{ steps.head-benchfile.outputs.name }}
cat ${{ steps.head-benchfile.outputs.name }}
- name: Delete old benchmark caches
if: github.event_name != 'pull_request'
continue-on-error: true
run: |
gh cache delete ${{ runner.os }}-bench-main.txt
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cache benchmark results
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
if: github.event_name != 'pull_request'
with:
path: ${{ steps.head-benchfile.outputs.name }}
key: ${{ runner.os }}-bench-${{ steps.head-benchfile.outputs.name }}
- name: Compare benchmarks
id: bench-diff
if: github.event_name == 'pull_request' && steps.cache-base-bench.outputs.cache-hit == 'true'
run: |
go run golang.org/x/perf/cmd/benchstat@latest ${{ steps.base-benchfile.outputs.name }} ${{ steps.head-benchfile.outputs.name }} > bench-diff.txt
cat bench-diff.txt
echo 'summary<<EOF' >> $GITHUB_OUTPUT
cat bench-diff.txt >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Write results to markdown file
env:
FILENAME: ${{ steps.head-benchfile.outputs.name }}
run: |
{
echo "### Benchmark Results"
echo ""
echo "<details><summary>Benchmark results</summary>"
echo ""
echo '```'
cat "$FILENAME"
echo '```'
echo "</details>"
} > bench-comment.md
- name: Write benchmark diff to markdown file
if: github.event_name == 'pull_request' && steps.cache-base-bench.outputs.cache-hit == 'true'
run: |
BENCH_DIFF="${{ steps.bench-diff.outputs.summary }}"
cat <<EOF >> bench-comment.md
<details><summary>Benchmark vs base branch</summary>
\`\`\`
$BENCH_DIFF
\`\`\`
</details>
EOF
- name: Upload benchmark results
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: bench-comment-${{ github.event.number }}
path: bench-comment.md
if-no-files-found: error
retention-days: 1
overwrite: true
- name: Save gobin cache
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
${{ steps.gopaths.outputs.path }}/bin
${{ steps.gopaths.outputs.path }}/include
key: ${{ runner.os }}-gobin-${{ hashfiles('Makefile') }}