Wait the outrun test's late turn without holding the slot's lock

d1ff24ed49's test-only delay of the lowering thread's first turn slept inside `if let Some(late)
= lock(&self.state).late.take()`, whose guard lives through the block: the slot's state lock was
held for the whole 100 ms, so the program's thread, and the test's own reads of the slot, waited
for it, and the thread then took the first batch before the program reached the cap. The delay
made no late turn, and the negative control (the old read at the cap alone) passed 3 of 3 on
lavapipe at 2ce15a2092.

`LoweringSlot::wait_late` takes the delay under the lock and sleeps without it.

Test: on lavapipe (msi-laptop, --cfg m2v_cpu_icd) and MoltenVK (M3 Max, --cfg m2v_gpu), the test
and its negative control.

(cherry picked from commit ec37c03abb0ed8ca81ac89703c39c6989950a1f9)
This commit is contained in:
Anees Iqbal committed 2026-11-05 11:25:48 -08:00
1 parent f2fc42a95d
commit ba0d7625b4
1 file changed
+11 -3
@@ -360,9 +360,7 @@ impl LoweringSlot {
pub(super) fn lower_handed(&self) {
loop {
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
if let Some(late) = lock(&self.state).late.take() {
std::thread::sleep(late);
}
self.wait_late();
let (turn, ended) = {
let Some(_section) = exit_guard::enter() else {
// The process exits: the program's thread lowers what is handed.
@@ -661,6 +659,16 @@ impl LoweringSlot {
pub(crate) fn turn_late(&self, by: std::time::Duration) {
lock(&self.state).late = Some(by);
}
/// The lowering thread's wait before its turn at the slot where [`turn_late`](Self::turn_late)
/// asked for one: taken under the slot's lock and waited without it, so the program's calls
/// go on meanwhile.
fn wait_late(&self) {
let late = lock(&self.state).late.take();
if let Some(late) = late {
std::thread::sleep(late);
}
}
}
/// A program's encoder's slot, with the calls it logged and their checks (the module docs),