From e24bedc824b795b11fc7cb23cece682d918b40df Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Mon, 13 Apr 2026 18:15:36 +0200 Subject: [PATCH 1/3] feat: add aarch64-apple-darwin artifacts to the release --- .github/workflows/release.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2bd00512..baacf29d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ permissions: contents: write jobs: - build-musl-binaries: + build-binaries: strategy: matrix: include: @@ -18,6 +18,8 @@ jobs: runner: ubuntu-24.04 - target: aarch64-unknown-linux-musl runner: codspeedhq-arm64-ubuntu-24.04 + - target: aarch64-apple-darwin + runner: macos-latest runs-on: ${{ matrix.runner }} steps: @@ -30,6 +32,7 @@ jobs: targets: ${{ matrix.target }} - name: Install musl tools + if: endsWith(matrix.target, '-linux-musl') run: sudo apt-get update && sudo apt-get install -y musl-tools - run: cargo build --locked --release --bin cargo-codspeed --target ${{ matrix.target }} @@ -42,7 +45,7 @@ jobs: if-no-files-found: error publish: - needs: build-musl-binaries + needs: build-binaries runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -81,6 +84,7 @@ jobs: target: - x86_64-unknown-linux-musl - aarch64-unknown-linux-musl + - aarch64-apple-darwin runs-on: ubuntu-latest steps: From 8bbbe168bbaab9b93b60567594b2d4237e833b80 Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Tue, 14 Apr 2026 10:30:27 +0200 Subject: [PATCH 2/3] ci: add a macos integration test --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5ee2127..b7da79fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -207,6 +207,37 @@ jobs: run: cargo codspeed run mode: walltime + walltime-macos-test: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: moonrepo/setup-rust@v1 + with: + cache-target: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - run: cargo install --path crates/cargo-codspeed --locked + + - name: Build the benchmarks + run: | + # Remove the cargo config else it forces instrumentation mode + rm -f .cargo/config.toml + cargo codspeed build -p codspeed-divan-compat -m walltime + + - name: Run the benchmarks + uses: CodSpeedHQ/action@main + env: + MY_ENV_VAR: "YES" + CODSPEED_SKIP_UPLOAD: "true" + with: + run: cargo codspeed run -p codspeed-divan-compat + mode: walltime + # TODO: Remove this once the runner has been released with macos support + runner-version: branch:main + musl-build-check: strategy: matrix: @@ -243,6 +274,7 @@ jobs: - msrv-check - analysis-integration-test - walltime-integration-test + - walltime-macos-test - musl-build-check steps: - uses: re-actors/alls-green@release/v1 From fa2bd15d53ba2ad07ad63712485df90b23511811 Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Wed, 15 Apr 2026 18:09:47 +0200 Subject: [PATCH 3/3] chore: bump use i32 for pid in instrument-hooks api --- crates/codspeed/instrument-hooks | 2 +- crates/codspeed/src/instrument_hooks/bindings.rs | 12 ++++++++---- crates/codspeed/src/instrument_hooks/mod.rs | 6 +++--- .../codspeed/src/instrument_hooks/update-bindings.sh | 3 ++- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/crates/codspeed/instrument-hooks b/crates/codspeed/instrument-hooks index 0c971823..ecdf31a3 160000 --- a/crates/codspeed/instrument-hooks +++ b/crates/codspeed/instrument-hooks @@ -1 +1 @@ -Subproject commit 0c971823b17cb5a3bbd0cce4411cbee2c6fe4317 +Subproject commit ecdf31a3afd0fb879823e40df65129ec823d374b diff --git a/crates/codspeed/src/instrument_hooks/bindings.rs b/crates/codspeed/src/instrument_hooks/bindings.rs index 428a2e69..1bca3e02 100644 --- a/crates/codspeed/src/instrument_hooks/bindings.rs +++ b/crates/codspeed/src/instrument_hooks/bindings.rs @@ -4,7 +4,11 @@ pub const MARKER_TYPE_SAMPLE_START: u32 = 0; pub const MARKER_TYPE_SAMPLE_END: u32 = 1; pub const MARKER_TYPE_BENCHMARK_START: u32 = 2; pub const MARKER_TYPE_BENCHMARK_END: u32 = 3; -pub type InstrumentHooks = *mut u64; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct InstrumentHooks { + _unused: [u8; 0], +} extern "C" { pub fn instrument_hooks_init() -> *mut InstrumentHooks; } @@ -44,7 +48,7 @@ extern "C" { extern "C" { pub fn instrument_hooks_add_marker( arg1: *mut InstrumentHooks, - pid: u32, + pid: i32, marker_type: u8, timestamp: u64, ) -> u8; @@ -56,7 +60,7 @@ pub const instrument_hooks_feature_t_FEATURE_DISABLE_CALLGRIND_MARKERS: instrume 0; pub type instrument_hooks_feature_t = ::std::os::raw::c_uint; extern "C" { - pub fn instrument_hooks_set_feature(feature: instrument_hooks_feature_t, enabled: bool); + pub fn instrument_hooks_set_feature(feature: u64, enabled: bool); } extern "C" { pub fn instrument_hooks_set_environment( @@ -76,5 +80,5 @@ extern "C" { ) -> u8; } extern "C" { - pub fn instrument_hooks_write_environment(arg1: *mut InstrumentHooks, pid: u32) -> u8; + pub fn instrument_hooks_write_environment(arg1: *mut InstrumentHooks, pid: i32) -> u8; } diff --git a/crates/codspeed/src/instrument_hooks/mod.rs b/crates/codspeed/src/instrument_hooks/mod.rs index cebe9b3d..b77ef426 100644 --- a/crates/codspeed/src/instrument_hooks/mod.rs +++ b/crates/codspeed/src/instrument_hooks/mod.rs @@ -129,7 +129,7 @@ mod linux_impl { #[inline(always)] pub fn add_benchmark_timestamps(&self, start: u64, end: u64) { - let pid = std::process::id(); + let pid = std::process::id() as i32; unsafe { ffi::instrument_hooks_add_marker( @@ -191,7 +191,7 @@ mod linux_impl { } pub fn write_environment(&self) -> Result<(), u8> { - let pid = std::process::id(); + let pid = std::process::id() as i32; let result = unsafe { ffi::instrument_hooks_write_environment(self.0, pid) }; if result == 0 { Ok(()) @@ -203,7 +203,7 @@ mod linux_impl { pub fn disable_callgrind_markers() { unsafe { ffi::instrument_hooks_set_feature( - ffi::instrument_hooks_feature_t_FEATURE_DISABLE_CALLGRIND_MARKERS, + ffi::instrument_hooks_feature_t_FEATURE_DISABLE_CALLGRIND_MARKERS.into(), true, ) }; diff --git a/crates/codspeed/src/instrument_hooks/update-bindings.sh b/crates/codspeed/src/instrument_hooks/update-bindings.sh index 0dd97f93..60d3ab41 100755 --- a/crates/codspeed/src/instrument_hooks/update-bindings.sh +++ b/crates/codspeed/src/instrument_hooks/update-bindings.sh @@ -7,4 +7,5 @@ bindgen "$SCRIPT_DIR/../../instrument-hooks/includes/core.h" \ -o "$SCRIPT_DIR/bindings.rs" \ --rust-target 1.74 \ --allowlist-function "instrument_hooks_.*" \ - --allowlist-var "MARKER_TYPE_.*" + --allowlist-var "MARKER_TYPE_.*" \ + --allowlist-type "instrument_hooks_feature_t"