ci: use hotpath-utils for benchmark workflows

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Iaae187e8320a3642c813ca2095a616056a6a6964
This commit is contained in:
raf 2026-03-27 15:44:28 +03:00
commit 26c7a9f528
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
2 changed files with 56 additions and 79 deletions

View file

@ -14,49 +14,31 @@ jobs:
comment:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout
uses: actions/checkout@v6
- uses: actions/checkout@v4
- name: Download profiling results
uses: actions/download-artifact@v8
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/download-artifact@v4
with:
name: hotpath-results
path: /tmp/
name: profile-metrics
path: /tmp/metrics/
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install hotpath-utils CLI
run: cargo install hotpath --bin hotpath-utils --features=utils
- name: Install hotpath CLI
run: cargo install hotpath
- name: Post timing comparison comment
- name: Post PR comment
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
HEAD_METRICS=$(cat /tmp/head_timing.json)
BASE_METRICS=$(cat /tmp/base_timing.json)
PR_NUMBER=$(cat /tmp/pr_number.txt)
hotpath profile-pr \
--head-metrics "$HEAD_METRICS" \
--base-metrics "$BASE_METRICS" \
export GITHUB_BASE_REF=$(cat /tmp/metrics/base_ref.txt)
export GITHUB_HEAD_REF=$(cat /tmp/metrics/head_ref.txt)
hotpath-utils profile-pr \
--head-metrics /tmp/metrics/head_timing.json \
--base-metrics /tmp/metrics/base_timing.json \
--github-token "$GH_TOKEN" \
--pr-number "$PR_NUMBER"
- name: Post allocation comparison comment
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
HEAD_METRICS=$(cat /tmp/head_alloc.json)
BASE_METRICS=$(cat /tmp/base_alloc.json)
PR_NUMBER=$(cat /tmp/pr_number.txt)
hotpath profile-pr \
--head-metrics "$HEAD_METRICS" \
--base-metrics "$BASE_METRICS" \
--github-token "$GH_TOKEN" \
--pr-number "$PR_NUMBER"
--pr-number "$(cat /tmp/metrics/pr_number.txt)" \
--benchmark-id "timing"

View file

@ -4,62 +4,57 @@ on:
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
permissions:
contents: read
jobs:
profile:
runs-on: ubuntu-latest
steps:
- name: Checkout PR HEAD
uses: actions/checkout@v6
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Run timing profiling on HEAD
- name: Create metrics directory
run: mkdir -p /tmp/metrics
- name: Head benchmark (timing)
env:
HOTPATH_JSON: "true"
run: |
cargo run --features='hotpath' 2>&1 | grep '^{"hotpath_profiling_mode"' > /tmp/head_timing.json
HOTPATH_OUTPUT_FORMAT: json
HOTPATH_OUTPUT_PATH: /tmp/metrics/head_timing.json
run: cargo run -p microfetch --release --features='hotpath'
- name: Run allocation profiling on HEAD
- name: Head benchmark (alloc)
env:
HOTPATH_JSON: "true"
run: |
cargo run --features='hotpath,hotpath-alloc' 2>&1 | grep '^{"hotpath_profiling_mode"' > /tmp/head_alloc.json
HOTPATH_OUTPUT_FORMAT: json
HOTPATH_OUTPUT_PATH: /tmp/metrics/head_alloc.json
run: cargo run -p microfetch --release --features='hotpath,hotpath-alloc'
- name: Checkout base branch
run: |
git checkout ${{ github.event.pull_request.base.sha }}
- name: Checkout base
run: git checkout ${{ github.event.pull_request.base.sha }}
- name: Run timing profiling on base
- name: Base benchmark (timing)
env:
HOTPATH_JSON: "true"
run: |
cargo run --features='hotpath' 2>&1 | grep '^{"hotpath_profiling_mode"' > /tmp/base_timing.json || echo '{}' > /tmp/base_timing.json
HOTPATH_OUTPUT_FORMAT: json
HOTPATH_OUTPUT_PATH: /tmp/metrics/base_timing.json
run: cargo run -p microfetch --release --features='hotpath' || echo '{}' > /tmp/metrics/base_timing.json
- name: Run allocation profiling on base
- name: Base benchmark (alloc)
env:
HOTPATH_JSON: "true"
run: |
cargo run --features='hotpath,hotpath-alloc' 2>&1 | grep '^{"hotpath_profiling_mode"' > /tmp/base_alloc.json || echo '{}' > /tmp/base_alloc.json
HOTPATH_OUTPUT_FORMAT: json
HOTPATH_OUTPUT_PATH: /tmp/metrics/base_alloc.json
run: cargo run -p microfetch --release --features='hotpath,hotpath-alloc' || echo '{}' > /tmp/metrics/base_alloc.json
- name: Save PR number
- name: Save PR metadata
run: |
echo '${{ github.event.pull_request.number }}' > /tmp/pr_number.txt
echo '${{ github.event.pull_request.number }}' > /tmp/metrics/pr_number.txt
echo '${{ github.base_ref }}' > /tmp/metrics/base_ref.txt
echo '${{ github.head_ref }}' > /tmp/metrics/head_ref.txt
- name: Upload profiling results
uses: actions/upload-artifact@v7
- uses: actions/upload-artifact@v4
with:
name: hotpath-results
path: |
/tmp/head_timing.json
/tmp/head_alloc.json
/tmp/base_timing.json
/tmp/base_alloc.json
/tmp/pr_number.txt
name: profile-metrics
path: /tmp/metrics/
retention-days: 1