Skip to content

Replace deprecated Rust crate libipld with cbor4ii #227

Replace deprecated Rust crate libipld with cbor4ii

Replace deprecated Rust crate libipld with cbor4ii #227

Workflow file for this run

name: CodSpeed benchmarks
on:
push:
branches:
- "main"
pull_request:
workflow_dispatch: # allows CodSpeed to trigger backtest
permissions:
contents: read
env:
UV_FROZEN: true
UV_PYTHON: 3.13 # use the latest version of Python because it is faster FIXME(@MarshalX): update to 3.14 when CodSpeed supports it
RUST_VERSION: "1.90.0"
jobs:
benchmarks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5 # required for correct CodSpeed integration
with:
python-version: ${{ env.UV_PYTHON }}
- name: Install UV.
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Install rust.
id: rust-toolchain
uses: dtolnay/rust-toolchain@master
with:
components: llvm-tools
toolchain: ${{ env.RUST_VERSION }}
- name: Cache rust.
uses: Swatinem/rust-cache@v2
- name: Build wheel with profile generation.
uses: PyO3/maturin-action@v1
with:
manylinux: auto
args: --release --out pgo-wheel --interpreter ${{ env.UV_PYTHON }}
rust-toolchain: ${{ env.RUST_VERSION }}
docker-options: -e CI
env:
RUSTFLAGS: "-Cprofile-generate=${{ github.workspace }}/profdata"
- name: Gather PGO data.
run: |
uv sync --group testing
uv pip install libipld --no-index --no-deps --find-links pgo-wheel --force-reinstall
uv run pytest . --benchmark-enable
- name: Prepare merged PGO data.
run: rustup run ${{ env.RUST_VERSION }} bash -c '$RUSTUP_HOME/toolchains/$RUSTUP_TOOLCHAIN/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/profdata'
- name: Build PGO-optimized wheel.
uses: PyO3/maturin-action@v1
with:
manylinux: auto
args: --release --out dist --interpreter ${{ env.UV_PYTHON }}
rust-toolchain: ${{ env.RUST_VERSION }}
docker-options: -e CI
env:
RUSTFLAGS: "-Cprofile-use=${{ github.workspace }}/merged.profdata"
- name: Find PGO built wheel.
id: pgo-wheel
run: echo "path=$(ls dist/*.whl)" | tee -a "$GITHUB_OUTPUT"
- name: Install PGO wheel.
run: uv pip install ${{ steps.pgo-wheel.outputs.path }} --force-reinstall
- name: Run CodSpeed benchmarks.
uses: CodSpeedHQ/action@v4
with:
mode: instrumentation
token: ${{ secrets.CODSPEED_TOKEN }}
run: uv run --group=codspeed pytest . --codspeed -n auto