feat(causal): wall-anchored timers — controller windows keep fixed wall length (RFC 007)
New timer anchor: insert_sleep_wall / scheduler::sleep_wall (exported) opt a Sleep entry out of the RFC 007 virtual-time shift, so it fires at its raw deadline regardless of injected delay. Featureless config is unchanged (the API exists but is identical to sleep). The causal controller's window/cooldown sleeps and the tsc_hz calibration sleep use it on the actor path (the OS-thread path was already wall). This fixes the controller's own sleeps dilating under its own injection — experiment windows stretched ~2x at 50% speedup (337ms -> 646ms injected/ window). Deltas were rate-normalized so results were unbiased; this fixes sweep cost, not bias. The general wall-anchored-timer-semantics jar item (user-facing opt-out) remains open; this lands the substrate. Test: wall_timer_ignores_injected_delay — wall entry fires at raw deadline while a virtual sibling in the same heap shifts. 13/13 causal, 34/34 binaries both feature configs.
This commit is contained in:
@@ -403,6 +403,28 @@ pub fn sleep(duration: std::time::Duration) {
|
||||
park_current();
|
||||
}
|
||||
|
||||
/// Like [`sleep`], but wall-anchored: under causal profiling (feature
|
||||
/// `smarm-causal`) the deadline is honoured in wall time instead of chasing
|
||||
/// injected virtual delay. Identical to [`sleep`] without the feature. For
|
||||
/// measurement machinery whose durations define wall time (the causal
|
||||
/// controller's windows, TSC calibration) — workload code wants [`sleep`].
|
||||
pub fn sleep_wall(duration: std::time::Duration) {
|
||||
let me = match current_pid() {
|
||||
Some(pid) => pid,
|
||||
None => panic!("sleep_wall() called outside an actor"),
|
||||
};
|
||||
let _np = NoPreempt::enter();
|
||||
let epoch = begin_wait();
|
||||
let deadline = crate::timer::deadline_from_now(duration);
|
||||
with_runtime(|inner| {
|
||||
match inner.timers.lock() {
|
||||
Ok(mut timers) => timers.insert_sleep_wall(deadline, me, epoch),
|
||||
Err(e) => panic!("smarm: timers lock poisoned (core corrupt): {e}"),
|
||||
}
|
||||
});
|
||||
park_current();
|
||||
}
|
||||
|
||||
pub fn insert_wait_timer(
|
||||
deadline: std::time::Instant,
|
||||
pid: Pid,
|
||||
|
||||
Reference in New Issue
Block a user