Time the queue-switch check's last steps in its teardown test
teardown_threads::a_running_queue_switch_check_leaves_the_device_to_the_
program_s_thread (de2554f1ac) holds the teardown's wait for the stopped
check under RELEASE, 16 ms. On the RTX 5080 Laptop GPU (b5080 entry
nvlane-holds-td, three runs, beside the runtime suite at -j 6) it waited
13.4 ms, 26.5 ms and 14.3 ms: one run over the bound, and the others
near it. The wait holds the test hook's release (a 1 ms poll), the
check's wake, the release of its Vulkan objects (three timelines, a
timestamp pool, a command pool of 96 command buffers) and the drop of
its shares of the device's parts; nothing says which costs the rest.
The check now records, under the device tests' cfgs only, how long its
objects' release and its shares' drop took, and the test prints them
beside the wait. No behaviour changes outside the test cfgs.
Verified: cargo fmt. The 5080 runtime leg of the lane fixes batch prints
the split.
(cherry picked from commit cdfd1b9bf44c40ee109f785b6ded89a514069a2a)
This commit is contained in:
1 parent
f14dda89f3
commit
2d0ed8f311
3 files changed
+35
-1
No files matched your search
@@ -349,6 +349,10 @@ pub(crate) struct QueueSwitch {
|
||||
/// (`tests/teardown_threads.rs`).
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) held: crate::freed_memory::held::Held,
|
||||
/// The crate's device tests' timings of the check's last two steps, in nanoseconds: the
|
||||
/// release of its Vulkan objects, and the drop of its shares of the device's parts.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
last_steps: [AtomicU64; 2],
|
||||
}
|
||||
|
||||
impl QueueSwitch {
|
||||
@@ -368,6 +372,8 @@ impl QueueSwitch {
|
||||
stop_waited: AtomicU64::new(0),
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
held: Default::default(),
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
last_steps: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,6 +454,22 @@ impl QueueSwitch {
|
||||
}
|
||||
}
|
||||
|
||||
/// Record that the check's last step `step` (0 its objects' release, 1 its shares' drop) ran
|
||||
/// from `from` until now.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) fn timed_step(&self, step: usize, from: Instant) {
|
||||
let nanos = u64::try_from(from.elapsed().as_nanos()).unwrap_or(u64::MAX);
|
||||
self.last_steps[step].store(nanos.max(1), Ordering::Release);
|
||||
}
|
||||
|
||||
/// How long the check's last two steps took ([`timed_step`](Self::timed_step)).
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) fn last_steps(&self) -> [Duration; 2] {
|
||||
(self.last_steps)
|
||||
.each_ref()
|
||||
.map(|t| Duration::from_nanos(t.load(Ordering::Acquire)))
|
||||
}
|
||||
|
||||
/// Let the tests' hold of the check go once the device's teardown began, or once it was let
|
||||
/// go already.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
|
||||
@@ -109,7 +109,11 @@ pub(crate) fn start(device: &Device) -> bool {
|
||||
let switch = Arc::clone(&parts.switch);
|
||||
run(&parts);
|
||||
// Its shares go before the teardown that waits for it goes on.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
let dropping = Instant::now();
|
||||
drop(parts);
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
switch.timed_step(1, dropping);
|
||||
switch.ended();
|
||||
});
|
||||
if spawned.is_err() {
|
||||
@@ -230,7 +234,11 @@ fn measure(parts: &Parts, pair: (usize, usize)) -> Result<Option<(i64, i64)>, Er
|
||||
Ok(_) => Ok(None),
|
||||
Err(error) => Err(error),
|
||||
};
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
let releasing = Instant::now();
|
||||
objects.release(parts);
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
parts.switch.timed_step(0, releasing);
|
||||
gaps
|
||||
}
|
||||
|
||||
|
||||
@@ -612,7 +612,11 @@ fn a_running_queue_switch_check_leaves_the_device_to_the_program_s_thread() {
|
||||
let waited = switch
|
||||
.stop_waited()
|
||||
.expect("the teardown waited for the running check");
|
||||
println!("the last drop took {dropped:?}, of which the wait for the check {waited:?}");
|
||||
let [release, shares] = switch.last_steps();
|
||||
println!(
|
||||
"the last drop took {dropped:?}, of which the wait for the check {waited:?} (its objects' \
|
||||
release {release:?}, its shares' drop {shares:?})"
|
||||
);
|
||||
assert!(
|
||||
waited < RELEASE,
|
||||
"the teardown waited {waited:?} for the check"
|
||||
|
||||
Reference in new issue
Block a user