queue_quiet: the burst's end read before it ends, on the wait's own clock
a_wait_ends_once_a_burst_that_began_after_it_ended failed on lavapipe's suite under a loaded gem10 (m3-max-12030): the wait returned before the burst's end plus SETTLE, as the test reads it. The test read that end with Instant::now() after QueueQuiet::ended had stored it, so a pause of the burst's thread between the two of more than SETTLE (1 ms) put the end it read past the one the wait saw; and it compared Instant (CLOCK_MONOTONIC) against the wait's host clock (CLOCK_MONOTONIC_RAW on Linux, CLOCK_UPTIME_RAW on macOS). The thread now reads the host's clock (gpu_time::host_nanos, the clock ended() stores) before ended(), and the waiter reads it as the wait returns: the end the wait saw is at or after the one read, so the wait's return is at least SETTLE past it whatever the pauses. The wait itself is unchanged. Verification: the test with a 3 ms pause between ended() and the timestamp fails at the old form and passes at this one, in the job that follows. (cherry picked from commit 3c6c921005c470f727804c7b05ee8a1209832b26)
This commit is contained in:
1 parent
e0a6edd099
commit
880a1f0c08
1 file changed
+7
-3
@@ -7,6 +7,7 @@
|
||||
//! and what each row holds is how the wait ended.
|
||||
|
||||
use crate::device::queue_quiet::{QueueQuiet, Waited, SETTLE};
|
||||
use crate::gpu_time;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
/// A bound longer than any pause a loaded host puts between two steps here.
|
||||
@@ -27,19 +28,22 @@ fn a_wait_ends_once_a_burst_that_began_after_it_ended() {
|
||||
quiet.began();
|
||||
quiet.ended();
|
||||
std::thread::scope(|scope| {
|
||||
// The host's clock as the burst's use ends, read before it ends on the clock the wait
|
||||
// reads, so that no pause between the two can put it past the end the wait saw.
|
||||
let ended = scope.spawn(|| {
|
||||
std::thread::sleep(Duration::from_millis(20));
|
||||
quiet.began();
|
||||
std::thread::sleep(Duration::from_millis(5));
|
||||
let ending = gpu_time::host_nanos();
|
||||
quiet.ended();
|
||||
Instant::now()
|
||||
ending
|
||||
});
|
||||
let waited = quiet.wait_after_burst(LONG, || false);
|
||||
let returned = Instant::now();
|
||||
let returned = gpu_time::host_nanos();
|
||||
let ended = ended.join().unwrap();
|
||||
assert_eq!(waited, Waited::AfterBurst);
|
||||
assert!(
|
||||
returned >= ended + SETTLE,
|
||||
returned >= ended + SETTLE.as_nanos() as u64,
|
||||
"the wait ended before the burst settled"
|
||||
);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user