Skip to content

Commit 17d51d5

Browse files
committed
fixup! fix(walltime): use mach_absolute_time for FIFO timestamps on macOS
1 parent 11a803f commit 17d51d5

3 files changed

Lines changed: 6 additions & 47 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ futures = "0.3.31"
6262
runner-shared = { path = "crates/runner-shared" }
6363
memtrack = { path = "crates/memtrack", default-features = false }
6464
exec-harness = { path = "crates/exec-harness" }
65+
instrument-hooks-bindings = { path = "crates/instrument-hooks-bindings" }
6566
ipc-channel = "0.18"
6667
shellexpand = { version = "3.1.1", features = ["tilde"] }
6768
addr2line = "0.25"
@@ -79,9 +80,6 @@ samply = { git = "https://github.com/AvalancheHQ/samply", branch = "codspeed" }
7980
[target.'cfg(target_os = "linux")'.dependencies]
8081
procfs = "0.17.0"
8182

82-
[target.'cfg(target_os = "macos")'.dependencies]
83-
mach2 = "0.4"
84-
8583
[dev-dependencies]
8684
temp-env = { version = "0.3.6", features = ["async_closure"] }
8785
insta = { version = "1.29.0", features = ["json", "redactions"] }

src/executor/shared/fifo.rs

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -175,39 +175,9 @@ impl RunnerFifo {
175175

176176
let mut integration = None;
177177

178-
let current_time = || {
179-
// Must match the clock used by instrument-hooks (`instrument_hooks_current_timestamp`)
180-
// so timestamps from this process and the benchmarked process are comparable.
181-
#[cfg(target_os = "macos")]
182-
{
183-
use mach2::mach_time;
184-
use std::sync::OnceLock;
185-
186-
static NANOS_PER_TICK: OnceLock<mach_time::mach_timebase_info> = OnceLock::new();
187-
188-
let nanos_per_tick = NANOS_PER_TICK.get_or_init(|| unsafe {
189-
let mut info = mach_time::mach_timebase_info::default();
190-
let errno = mach_time::mach_timebase_info(&mut info as *mut _);
191-
if errno != 0 || info.denom == 0 {
192-
info.numer = 1;
193-
info.denom = 1;
194-
};
195-
info
196-
});
197-
198-
let time = unsafe { mach_time::mach_absolute_time() };
199-
200-
time * nanos_per_tick.numer as u64 / nanos_per_tick.denom as u64
201-
}
202-
203-
#[cfg(not(target_os = "macos"))]
204-
{
205-
use nix::{sys::time::TimeValLike, time::clock_gettime};
206-
207-
let clock = nix::time::ClockId::CLOCK_MONOTONIC;
208-
clock_gettime(clock).unwrap().num_nanoseconds() as u64
209-
}
210-
};
178+
// Must match the clock used by the benchmarked process so timestamps
179+
// from both sides are comparable.
180+
let current_time = instrument_hooks_bindings::InstrumentHooks::current_timestamp;
211181

212182
let mut benchmark_started = false;
213183

0 commit comments

Comments
 (0)