-
Notifications
You must be signed in to change notification settings - Fork 24
195 lines (166 loc) · 5.63 KB
/
benchmark.yml
File metadata and controls
195 lines (166 loc) · 5.63 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
name: Performance Benchmarks
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 2 * * 1' # Run every Monday at 2 AM UTC
env:
CARGO_TERM_COLOR: always
jobs:
benchmark:
name: Performance Benchmarks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential pkg-config libssl-dev
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-bench-
${{ runner.os }}-cargo-
- name: Run benchmarks
run: |
# Create benchmarks directory if it doesn't exist
mkdir -p target/criterion
cargo bench --workspace 2>&1 | tee benchmark_output.txt
- name: Store benchmark results
uses: benchmark-action/github-action-benchmark@v1
with:
name: Rust Benchmark
tool: 'cargo'
output-file-path: benchmark_output.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@maintainers'
- name: Upload benchmark reports
uses: actions/upload-artifact@v5
with:
name: benchmark-reports
path: |
target/criterion/**/*.html
target/criterion/**/*.json
retention-days: 30
- name: Performance regression check
if: github.event_name == 'pull_request'
run: |
echo "Checking for performance regressions..."
# This would be enhanced with custom performance regression detection logic
if grep -q "Performance regression detected" benchmark_output.txt; then
echo "❌ Performance regression detected!"
exit 1
else
echo "✅ No significant performance regression detected"
fi
benchmark-comparison:
name: Benchmark Comparison
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout PR branch
uses: actions/checkout@v5
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential pkg-config libssl-dev
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-bench-pr-${{ hashFiles('**/Cargo.lock') }}
- name: Run PR benchmarks
run: |
cargo bench --workspace > pr_benchmarks.txt 2>&1
- name: Checkout main branch
uses: actions/checkout@v5
with:
ref: main
path: main-branch
- name: Run main branch benchmarks
working-directory: main-branch
run: |
cargo bench --workspace > ../main_benchmarks.txt 2>&1
- name: Install critcmp for comparison
run: cargo install critcmp
- name: Compare benchmarks
run: |
echo "## Benchmark Comparison" > benchmark_comparison.md
echo "" >> benchmark_comparison.md
echo "Comparing this PR against main branch:" >> benchmark_comparison.md
echo "" >> benchmark_comparison.md
echo '```' >> benchmark_comparison.md
critcmp main_benchmarks.txt pr_benchmarks.txt >> benchmark_comparison.md || echo "No comparable benchmarks found" >> benchmark_comparison.md
echo '```' >> benchmark_comparison.md
- name: Comment benchmark results
uses: actions/github-script@v8
with:
script: |
const fs = require('fs');
const comparison = fs.readFileSync('benchmark_comparison.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comparison
});
memory-profiling:
name: Memory Profiling
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential pkg-config libssl-dev valgrind
- name: Install cargo-valgrind
run: cargo install cargo-valgrind
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-valgrind-${{ hashFiles('**/Cargo.lock') }}
- name: Run memory profiling
run: |
# Run memory profiling on key benchmarks
echo "Running memory profiling..."
cargo build --release --workspace
# Create memory profiling report
echo "# Memory Profiling Report" > memory_report.md
echo "" >> memory_report.md
echo "Generated on: $(date)" >> memory_report.md
echo "" >> memory_report.md
# Add memory usage statistics here when we have specific binaries
- name: Upload memory profiling report
uses: actions/upload-artifact@v5
with:
name: memory-profiling-report
path: memory_report.md
retention-days: 30