php-lsp 0.4.0

A PHP Language Server Protocol implementation
Documentation
name: Benchmarks

on:
  workflow_dispatch:
  # Run on pushes to main so gh-pages history stays fresh — every merged
  # PR updates the baseline the next comparison will use.
  push:
    branches: [main]
    paths:
      - 'src/**'
      - 'benches/**'
      - 'mir-*/**'
      - 'Cargo.toml'
      - 'Cargo.lock'
  # Phase H gate: run on PRs that touch perf-sensitive code. The
  # benchmark-action compares against gh-pages history with a 130 %
  # alert threshold, failing the PR on detected regression.
  pull_request:
    branches: [main]
    paths:
      - 'src/**'
      - 'benches/**'
      - 'mir-*/**'
      - 'Cargo.toml'
      - 'Cargo.lock'

jobs:
  bench:
    name: Run criterion benchmarks
    # ubuntu-latest-4-cores gives a dedicated 4-core instance which reduces
    # run-to-run variance compared to the shared 2-core ubuntu-latest runners.
    # The alert threshold is kept at 130 % to absorb remaining CI noise.
    runs-on: ubuntu-latest-4-cores
    timeout-minutes: 60
    permissions:
      contents: write

    steps:
      - uses: actions/checkout@v6

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo registry
        uses: actions/cache@v5
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-bench-

      # Required by the `*_laravel_framework` benches in requests/index/
      # semantic — they skip silently if the fixture is missing, so
      # without this step CI would under-report coverage on salsa's
      # cross-file paths (the ones most likely to regress).
      - name: Set up Laravel fixture
        run: bash scripts/setup_laravel_fixture.sh

      - name: Run benchmarks
        run: cargo bench -- --output-format bencher | tee output.txt

      - name: Store benchmark result
        uses: benchmark-action/github-action-benchmark@v1.22.0
        with:
          tool: cargo
          output-file-path: output.txt
          github-token: ${{ secrets.GITHUB_TOKEN }}
          # Alert threshold accounts for natural variance on shared CI runners (~15-30%).
          # 130% flags only genuine regressions and avoids constant noise.
          alert-threshold: "130%"
          comment-on-alert: true
          fail-on-alert: true
          # Push results to gh-pages branch to track history.
          auto-push: ${{ github.ref == 'refs/heads/main' }}

      - name: Upload criterion HTML reports
        uses: actions/upload-artifact@v7
        with:
          name: criterion-${{ github.sha }}
          path: target/criterion/
          retention-days: 90