-
Notifications
You must be signed in to change notification settings - Fork 34
204 lines (177 loc) · 7.08 KB
/
benchmarks.yml
File metadata and controls
204 lines (177 loc) · 7.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
name: Benchmarks
on:
workflow_dispatch:
# TODO: Remove pull_request trigger after testing
pull_request:
types: [opened, synchronize, reopened]
push:
branches: [main]
permissions:
id-token: write # Required for OIDC authentication to AWS
contents: read
env:
BENCHMARK_REPEAT_COUNT: 5
jobs:
benchmarks:
name: benchmarks-${{ matrix.name }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- runner: 'c7i-16xlarge'
name: 'x86-intel-64cpu-128gb'
- runner: 'c8g-16xlarge'
name: 'arm-graviton4-64cpu-128gb'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref }}
- name: Set safe directory
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Install deps
run: |
sudo yum -y install gcc openssl-devel curl jq z3-devel clang pkg-config python3 python3-pip
pip3 install -r .github/scripts/requirements.txt
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
key: benchmarks-${{ matrix.name }}
cache-on-failure: true
- name: Run platform diagnostics
run: cargo test -p binius-utils --features platform-diagnostics test_platform_diagnostics -- --nocapture
env:
RUSTFLAGS: "-C target-cpu=native"
- name: Run benchmarks
run: |
python3 .github/scripts/run_benchmarks.py --repeat ${{ env.BENCHMARK_REPEAT_COUNT }}
env:
PERFETTO_PLATFORM_NAME: "${{ matrix.runner }}"
RUSTFLAGS: "-C target-cpu=native"
- name: List perfetto traces and summaries
if: always()
run: |
echo "=== Perfetto traces directory structure ==="
if [ -d perfetto_traces ]; then
find perfetto_traces -type f | sort
else
echo "DEBUG: No perfetto_traces directory found"
fi
echo ""
echo "=== Benchmark summaries ==="
if [ -d benchmark_summaries ]; then
find benchmark_summaries -type f | sort
else
echo "DEBUG: No benchmark_summaries directory found"
fi
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_UPLOAD_ROLE }}
aws-region: us-east-1
- name: Upload perfetto traces to S3
run: |
BRANCH_NAME="${{ github.head_ref || github.ref_name }}"
echo "DEBUG: Branch name: $BRANCH_NAME"
if [ "$BRANCH_NAME" = "main" ]; then
BRANCH_PATH="main"
else
# Sanitize branch name
# Lowercase, keep a-z 0-9 . _ -, replace others with dash, remove leading/trailing dashes
SANITIZED_BRANCH=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9._-]/-/g' | sed 's/^-*//g' | sed 's/-*$//g' | sed 's/--*/-/g')
BRANCH_PATH="branch-${SANITIZED_BRANCH}"
fi
echo "DEBUG: Branch path: $BRANCH_PATH"
if [ -d perfetto_traces ]; then
echo "DEBUG: Uploading perfetto traces to S3.."
aws s3 cp "perfetto_traces/" "${{ secrets.PERFETTO_BUCKET }}/traces/binius64/${BRANCH_PATH}/" --recursive
echo "DEBUG: Traces uploaded to: ${{ secrets.PERFETTO_BUCKET }}/traces/binius64/${BRANCH_PATH}/"
else
echo "DEBUG: No perfetto_traces directory to upload"
fi
echo "BRANCH_PATH=${BRANCH_PATH}" >> $GITHUB_ENV
- name: Generate benchmark report for GitHub Summary
if: always()
run: |
echo "DEBUG: Generating benchmark report..."
echo "DEBUG: BRANCH_PATH=${BRANCH_PATH}"
echo "DEBUG: Current directory contents:"
ls -la
echo "DEBUG: Running report generation script..."
python3 .github/scripts/generate_benchmark_report.py \
--branch-path "${BRANCH_PATH}" \
>> $GITHUB_STEP_SUMMARY
echo "DEBUG: Report generation completed, exit code: $?"
- name: Upload benchmark summaries as artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: benchmark-summaries-${{ matrix.name }}
path: |
benchmark_summaries/*.json
perfetto_traces/**/metrics.json
retention-days: 30
publish-benchmark-results:
name: Publish benchmark results to binius-benchmark repo
# TODO: Re-enable condition
# if: github.ref == 'refs/heads/main'
needs: [benchmarks]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Download all benchmark artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
pattern: benchmark-summaries-*
merge-multiple: true
# GitHub App authentication
- name: Create GitHub App token
uses: actions/create-github-app-token@v2
id: app-token
with:
app-id: ${{ vars.BENCHMARK_PUBLISHER_APP_ID }}
private-key: ${{ secrets.BENCHMARK_PUBLISHER_PRIVATE_KEY }}
owner: IrreducibleOSS
repositories: binius-benchmark
- name: Get GitHub App User ID
id: get-user-id
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Configure git credentials globally
run: |
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]'
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com'
- name: Publish benchmark results with retry
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
max_attempts: 5
retry_wait_seconds: 30
command: |
set -e # Exit on any error to trigger retry
# Clone and setup
rm -rf /tmp/binius-benchmark
git clone "https://x-access-token:${GH_TOKEN}@github.com/IrreducibleOSS/binius-benchmark.git" /tmp/binius-benchmark
cd /tmp/binius-benchmark
git pull origin main
# Process all benchmark-results files
echo "Processing benchmark results..."
python3 "${{ env.BENCHMARK_PROCESSOR_SCRIPT }}" "$GITHUB_WORKSPACE"/artifacts/benchmark_summaries/benchmark-results-*.json
# Commit if changes exist
git add .
if ! git diff --staged --quiet; then
git commit -m "Update benchmark data - binius64@${{ github.sha }}"
git push origin main
echo "🎉 Successfully pushed changes"
else
echo "ℹ️ No changes to commit"
fi
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
BENCHMARK_PROCESSOR_SCRIPT: scripts/update.py