|
| 1 | +name: Refresh PGO profile |
| 2 | +# Regenerates caddy/frankenphp/default.pgo by hammering frankenphp with wrk in |
| 3 | +# both regular and worker mode (see build-pgo.sh) and opens a PR with the |
| 4 | +# new merged profile. Direct `go build` and the Dockerfile auto-detect it; |
| 5 | +# xcaddy users still need an explicit --pgo flag. |
| 6 | +concurrency: |
| 7 | + cancel-in-progress: false |
| 8 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + paths: |
| 14 | + - "**/*.go" |
| 15 | + - "frankenphp.c" |
| 16 | + - "profiles/**" |
| 17 | + - ".github/workflows/pgo-profile.yaml" |
| 18 | + workflow_dispatch: |
| 19 | + inputs: |
| 20 | + bench_seconds: |
| 21 | + description: "Seconds to run wrk per script" |
| 22 | + default: "30" |
| 23 | + required: false |
| 24 | +permissions: |
| 25 | + contents: write |
| 26 | + pull-requests: write |
| 27 | +jobs: |
| 28 | + refresh: |
| 29 | + environment: pgo |
| 30 | + name: Generate PGO profile |
| 31 | + runs-on: ubuntu-latest |
| 32 | + env: |
| 33 | + GOTOOLCHAIN: local |
| 34 | + GOFLAGS: "-tags=nobadger,nomysql,nopgx" |
| 35 | + LIBRARY_PATH: ${{ github.workspace }}/watcher/target/lib |
| 36 | + BENCH_SEC: ${{ github.event.inputs.bench_seconds || '30' }} |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v6 |
| 39 | + with: |
| 40 | + fetch-depth: 0 |
| 41 | + # zizmor: ignore[artipacked] |
| 42 | + # persist-credentials is intentionally left enabled because this |
| 43 | + # workflow needs to push a branch via git push (mirrors translate.yaml). |
| 44 | + - uses: actions/setup-go@v6 |
| 45 | + with: |
| 46 | + go-version: "1.26" |
| 47 | + cache-dependency-path: | |
| 48 | + go.sum |
| 49 | + caddy/go.sum |
| 50 | + - uses: shivammathur/setup-php@v2 |
| 51 | + with: |
| 52 | + php-version: "8.5" |
| 53 | + ini-file: development |
| 54 | + coverage: none |
| 55 | + tools: none |
| 56 | + env: |
| 57 | + phpts: ts |
| 58 | + debug: true |
| 59 | + - name: Install e-dant/watcher |
| 60 | + uses: ./.github/actions/watcher |
| 61 | + - name: Set CGO flags |
| 62 | + run: echo "CGO_CFLAGS=-I${PWD}/watcher/target/include $(php-config --includes)" >> "${GITHUB_ENV}" |
| 63 | + - name: Install wrk |
| 64 | + run: sudo apt-get update && sudo apt-get install -y wrk |
| 65 | + - name: Generate profile |
| 66 | + run: ./profiles/build-pgo.sh |
| 67 | + - name: Show pprof summary |
| 68 | + run: | |
| 69 | + go install github.com/google/pprof@latest |
| 70 | + "$(go env GOPATH)/bin/pprof" -top -cum -nodecount=25 caddy/frankenphp/default.pgo || true |
| 71 | + - name: Open PR with refreshed profile |
| 72 | + env: |
| 73 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + ACTOR: ${{ github.actor }} |
| 75 | + ACTOR_ID: ${{ github.actor_id }} |
| 76 | + RUN_ID: ${{ github.run_id }} |
| 77 | + SOURCE_SHA: ${{ github.sha }} |
| 78 | + BENCH_SEC: ${{ env.BENCH_SEC }} |
| 79 | + run: | |
| 80 | + git config user.name "github-actions[bot]" |
| 81 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 82 | + BRANCH="pgo/refresh-$RUN_ID" |
| 83 | + git checkout -b "$BRANCH" |
| 84 | + git add caddy/frankenphp/default.pgo |
| 85 | + git diff --cached --quiet && exit 0 |
| 86 | + git commit -m "perf(pgo): refresh PGO profile" --author="$ACTOR <$ACTOR_ID+$ACTOR@users.noreply.github.com>" |
| 87 | + git push origin "$BRANCH" |
| 88 | + gh pr create \ |
| 89 | + --title "perf(pgo): refresh PGO profile" \ |
| 90 | + --body "Automated refresh of \`caddy/frankenphp/default.pgo\` from \`$SOURCE_SHA\`, generated with \`BENCH_SEC=$BENCH_SEC\` across every script in \`profiles/app/\` in both regular and worker mode." \ |
| 91 | + --label "perf" \ |
| 92 | + --label "bot" |
0 commit comments