-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- Open the PR up as a draft until you feel it is ready for a proper review. Do not make PR:s from your own `main` branch, as that makes it difficult for reviewers to add their own fixes. Add any improvements to the branch as new commits to make it easier for reviewers to follow the progress. All commits will be squashed to a single commit once the PR is merged into `main`. Make sure you mention any issues that this PR closes in the description, as well as any other related issues. To get an auto-generated PR description you can put "copilot:summary" or "copilot:walkthrough" anywhere. --> ### What Fixes #2511 - Adds `scripts/ci/sizes.py` for measuring and comparing file sizes - This works for any files, not just WASM files - Use the new script in a new `reusable_track_size.yml` workflow - Measures sizes of various files (`.wasm`, `.js`, demo `.rrd`), and uploads the results to GCS - Compares the results to `main` and posts a PR comment if the size changed significantly (+10% or -10%) - Builds file size graphs and pushes them to `gh-pages` on every commit to `main` - Also updated the PR description template to include links to benchmark graphs and the new size graphs. ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/3037) (if applicable) - [PR Build Summary](https://build.rerun.io/pr/3037) - [Docs preview](https://rerun.io/preview/pr%3Ajan%2Ftrack-wasm-size/docs) - [Examples preview](https://rerun.io/preview/pr%3Ajan%2Ftrack-wasm-size/examples)
- Loading branch information
Showing
5 changed files
with
384 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
name: "Track Size" | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
CONCURRENCY: | ||
required: true | ||
type: string | ||
ADHOC_NAME: | ||
required: false | ||
type: string | ||
default: "" | ||
PR_NUMBER: | ||
required: false | ||
type: number | ||
|
||
permissions: | ||
contents: write | ||
id-token: write | ||
deployments: write | ||
pull-requests: write | ||
|
||
jobs: | ||
track-sizes: | ||
name: "Track Sizes" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Get context | ||
id: context | ||
run: | | ||
echo "head_short_sha=$(echo ${{ github.sha }} | cut -c1-7)" >> "$GITHUB_OUTPUT" | ||
if [ -n ${{ inputs.PR_NUMBER }} ]; then | ||
base_short_sha=$(echo ${{ github.event.pull_request.base.sha }} | cut -c1-7) | ||
else | ||
base_short_sha=$short_sha | ||
fi | ||
echo "base_short_sha=$base_short_sha" >> "$GITHUB_OUTPUT" | ||
- id: "auth" | ||
uses: google-github-actions/auth@v1 | ||
with: | ||
workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }} | ||
|
||
- name: "Set up Cloud SDK" | ||
uses: "google-github-actions/setup-gcloud@v1" | ||
with: | ||
version: ">= 363.0.0" | ||
|
||
- name: Download web_viewer | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: web_viewer | ||
path: web_viewer | ||
|
||
- name: Download web_demo | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: web_demo | ||
path: web_demo | ||
|
||
- name: Download base branch results | ||
run: | | ||
file_path="gs://rerun-builds/sizes/commit/${{ steps.context.outputs.base_short_sha }}/data.json" | ||
if [ "$(gsutil -q stat $file_path ; echo $?)" = 0 ]; then | ||
gsutil cp $file_path "/tmp/prev.json" | ||
else | ||
echo "[]" > "/tmp/prev.json" | ||
fi | ||
- name: Measure sizes | ||
id: measure | ||
shell: bash | ||
run: | | ||
entries=() | ||
entries+=("Wasm:web_viewer/re_viewer_bg.wasm:MB") | ||
entries+=("JS:web_viewer/re_viewer.js:KB") | ||
for file in web_demo/examples/**/*.rrd; do | ||
name=$(basename $(dirname "$file")) | ||
entries+=("$name.rrd:$file:KB") | ||
done | ||
data=$(python3 scripts/ci/sizes.py measure "${entries[@]}") | ||
echo "$data" | ||
echo "$data" > "/tmp/data.json" | ||
comparison=$(python3 scripts/ci/sizes.py compare --threshold=5 "/tmp/prev.json" "/tmp/data.json") | ||
echo "$comparison" | ||
{ | ||
echo 'comparison<<EOF' | ||
echo "$comparison" | ||
echo EOF | ||
} >> "$GITHUB_OUTPUT" | ||
if [ -n "$comparison" ]; then | ||
echo "is_comparison_set=true" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "is_comparison_set=false" >> "$GITHUB_OUTPUT" | ||
fi | ||
- name: Upload data to GCS (commit) | ||
if: inputs.ADHOC_NAME == '' | ||
uses: google-github-actions/upload-cloud-storage@v1 | ||
with: | ||
path: /tmp/data.json | ||
destination: "rerun-builds/sizes/commit/${{ steps.context.outputs.head_short_sha }}" | ||
|
||
- name: Upload data to GCS (adhoc) | ||
if: inputs.ADHOC_NAME != '' | ||
uses: google-github-actions/upload-cloud-storage@v1 | ||
with: | ||
path: /tmp/data.json | ||
destination: "rerun-builds/sizes/adhoc/${{ inputs.ADHOC_NAME }}" | ||
|
||
- name: Store benchmark result | ||
# Only run on `main` | ||
if: github.ref == 'refs/heads/main' | ||
# https://github.com/benchmark-action/github-action-benchmark | ||
uses: benchmark-action/github-action-benchmark@v1 | ||
with: | ||
name: Sizes | ||
tool: customSmallerIsBetter | ||
output-file-path: /tmp/benchmark | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Show alert with commit on detecting possible size regression | ||
comment-on-alert: true | ||
alert-threshold: "110%" | ||
fail-on-alert: false | ||
comment-always: false | ||
|
||
save-data-file: true | ||
auto-push: true | ||
gh-pages-branch: gh-pages | ||
benchmark-data-dir-path: dev/sizes | ||
max-items-in-chart: 30 | ||
|
||
- name: Create PR comment | ||
if: inputs.PR_NUMBER != '' && steps.measure.outputs.is_comparison_set == 'true' | ||
# https://github.com/mshick/add-pr-comment | ||
uses: mshick/[email protected] | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
message: | | ||
# Size changes | ||
${{ steps.measure.outputs.comparison }} | ||
Oops, something went wrong.