From 37bf2ade11ef14d61ac7ccb7a50938106d62d757 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Tue, 21 Oct 2025 15:01:41 +0200 Subject: [PATCH] Improve profiling CI (#3296) * Imporve profiling CI * Disable optimizations for graphene core in dev builds --- .../workflows/comment-profiling-changes.yaml | 47 +++++++++++++++++-- Cargo.toml | 1 - 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/.github/workflows/comment-profiling-changes.yaml b/.github/workflows/comment-profiling-changes.yaml index 57b49df9..efe590bc 100644 --- a/.github/workflows/comment-profiling-changes.yaml +++ b/.github/workflows/comment-profiling-changes.yaml @@ -1,7 +1,11 @@ name: Profiling Changes on: - pull_request: {} + pull_request: + paths: + - 'node-graph/**' + - 'Cargo.toml' + - 'Cargo.lock' env: CARGO_TERM_COLOR: always @@ -50,14 +54,23 @@ jobs: id: master-sha run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + - name: Get CPU info + id: cpu-info + run: | + # Get CPU model and create a short hash for cache key + CPU_MODEL=$(cat /proc/cpuinfo | grep "model name" | head -1 | cut -d: -f2 | xargs) + CPU_HASH=$(echo "$CPU_MODEL" | sha256sum | cut -c1-8) + echo "cpu-hash=$CPU_HASH" >> $GITHUB_OUTPUT + echo "CPU: $CPU_MODEL (hash: $CPU_HASH)" + - name: Cache benchmark baselines id: cache-benchmark-baselines uses: actions/cache@v4 with: path: target/iai - key: ${{ runner.os }}-benchmark-baselines-master-${{ steps.master-sha.outputs.sha }} + key: ${{ runner.os }}-${{ runner.arch }}-${{ steps.cpu-info.outputs.cpu-hash }}-benchmark-baselines-master-${{ steps.master-sha.outputs.sha }} restore-keys: | - ${{ runner.os }}-benchmark-baselines-master- + ${{ runner.os }}-${{ runner.arch }}-${{ steps.cpu-info.outputs.cpu-hash }}-benchmark-baselines-master- - name: Run baseline benchmarks if: steps.cache-benchmark-baselines.outputs.cache-hit != 'true' @@ -85,6 +98,8 @@ jobs: cargo bench --bench run_cached_iai -- --baseline=master --output-format=json | jq -sc | sed 's/\\"//g' > /tmp/run_cached_output.json - name: Make old comments collapsed by default + # Only run if we have write permissions (not a fork) + if: github.event.pull_request.head.repo.full_name == github.repository uses: actions/github-script@v7 with: github-token: ${{secrets.GITHUB_TOKEN}} @@ -110,6 +125,7 @@ jobs: } - name: Comment PR + if: github.event.pull_request.head.repo.full_name == github.repository uses: actions/github-script@v7 with: github-token: ${{secrets.GITHUB_TOKEN}} @@ -246,3 +262,28 @@ jobs: } else { console.log("No benchmark results to display."); } + + - name: Fail on significant regressions + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + + const allOutputs = [ + JSON.parse(fs.readFileSync('/tmp/compile_output.json', 'utf8')), + JSON.parse(fs.readFileSync('/tmp/update_output.json', 'utf8')), + JSON.parse(fs.readFileSync('/tmp/run_once_output.json', 'utf8')), + JSON.parse(fs.readFileSync('/tmp/run_cached_output.json', 'utf8')) + ]; + + for (const benchmarkOutput of allOutputs) { + for (const benchmark of benchmarkOutput) { + if (benchmark.profiles?.[0]?.summaries?.parts?.[0]?.metrics_summary?.Callgrind?.Ir?.diffs?.diff_pct) { + const diffPct = parseFloat(benchmark.profiles[0].summaries.parts[0].metrics_summary.Callgrind.Ir.diffs.diff_pct); + if (diffPct > 5) { + core.setFailed(`Significant performance regression detected: ${benchmark.module_path} ${benchmark.id} increased by ${diffPct.toFixed(2)}%`); + return; + } + } + } + } diff --git a/Cargo.toml b/Cargo.toml index 345484ae..c8e7bf43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -205,7 +205,6 @@ opt-level = 1 [profile.dev.package] graphite-editor = { opt-level = 1 } graphene-core-shaders = { opt-level = 1 } -graphene-core = { opt-level = 1 } graphene-std = { opt-level = 1 } 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 graphite-proc-macros = { opt-level = 1 }