Repository navigation
Add load tests, a browser swarm and committed benchmark results #4055
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
base: dev
Are you sure you want to change the base?
Changes from all commits
505cd77
3bf0a71
a91e2c5
3344314
8919412
4008669
05f0792
dc5289b
7768d5b
a9493e3
f1e9fe7
193596d
855d5d4
c6311b9
6eff93c
2d17227
28e2832
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,244 @@ | ||||||||||||||||||||||
| name: Publish Benchmarks | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Measures the benchmarks on the dev branch weekly (and on demand). Only when | ||||||||||||||||||||||
| # the numbers moved enough to matter (a capacity step in the load tests, a | ||||||||||||||||||||||
| # renderer median by over 25% and 5 ms, or a serialization median by over 25% | ||||||||||||||||||||||
| # and 5 ms) does it open a pull request that | ||||||||||||||||||||||
| # commits them to benchmarks/results/ (read by the docs) and the README table. | ||||||||||||||||||||||
| # Per-PR renderer regressions are benchmarks.yml's job, not this one. | ||||||||||||||||||||||
| # | ||||||||||||||||||||||
| # Needs "Allow GitHub Actions to create and approve pull requests" in the | ||||||||||||||||||||||
| # repo settings. A pull request opened with GITHUB_TOKEN starts no other | ||||||||||||||||||||||
| # workflows: close and reopen it to run the checks before merging. | ||||||||||||||||||||||
|
Comment on lines
+10
to
+12
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this done? If so, we don't need this.
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| on: | ||||||||||||||||||||||
| schedule: | ||||||||||||||||||||||
| - cron: '0 6 * * 1' | ||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||
| inputs: | ||||||||||||||||||||||
| streaming: | ||||||||||||||||||||||
| description: Run the streaming load sweep too | ||||||||||||||||||||||
| type: boolean | ||||||||||||||||||||||
| default: true | ||||||||||||||||||||||
| callbacks: | ||||||||||||||||||||||
| description: Run the HTTP vs websocket callback sweep too | ||||||||||||||||||||||
|
Comment on lines
+20
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
| type: boolean | ||||||||||||||||||||||
| default: true | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| concurrency: | ||||||||||||||||||||||
| group: benchmarks-publish | ||||||||||||||||||||||
| cancel-in-progress: false | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||
| renderer: | ||||||||||||||||||||||
| name: Renderer benchmarks | ||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||
| timeout-minutes: 30 | ||||||||||||||||||||||
| steps: | ||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||
| - uses: actions/setup-node@v4 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| node-version: '24' | ||||||||||||||||||||||
| cache: npm | ||||||||||||||||||||||
| - run: npm ci | ||||||||||||||||||||||
|
Check warning on line 46 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| - uses: actions/setup-python@v5 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| python-version: '3.12' | ||||||||||||||||||||||
| cache: pip | ||||||||||||||||||||||
| - name: Install Dash | ||||||||||||||||||||||
| run: | | ||||||||||||||||||||||
| python -m pip install --upgrade pip | ||||||||||||||||||||||
|
Check warning on line 53 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| python -m pip install "setuptools<80.0.0" | ||||||||||||||||||||||
|
Check warning on line 54 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| python -m pip install -e .[ci,dev,testing] | ||||||||||||||||||||||
|
Check warning on line 55 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| - run: npm run build | ||||||||||||||||||||||
| - uses: browser-actions/setup-chrome@c785b87e244131f27c9f19c1a33e2ead956ab7ce # v1 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| chrome-version: stable | ||||||||||||||||||||||
| - name: Set up virtual display | ||||||||||||||||||||||
| run: | | ||||||||||||||||||||||
| sudo apt-get update | ||||||||||||||||||||||
| sudo apt-get install -y xvfb | ||||||||||||||||||||||
| sudo Xvfb :99 -ac -screen 0 1400x1000x24 & | ||||||||||||||||||||||
| echo "DISPLAY=:99" >> $GITHUB_ENV | ||||||||||||||||||||||
| # Exit 1 is a gate failure after every scenario ran: publish it, then | ||||||||||||||||||||||
| # fail. Exit 2 means some scenarios did not run: publish nothing. | ||||||||||||||||||||||
| - id: run | ||||||||||||||||||||||
| run: | | ||||||||||||||||||||||
| set +e | ||||||||||||||||||||||
| python -m benchmarks.run --out benchmarks/results.json \ | ||||||||||||||||||||||
| --descriptions benchmarks/descriptions.json | ||||||||||||||||||||||
| echo "status=$?" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||
| - uses: actions/upload-artifact@v4 | ||||||||||||||||||||||
| if: steps.run.outputs.status == '0' || steps.run.outputs.status == '1' | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| name: renderer-results | ||||||||||||||||||||||
| path: | | ||||||||||||||||||||||
| benchmarks/results.json | ||||||||||||||||||||||
| benchmarks/descriptions.json | ||||||||||||||||||||||
| - if: steps.run.outputs.status != '0' | ||||||||||||||||||||||
| run: exit 1 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| streaming: | ||||||||||||||||||||||
| name: Streaming load sweep | ||||||||||||||||||||||
| if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.streaming) | ||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||
| timeout-minutes: 120 | ||||||||||||||||||||||
| steps: | ||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||
| - uses: actions/setup-node@v4 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| node-version: '24' | ||||||||||||||||||||||
| cache: npm | ||||||||||||||||||||||
| - run: npm ci | ||||||||||||||||||||||
| - uses: actions/setup-python@v5 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| python-version: '3.12' | ||||||||||||||||||||||
| cache: pip | ||||||||||||||||||||||
| - name: Install Dash | ||||||||||||||||||||||
| run: | | ||||||||||||||||||||||
| python -m pip install --upgrade pip | ||||||||||||||||||||||
|
Check warning on line 102 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| python -m pip install "setuptools<80.0.0" | ||||||||||||||||||||||
|
Check warning on line 103 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| python -m pip install -e .[ci,dev,testing,async,fastapi,quart] | ||||||||||||||||||||||
|
Check warning on line 104 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| python -m pip install gunicorn uvicorn aiohttp psutil | ||||||||||||||||||||||
|
Check warning on line 105 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| - run: npm run build | ||||||||||||||||||||||
| - name: Run the sweep | ||||||||||||||||||||||
| env: | ||||||||||||||||||||||
| BENCH_RUNNER: GitHub Actions ubuntu-latest | ||||||||||||||||||||||
| run: | | ||||||||||||||||||||||
| ulimit -n 65536 | ||||||||||||||||||||||
| python -m benchmarks.streaming.load \ | ||||||||||||||||||||||
| --out benchmarks/streaming/results.json | ||||||||||||||||||||||
| - uses: actions/upload-artifact@v4 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| name: streaming-results | ||||||||||||||||||||||
| path: benchmarks/streaming/results.json | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| callbacks: | ||||||||||||||||||||||
| name: Callback load sweep | ||||||||||||||||||||||
| if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.callbacks) | ||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||
| timeout-minutes: 120 | ||||||||||||||||||||||
| steps: | ||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||
| - uses: actions/setup-node@v4 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| node-version: '24' | ||||||||||||||||||||||
| cache: npm | ||||||||||||||||||||||
| - run: npm ci | ||||||||||||||||||||||
|
Check warning on line 130 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| - uses: actions/setup-python@v5 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| python-version: '3.12' | ||||||||||||||||||||||
| cache: pip | ||||||||||||||||||||||
| - name: Install Dash | ||||||||||||||||||||||
| run: | | ||||||||||||||||||||||
| python -m pip install --upgrade pip | ||||||||||||||||||||||
|
Check warning on line 137 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| python -m pip install "setuptools<80.0.0" | ||||||||||||||||||||||
|
Check warning on line 138 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| python -m pip install -e .[ci,dev,testing,async,fastapi,quart] | ||||||||||||||||||||||
|
Check warning on line 139 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| python -m pip install gunicorn uvicorn aiohttp psutil | ||||||||||||||||||||||
|
Check warning on line 140 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| - run: npm run build | ||||||||||||||||||||||
| - name: Run the sweep | ||||||||||||||||||||||
| env: | ||||||||||||||||||||||
| BENCH_RUNNER: GitHub Actions ubuntu-latest | ||||||||||||||||||||||
| run: | | ||||||||||||||||||||||
| ulimit -n 65536 | ||||||||||||||||||||||
| python -m benchmarks.callbacks.load --out benchmarks/callbacks/results.json | ||||||||||||||||||||||
| - uses: actions/upload-artifact@v4 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| name: callbacks-results | ||||||||||||||||||||||
| path: benchmarks/callbacks/results.json | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| serialization: | ||||||||||||||||||||||
| name: Serialization benchmarks | ||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||
| timeout-minutes: 30 | ||||||||||||||||||||||
| steps: | ||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||
| - uses: actions/setup-node@v4 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| node-version: '24' | ||||||||||||||||||||||
| cache: npm | ||||||||||||||||||||||
| - run: npm ci | ||||||||||||||||||||||
|
Check warning on line 163 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| - uses: actions/setup-python@v5 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| python-version: '3.12' | ||||||||||||||||||||||
| cache: pip | ||||||||||||||||||||||
| - name: Install Dash | ||||||||||||||||||||||
| run: | | ||||||||||||||||||||||
| python -m pip install --upgrade pip | ||||||||||||||||||||||
|
Check warning on line 170 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| python -m pip install "setuptools<80.0.0" | ||||||||||||||||||||||
|
Check warning on line 171 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| python -m pip install -e .[ci,dev,testing] | ||||||||||||||||||||||
|
Check warning on line 172 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| - run: npm run build | ||||||||||||||||||||||
| # Runs with orjson and again with its import blocked. | ||||||||||||||||||||||
| - run: python -m benchmarks.serialization.bench --out benchmarks/serialization/results.json | ||||||||||||||||||||||
| - uses: actions/upload-artifact@v4 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| name: serialization-results | ||||||||||||||||||||||
| path: benchmarks/serialization/results.json | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| publish: | ||||||||||||||||||||||
| name: Open the results pull request | ||||||||||||||||||||||
| needs: [renderer, streaming, callbacks, serialization] | ||||||||||||||||||||||
| # Only dev's numbers are committed, even when a dispatch runs elsewhere. | ||||||||||||||||||||||
| if: >- | ||||||||||||||||||||||
| always() && github.ref == 'refs/heads/dev' && | ||||||||||||||||||||||
| (needs.renderer.result == 'success' || needs.renderer.result == 'failure' || | ||||||||||||||||||||||
| needs.streaming.result == 'success' || | ||||||||||||||||||||||
| needs.callbacks.result == 'success' || needs.serialization.result == 'success') | ||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||
| contents: write | ||||||||||||||||||||||
| pull-requests: write | ||||||||||||||||||||||
| env: | ||||||||||||||||||||||
| BRANCH: benchmarks/update-results | ||||||||||||||||||||||
| steps: | ||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||
| - uses: actions/setup-python@v5 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| python-version: '3.12' | ||||||||||||||||||||||
| - uses: actions/download-artifact@v4 | ||||||||||||||||||||||
| with: | ||||||||||||||||||||||
| path: results | ||||||||||||||||||||||
| - name: Update the results | ||||||||||||||||||||||
| env: | ||||||||||||||||||||||
| BENCH_RUNNER: GitHub Actions ubuntu-latest | ||||||||||||||||||||||
| run: | | ||||||||||||||||||||||
| args="" | ||||||||||||||||||||||
| [ -f results/renderer-results/results.json ] && args="$args --renderer results/renderer-results/results.json" | ||||||||||||||||||||||
| [ -f results/renderer-results/descriptions.json ] && args="$args --renderer-descriptions results/renderer-results/descriptions.json" | ||||||||||||||||||||||
| [ -f results/streaming-results/results.json ] && args="$args --streaming results/streaming-results/results.json" | ||||||||||||||||||||||
| [ -f results/callbacks-results/results.json ] && args="$args --callbacks results/callbacks-results/results.json" | ||||||||||||||||||||||
| [ -f results/serialization-results/results.json ] && args="$args --serialization results/serialization-results/results.json" | ||||||||||||||||||||||
| python -m pip install -e . | ||||||||||||||||||||||
|
Check warning on line 214 in .github/workflows/benchmarks-publish.yml
|
||||||||||||||||||||||
| python -m benchmarks.publish --commit "${GITHUB_SHA::9}" \ | ||||||||||||||||||||||
| --only-significant --changes "$RUNNER_TEMP/changes.md" $args | ||||||||||||||||||||||
| - name: Open or update the pull request | ||||||||||||||||||||||
| env: | ||||||||||||||||||||||
| GH_TOKEN: ${{ github.token }} | ||||||||||||||||||||||
| run: | | ||||||||||||||||||||||
| git add benchmarks/results README.md | ||||||||||||||||||||||
| if git diff --cached --quiet; then | ||||||||||||||||||||||
| echo "No significant change." | ||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| echo "Benchmark numbers from ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID} moved enough to publish:" | ||||||||||||||||||||||
| echo | ||||||||||||||||||||||
| cat "$RUNNER_TEMP/changes.md" | ||||||||||||||||||||||
| echo | ||||||||||||||||||||||
| echo "Merge to update the README table and the docs." | ||||||||||||||||||||||
| } > "$RUNNER_TEMP/body.md" | ||||||||||||||||||||||
| git config user.name "github-actions[bot]" | ||||||||||||||||||||||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||||||||||||||||||||||
| git switch -c "$BRANCH" | ||||||||||||||||||||||
| git commit -m "Update benchmark results for ${GITHUB_SHA::9}" | ||||||||||||||||||||||
| # Each run starts from dev, so an unmerged run is replaced, not stacked. | ||||||||||||||||||||||
| git push --force origin "$BRANCH" | ||||||||||||||||||||||
| if [ -z "$(gh pr list --head "$BRANCH" --state open --json number --jq '.[].number')" ]; then | ||||||||||||||||||||||
| gh pr create --base dev --head "$BRANCH" \ | ||||||||||||||||||||||
| --title "Update benchmark results" --body-file "$RUNNER_TEMP/body.md" | ||||||||||||||||||||||
| else | ||||||||||||||||||||||
| gh pr edit "$BRANCH" --body-file "$RUNNER_TEMP/body.md" | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| # Generated benchmark artifacts (baseline.json is committed on purpose) | ||
| # Generated benchmark artifacts (baseline.json and results/ are committed on purpose) | ||
| results.json | ||
| summary.md | ||
| *.cpuprofile | ||
| __pycache__/ | ||
| streaming/results.json | ||
| callbacks/results.json |
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'm wondering about the benchmark reproducibility from run-to-run. Have you run benchmarks on CI enough to feel confident that the results won't be polluted by overloaded/slow runners?
Put another way, if a benchmark "fails", how do we know it's not a GH problem rather than a code problem?
I'm not sure what guarantees or configuration GH provides around this topic.