Repository navigation
ci: bencher v1, benches/perf/{lb,sharding,pooler}, detect perf regressions #1617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bce31c4
ci: bencher v1, benches/perf/{lb,sharding,pooler}, error on perf regr…
jkaczman 3cc5590
-T 30 -> 150
jkaczman 4f4ea12
-T 150 -> 90 (free tier limit)
jkaczman 2995ea7
Run all 3, in parallel, for 3 mins each.
jkaczman 4ed2b03
Only comment on regression
jkaczman 39c99e0
Update Bencher to latest; fire-and-forget repository dispatch workflow
jkaczman 8cfe197
Only comment on alert (followup). --start-point-reset
jkaczman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # NOTE!!!: This does not work with forks right now, because this needs repository secrets. | ||
| # It would be unsafe to allow them in this workflow. | ||
| # Bencher has a documented 2-step workflow on how to accomplish this. I'll follow up with that in another PR. | ||
|
|
||
| # TODO: I have some big plans for this file. Please contact @jkaczman before planning to modify with new tests. | ||
|
|
||
| name: bencher | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| IMAGE: registry.bencher.dev/pgdog:${{ github.sha }} | ||
|
|
||
| jobs: | ||
| image: | ||
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository | ||
| # This initial runner is to assemble the docker image for the Bencher runner. It doesn't run any tests itself. | ||
| # Bencher's runners do not have outside network access; requires us to have everything ready-to-go. | ||
| runs-on: blacksmith-4vcpu-ubuntu-2404 | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - name: Install CI deps | ||
| run: bash integration/ci/install-deps.sh | ||
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| prefix-key: build-v1 | ||
| - name: Build | ||
| run: cargo build --release --bin pgdog | ||
|
|
||
| - name: Build image | ||
| run: docker build --build-context bin=target/release -f benches/perf/Dockerfile -t $IMAGE . | ||
| - name: Push image | ||
| run: | | ||
| echo '${{ secrets.BENCHER_API_KEY }}' | docker login registry.bencher.dev -u pgdog --password-stdin | ||
| docker push $IMAGE | ||
|
|
||
| bench: | ||
| needs: image | ||
| permissions: | ||
| checks: write | ||
| pull-requests: write | ||
| runs-on: blacksmith-2vcpu-ubuntu-2404 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| suite: [pooler, lb, sharding] | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: bencherdev/bencher@f80847436d7157936b40525db4c2a1064124f04a | ||
| - name: Run ${{ matrix.suite }} on Bencher bare metal | ||
| env: | ||
| START_POINT: ${{ github.event_name == 'pull_request' && format('--start-point {0} --start-point-hash {1} --start-point-clone-thresholds --start-point-reset', github.base_ref, github.event.pull_request.base.sha) || '' }} | ||
| # This will run one test per job (all in parallel). | ||
| # It'll error if a test's throughput is more than 3% BELOW the mean of the baseline's previous runs (main) | ||
| # | ||
| # After testing 5x back-to-back, variance was <1%. This should be enough | ||
| # of a difference, unless something goes on with their servers in the future. | ||
| # | ||
| # TODO: we can re-evaluate a proper variance later | ||
| # | ||
| # Why --github-actions? This allows it to comment on the PR with the result. | ||
| # Why --adapter json? This allows us to use a 'custom harness'; basically nothing like rust's cargo test / criterion, we're running custom scripts | ||
| # Why --detach & --ci-callback-token? This allows us to exit early, and defer posting a comment until repository_dispatch is fired on | ||
| # a separate workflow (bencher_followup.yml) | ||
| run: | | ||
| bencher run \ | ||
| --project pgdog \ | ||
| --key '${{ secrets.BENCHER_API_KEY }}' \ | ||
| --branch '${{ github.head_ref || github.ref_name }}' \ | ||
| $START_POINT \ | ||
| --spec intel-v1 \ | ||
| --threshold-measure throughput \ | ||
| --threshold-test percentage \ | ||
| --threshold-lower-boundary 0.03 \ | ||
| --thresholds-reset \ | ||
| --error-on-alert \ | ||
| --github-actions '${{ secrets.GITHUB_TOKEN }}' \ | ||
| --ci-id ${{ matrix.suite }} \ | ||
| --ci-only-on-alert \ | ||
| --adapter json \ | ||
| --image $IMAGE \ | ||
| --detach \ | ||
| --ci-callback-token '${{ secrets.BENCHER_GITHUB_TOKEN }}' \ | ||
| "bash benches/perf/bencher.sh ${{ matrix.suite }}" | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # This is just the workflow Bencher has in its docs; haven't customized it yet | ||
| # <https://bencher.dev/docs/how-to/github-actions/#pull-requests-on-bare-metal> | ||
| on: | ||
| repository_dispatch: | ||
| types: [bencher_run] | ||
|
|
||
| jobs: | ||
| attach_pr_benchmarks: | ||
| name: Post PR Benchmark Results from Bencher Bare Metal | ||
| permissions: | ||
| checks: write | ||
| pull-requests: write | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: bencherdev/bencher@f80847436d7157936b40525db4c2a1064124f04a | ||
| - name: Post PR Benchmark Results with Bencher | ||
| env: | ||
| JOB_UUID: ${{ github.event.client_payload.bencher.job }} | ||
| run: | | ||
| bencher run \ | ||
| --project pgdog \ | ||
| --key '${{ secrets.BENCHER_API_KEY }}' \ | ||
| --job "$JOB_UUID" \ | ||
| --error-on-alert \ | ||
| --ci-only-on-alert \ | ||
| --github-actions '${{ secrets.GITHUB_TOKEN }}' |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Re-uses the base runtime image; injects this branch's built pgdog binary and | ||
| # the perf scripts we're gonna run in Bencher. | ||
|
|
||
| FROM ghcr.io/pgdogdev/pgdog-base-runtime:latest | ||
|
|
||
| RUN apt update && apt install -y --no-install-recommends postgresql-18 sudo iproute2 | ||
|
|
||
| WORKDIR /pgdog | ||
| COPY --from=bin pgdog /usr/local/bin/pgdog | ||
| COPY integration/common.sh integration/setup.sh integration/ | ||
| COPY integration/ci/setup.sh integration/ci/ | ||
| COPY pgdog/src/backend/schema/setup.sql pgdog/src/backend/schema/ | ||
| COPY benches/perf benches/perf | ||
|
|
||
| # This happens here because we don't have network access in Bencher. | ||
| RUN bash integration/ci/setup.sh && pg_ctlcluster 18 main stop | ||
|
|
||
| CMD ["bash", "benches/perf/bencher.sh", "pooler", "lb", "sharding"] |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #!/bin/bash | ||
| set -e | ||
| export PGDOG_BIN=/usr/local/bin/pgdog | ||
|
|
||
| # We have to make some changes to account for this being ran in a Firecracker microVM, not a Docker container (as | ||
| # this pgdog-base-runtime image was based on that) | ||
| printf '127.0.0.1 localhost\n::1 localhost\n' > /etc/hosts | ||
| ip link set lo up | ||
| mkdir -p /dev/shm && mount -t tmpfs tmpfs /dev/shm | ||
| chown -R postgres:postgres /var/lib/postgresql /etc/postgresql /var/log/postgresql | ||
| chgrp -R ssl-cert /etc/ssl/private | ||
| pg_ctlcluster 18 main start | ||
|
|
||
| # This assembles into "Bencher Metric Format"; required because we don't use something like criterion here, | ||
| # we have our own custom runtime scripts | ||
| json="" | ||
| for name in "$@"; do | ||
| bash benches/perf/run.sh $name > $name.txt 2>&1 | ||
| cat $name.txt >&2 | ||
| tps=$(awk '/^tps/ {print $3}' $name.txt) | ||
| json+="\"$name\": {\"throughput\": {\"value\": $tps}}," | ||
| done | ||
|
|
||
| echo "{${json%,}}" |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/bin/bash | ||
| set -e | ||
| SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
| source ${SCRIPT_DIR}/../../integration/common.sh | ||
|
|
||
| run_pgdog benches/perf/$1 | ||
| wait_for_pgdog | ||
|
|
||
| bash ${SCRIPT_DIR}/$1/run.sh | ||
|
|
||
| stop_pgdog |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want this to be fire and forget (don't wait for job to start/end). Otherwise, we're sitting in the action wasting minutes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. You're right! I missed that it edited the message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot about this: GITHUB_TOKEN expires when the job finishes or after its effective maximum lifetime.