-
-
Notifications
You must be signed in to change notification settings - Fork 4
174 lines (149 loc) · 4.99 KB
/
Copy pathprofiling.yml
File metadata and controls
174 lines (149 loc) · 4.99 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
---
name: Profiling
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
inputs:
target:
description: 'Benchmark target (bench, test, binary)'
required: true
default: 'bench'
type: choice
options:
- bench
- test
- binary
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-D warnings"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
flamegraph:
name: Generate Flamegraph
runs-on: ubuntu-latest
if: >
github.event_name == 'workflow_dispatch' ||
contains(github.event.head_commit.message, '[perf]')
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: llvm-tools
- name: Install flamegraph tools
run: |
cargo install flamegraph
sudo apt-get update
sudo apt-get install -y linux-perf
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "flamegraph-${{ hashFiles('**/Cargo.lock') }}"
cache-all-crates: true
- name: Generate flamegraph for benchmarks
if: >
inputs.target == 'bench' ||
(github.event_name != 'workflow_dispatch')
run: |
mkdir -p target/flamegraphs
cargo flamegraph --bench throughput --output target/flamegraphs/flamegraph.svg -- --bench
- name: Generate flamegraph for tests
if: inputs.target == 'test'
run: |
mkdir -p target/flamegraphs
cargo flamegraph --output target/flamegraphs/flamegraph.svg --test integration
- name: Generate flamegraph for binary
if: inputs.target == 'binary'
run: |
mkdir -p target/flamegraphs
cargo flamegraph --output target/flamegraphs/flamegraph.svg --bin cascette-ribbit -- --help
- name: Upload flamegraph artifacts
uses: actions/upload-artifact@v4
with:
name: flamegraph-${{ inputs.target }}
path: target/flamegraphs/
retention-days: 30
- name: Upload flamegraph to PR comment
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const flamegraph = fs.readFileSync(
'target/flamegraphs/flamegraph.svg',
'base64'
);
const comment = `<!-- flamegraph-comment -->
<details>
<summary>🔥 Flamegraph</summary>

</details>`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('<!-- flamegraph-comment -->')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: comment
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
}
# Performance regression detection using criterion
benchmark:
name: Benchmark
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "benchmark-${{ hashFiles('**/Cargo.lock') }}"
cache-all-crates: true
- name: Run benchmarks
run: cargo bench --bench throughput -- --output-format bencher | tee benchmark-results.txt
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
tool: 'cargo'
output-file-path: benchmark-results.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@danielsreichenbach'
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: target/criterion/
retention-days: 30