Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/master_benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Master Benchmarks

on:
push:
branches: master
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
clang: "17"
php_version: "8.4"

jobs:
run_benchmarks:
name: Run Master Benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php_version }}
env:
debug: true
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v5
with:
path: ${{ runner.temp }}/llvm-${{ env.clang }}
key: ubuntu-latest-llvm-${{ env.clang }}
- name: Setup LLVM & Clang
uses: KyleMayes/install-llvm-action@v2
with:
version: ${{ env.clang }}
directory: ${{ runner.temp }}/llvm-${{ env.clang }}
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Configure Clang
run: |
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/lib" >> $GITHUB_ENV
- name: Install Valgrind
run: sudo apt-get update && sudo apt-get install -y valgrind
- uses: taiki-e/install-action@cargo-binstall
- name: Install gungraun-runner
run: |
version=$(cargo metadata --manifest-path ./benches/Cargo.toml --format-version=1 |\
jq '.packages[] | select(.name == "gungraun").version' |\
tr -d '"'
)
cargo binstall --no-confirm --force gungraun-runner --version $version
echo "GUNGRAUN_RUNNER=$(which gungraun-runner)" >> $GITHUB_ENV
- name: Run Benchmarks
run: cargo bench --manifest-path ./benches/Cargo.toml > benchmark_results.txt
- uses: bencherdev/bencher@main
- name: Track Benchmarks with Bencher
run: |
bencher run \
--host 'https://bencher.php.rs/api' \
--project ext-php-rs \
--token '${{ secrets.BENCHER_API_TOKEN }}' \
--branch master \
--testbed "$(php --version | head -n 1)" \
--err \
--adapter rust_gungraun \
--github-actions '${{ secrets.GITHUB_TOKEN }}' \
--file "./benchmark_results.txt"
20 changes: 20 additions & 0 deletions .github/workflows/pr_benchmarks_archive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Archive PR Benchmark Branch

on:
pull_request_target:
types: [closed]

jobs:
archive_fork_pr_branch:
name: Archive closed PR branch with Bencher
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: bencherdev/bencher@main
- name: Archive closed fork PR branch with Bencher
run: |
bencher archive \
--host 'https://bencher.php.rs/api' \
--project ext-php-rs \
--token '${{ secrets.BENCHER_API_TOKEN }}' \
--branch "$GITHUB_HEAD_REF"
85 changes: 85 additions & 0 deletions .github/workflows/pr_benchmarks_run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Run Benchmarks

on:
pull_request:
types: [opened, reopened, synchronize]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
clang: "17"
php_version: "8.4"

jobs:
run_benchmarks:
name: Run PR Benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.php_version }}
env:
debug: true
- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Cache LLVM and Clang
id: cache-llvm
uses: actions/cache@v5
with:
path: ${{ runner.temp }}/llvm-${{ env.clang }}
key: ubuntu-latest-llvm-${{ env.clang }}
- name: Setup LLVM & Clang
uses: KyleMayes/install-llvm-action@v2
with:
version: ${{ env.clang }}
directory: ${{ runner.temp }}/llvm-${{ env.clang }}
cached: ${{ steps.cache-llvm.outputs.cache-hit }}
- name: Configure Clang
run: |
echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ env.clang }}/lib" >> $GITHUB_ENV
- name: Install Valgrind
run: sudo apt-get update && sudo apt-get install -y valgrind
- uses: taiki-e/install-action@cargo-binstall
- name: Install gungraun-runner
run: |
version=$(cargo metadata --manifest-path ./benches/Cargo.toml --format-version=1 |\
jq '.packages[] | select(.name == "gungraun").version' |\
tr -d '"'
)
cargo binstall --no-confirm --force gungraun-runner --version $version
echo "GUNGRAUN_RUNNER=$(which gungraun-runner)" >> $GITHUB_ENV
- name: Run Benchmarks
run: cargo bench --manifest-path ./benches/Cargo.toml > benchmark_results.txt
env:
NO_COLOR: "1"
- name: Benchmark Summary
run: |
echo '## Benchmark Results' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
sed 's/\x1b\[[0-9;]*m//g' benchmark_results.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Upload Benchmark Results
uses: actions/upload-artifact@v6
with:
name: benchmark_results.txt
path: ./benchmark_results.txt
- name: Save testbed name
run: php --version | head -n 1 > testbed.txt
- name: Upload Testbed
uses: actions/upload-artifact@v6
with:
name: testbed.txt
path: ./testbed.txt
- name: Upload Pull Request Event
uses: actions/upload-artifact@v6
with:
name: event.json
path: ${{ github.event_path }}
64 changes: 64 additions & 0 deletions .github/workflows/pr_benchmarks_upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Upload PR Benchmark Results

on:
workflow_run:
workflows: [Run Benchmarks]
types: [completed]

jobs:
upload_benchmarks:
if: github.event.workflow_run.conclusion == 'success'
permissions:
pull-requests: write
runs-on: ubuntu-latest
env:
BENCHMARK_RESULTS: benchmark_results.txt
PR_EVENT: event.json
steps:
- name: Download Benchmark Results
uses: dawidd6/action-download-artifact@v6
with:
name: ${{ env.BENCHMARK_RESULTS }}
run_id: ${{ github.event.workflow_run.id }}
- name: Download PR Event
uses: dawidd6/action-download-artifact@v6
with:
name: ${{ env.PR_EVENT }}
run_id: ${{ github.event.workflow_run.id }}
- name: Download Testbed
uses: dawidd6/action-download-artifact@v6
with:
name: testbed.txt
run_id: ${{ github.event.workflow_run.id }}
- name: Export PR Event Data
uses: actions/github-script@v7
with:
script: |
let fs = require('fs');
let prEvent = JSON.parse(fs.readFileSync(process.env.PR_EVENT, {encoding: 'utf8'}));
core.exportVariable("PR_HEAD", prEvent.pull_request.head.ref);
core.exportVariable("PR_HEAD_SHA", prEvent.pull_request.head.sha);
core.exportVariable("PR_BASE", prEvent.pull_request.base.ref);
core.exportVariable("PR_BASE_SHA", prEvent.pull_request.base.sha);
core.exportVariable("PR_NUMBER", prEvent.number);
let testbed = fs.readFileSync('testbed.txt', {encoding: 'utf8'}).trim();
core.exportVariable("TESTBED", testbed);
- uses: bencherdev/bencher@main
- name: Track Benchmarks with Bencher
run: |
bencher run \
--host 'https://bencher.php.rs/api' \
--project ext-php-rs \
--token '${{ secrets.BENCHER_API_TOKEN }}' \
--branch "$PR_HEAD" \
--hash "$PR_HEAD_SHA" \
--start-point "$PR_BASE" \
--start-point-hash "$PR_BASE_SHA" \
--start-point-clone-thresholds \
--start-point-reset \
--testbed "$TESTBED" \
--err \
--adapter rust_gungraun \
--github-actions '${{ secrets.GITHUB_TOKEN }}' \
--ci-number "$PR_NUMBER" \
--file "$BENCHMARK_RESULTS"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Cargo.lock
/tmp
/.direnv
expand.rs
callgrind.out.*
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ authors = [
]
edition = "2024"
categories = ["api-bindings"]
exclude = ["/.github", "/.crates"]
exclude = ["/.github", "/.crates", "/benches"]
autotests = false

[dependencies]
Expand Down
2 changes: 2 additions & 0 deletions benches/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[profile.bench]
debug = true
3 changes: 3 additions & 0 deletions benches/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/target
/ext/target
callgrind.out.*
22 changes: 22 additions & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "benches"
version = "0.1.0"
edition = "2024"
publish = false

[dependencies]
gungraun = "0.17.0"

[features]
default = ["enum", "runtime", "closure"]
enum = []
anyhow = []
runtime = []
closure = []
static = []

[[bench]]
name = "binary_bench"
harness = false

[workspace]
Loading
Loading