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
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,37 @@ jobs:
run: cargo codspeed run
mode: walltime

walltime-macos-test:
Comment thread
GuillaumeLagrange marked this conversation as resolved.
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:
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ permissions:
contents: write

jobs:
build-musl-binaries:
build-binaries:
strategy:
matrix:
include:
- target: x86_64-unknown-linux-musl
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:
Expand All @@ -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 }}
Expand All @@ -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
Expand Down Expand Up @@ -81,6 +84,7 @@ jobs:
target:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
- aarch64-apple-darwin

runs-on: ubuntu-latest
steps:
Expand Down
12 changes: 8 additions & 4 deletions crates/codspeed/src/instrument_hooks/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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(
Expand All @@ -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;
}
6 changes: 3 additions & 3 deletions crates/codspeed/src/instrument_hooks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(())
Expand All @@ -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,
)
};
Expand Down
3 changes: 2 additions & 1 deletion crates/codspeed/src/instrument_hooks/update-bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading