Skip to content

Commit 37bf2ad

Browse files
authored
Improve profiling CI (#3296)
* Imporve profiling CI * Disable optimizations for graphene core in dev builds
1 parent 39f4ccf commit 37bf2ad

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

.github/workflows/comment-profiling-changes.yaml

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
name: Profiling Changes
22

33
on:
4-
pull_request: {}
4+
pull_request:
5+
paths:
6+
- 'node-graph/**'
7+
- 'Cargo.toml'
8+
- 'Cargo.lock'
59

610
env:
711
CARGO_TERM_COLOR: always
@@ -50,14 +54,23 @@ jobs:
5054
id: master-sha
5155
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
5256

57+
- name: Get CPU info
58+
id: cpu-info
59+
run: |
60+
# Get CPU model and create a short hash for cache key
61+
CPU_MODEL=$(cat /proc/cpuinfo | grep "model name" | head -1 | cut -d: -f2 | xargs)
62+
CPU_HASH=$(echo "$CPU_MODEL" | sha256sum | cut -c1-8)
63+
echo "cpu-hash=$CPU_HASH" >> $GITHUB_OUTPUT
64+
echo "CPU: $CPU_MODEL (hash: $CPU_HASH)"
65+
5366
- name: Cache benchmark baselines
5467
id: cache-benchmark-baselines
5568
uses: actions/cache@v4
5669
with:
5770
path: target/iai
58-
key: ${{ runner.os }}-benchmark-baselines-master-${{ steps.master-sha.outputs.sha }}
71+
key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.cpu-info.outputs.cpu-hash }}-benchmark-baselines-master-${{ steps.master-sha.outputs.sha }}
5972
restore-keys: |
60-
${{ runner.os }}-benchmark-baselines-master-
73+
${{ runner.os }}-${{ runner.arch }}-${{ steps.cpu-info.outputs.cpu-hash }}-benchmark-baselines-master-
6174
6275
- name: Run baseline benchmarks
6376
if: steps.cache-benchmark-baselines.outputs.cache-hit != 'true'
@@ -85,6 +98,8 @@ jobs:
8598
cargo bench --bench run_cached_iai -- --baseline=master --output-format=json | jq -sc | sed 's/\\"//g' > /tmp/run_cached_output.json
8699
87100
- name: Make old comments collapsed by default
101+
# Only run if we have write permissions (not a fork)
102+
if: github.event.pull_request.head.repo.full_name == github.repository
88103
uses: actions/github-script@v7
89104
with:
90105
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -110,6 +125,7 @@ jobs:
110125
}
111126
112127
- name: Comment PR
128+
if: github.event.pull_request.head.repo.full_name == github.repository
113129
uses: actions/github-script@v7
114130
with:
115131
github-token: ${{secrets.GITHUB_TOKEN}}
@@ -246,3 +262,28 @@ jobs:
246262
} else {
247263
console.log("No benchmark results to display.");
248264
}
265+
266+
- name: Fail on significant regressions
267+
uses: actions/github-script@v7
268+
with:
269+
script: |
270+
const fs = require('fs');
271+
272+
const allOutputs = [
273+
JSON.parse(fs.readFileSync('/tmp/compile_output.json', 'utf8')),
274+
JSON.parse(fs.readFileSync('/tmp/update_output.json', 'utf8')),
275+
JSON.parse(fs.readFileSync('/tmp/run_once_output.json', 'utf8')),
276+
JSON.parse(fs.readFileSync('/tmp/run_cached_output.json', 'utf8'))
277+
];
278+
279+
for (const benchmarkOutput of allOutputs) {
280+
for (const benchmark of benchmarkOutput) {
281+
if (benchmark.profiles?.[0]?.summaries?.parts?.[0]?.metrics_summary?.Callgrind?.Ir?.diffs?.diff_pct) {
282+
const diffPct = parseFloat(benchmark.profiles[0].summaries.parts[0].metrics_summary.Callgrind.Ir.diffs.diff_pct);
283+
if (diffPct > 5) {
284+
core.setFailed(`Significant performance regression detected: ${benchmark.module_path} ${benchmark.id} increased by ${diffPct.toFixed(2)}%`);
285+
return;
286+
}
287+
}
288+
}
289+
}

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ opt-level = 1
205205
[profile.dev.package]
206206
graphite-editor = { opt-level = 1 }
207207
graphene-core-shaders = { opt-level = 1 }
208-
graphene-core = { opt-level = 1 }
209208
graphene-std = { opt-level = 1 }
210209
interpreted-executor = { opt-level = 1 } # This is a mitigation for https://github.com/rustwasm/wasm-pack/issues/981 which is needed because the node_registry function is too large
211210
graphite-proc-macros = { opt-level = 1 }

0 commit comments

Comments
 (0)