rt test: a burst's idle recorders past the warm ones release their memory (red)
The device keeps up to 64 idle recorders, and every reset that idles one keeps its pool's memory and its hazard table. So a burst of command buffers leaves 64 command pools holding the memory of the largest command buffers they recorded, plus their hazard tables, until the device goes. The test: 64 and 8 recorders, each with a command buffer recorded and a hazard table marked, are given back. The first 48 (WARM) should keep their memory and tables, and the other 16 should be idle with both released. Taking the 48 again should leave the released ones idle, and giving them back should make them warm again. Taking every idle one records into the released ones as well, and giving them back should leave the same split. The test seams are cfg(test): WARM, the idle accessor (kept and released, each with how many hold a table) and Hazards::holds_table. Expected red today: the burst leaves 64 idle that kept their memory and tables, and none released.
This commit is contained in:
1 parent
d9054b5164
commit
7a2a2247f8
4 files changed
+102
-1
No files matched your search
@@ -141,6 +141,12 @@ impl Hazards {
|
||||
self.read_wild
|
||||
}
|
||||
|
||||
/// For the device tests: whether the sets hold a table of marks.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) fn holds_table(&self) -> bool {
|
||||
self.marks.capacity() + self.own.capacity() > 0
|
||||
}
|
||||
|
||||
/// Starts both sets again, at a barrier.
|
||||
pub(crate) fn clear(&mut self) {
|
||||
if self.generation == u32::MAX {
|
||||
|
||||
@@ -11,7 +11,12 @@ use ash::vk;
|
||||
use std::sync::Mutex;
|
||||
|
||||
/// The most idle pools the device keeps; one given back past them is destroyed.
|
||||
const IDLE_MAX: usize = 64;
|
||||
pub(crate) const IDLE_MAX: usize = 64;
|
||||
|
||||
/// For the device tests: the idle pools that keep their memory through the reset that idles them;
|
||||
/// today every idle pool keeps it.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) const WARM: usize = 48;
|
||||
|
||||
/// A command pool and the command buffers allocated from it so far, the first `used` of them
|
||||
/// recording or recorded, and the hazard sets of the Metal command buffer recording with it,
|
||||
@@ -223,6 +228,16 @@ impl Recorders {
|
||||
}
|
||||
}
|
||||
|
||||
/// For the device tests: the idle recorders whose pools kept their memory at the reset that
|
||||
/// idled them, and those whose pools released it, each with how many of them hold a hazard
|
||||
/// table.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) fn idle(&self) -> [(usize, usize); 2] {
|
||||
let idle = lock(&self.idle);
|
||||
let tables = idle.iter().filter(|r| r.hazards.holds_table()).count();
|
||||
[(idle.len(), tables), (0, 0)]
|
||||
}
|
||||
|
||||
/// At teardown: destroys every idle recorder.
|
||||
pub(crate) fn destroy_all(&mut self, device: &ash::Device) {
|
||||
let idle = self
|
||||
|
||||
@@ -128,6 +128,7 @@ mod readback;
|
||||
pub(crate) mod real_size;
|
||||
mod real_size_overs;
|
||||
mod real_size_renders;
|
||||
mod recorders;
|
||||
mod refusal_basis;
|
||||
mod render;
|
||||
mod resolve;
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
//! The device's idle recorders (`crate::record`), on every device of the cfg's kind: a burst of
|
||||
//! recorders past `IDLE_MAX`, each with a command buffer recorded and a hazard table, given back,
|
||||
//! leaves `WARM` idle that kept their pools' memory and their tables, and the rest up to
|
||||
//! `IDLE_MAX` idle with both released; the reaper destroys those past `IDLE_MAX`. Recorders taken
|
||||
//! within the warm ones are taken from them and come back among them, and the released ones record
|
||||
//! again.
|
||||
|
||||
#[cfg(any(m2v_gpu, m2v_cpu_icd))]
|
||||
mod on_device {
|
||||
use crate::device::Core;
|
||||
use crate::hazard::Access;
|
||||
use crate::record::{self, Recorder, IDLE_MAX, WARM};
|
||||
use crate::tests::command::on_device::each_device;
|
||||
|
||||
/// A resource id each recorder marks, so its hazard table holds 4,096 marks.
|
||||
const ID: u32 = 4095;
|
||||
|
||||
/// `count` recorders, each with a command buffer recorded and ended, and [`ID`] marked.
|
||||
fn recorded(core: &Core, count: usize) -> Vec<Recorder> {
|
||||
(0..count)
|
||||
.map(|_| {
|
||||
let mut recorder = core.recorders.take(&core.device).expect("a recorder");
|
||||
let buffer = recorder.next(&core.device).expect("a command buffer");
|
||||
recorder.hazards.mark(ID, Access::Write);
|
||||
record::end(&core.device, buffer, false, &[], None, &core.counters)
|
||||
.expect("the command buffer ended");
|
||||
recorder
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn give_back(core: &Core, recorders: Vec<Recorder>) {
|
||||
for recorder in recorders {
|
||||
core.recorders.give_back(core, recorder);
|
||||
}
|
||||
}
|
||||
|
||||
/// A burst of [`IDLE_MAX`] and 8 recorders, given back: the first [`WARM`] kept their memory and
|
||||
/// tables, the rest up to `IDLE_MAX` released both. Taking the warm ones again leaves the
|
||||
/// released ones idle, and giving them back makes them warm again; taking every idle one
|
||||
/// records into the released ones too, and their give-back leaves the same split.
|
||||
#[test]
|
||||
fn a_burst_s_recorders_past_the_warm_ones_release_their_memory() {
|
||||
each_device("recorders_burst", |name, _, device| {
|
||||
let core = device.core();
|
||||
core.pool.await_internals();
|
||||
let cold = IDLE_MAX - WARM;
|
||||
give_back(core, recorded(core, IDLE_MAX + 8));
|
||||
assert_eq!(
|
||||
core.recorders.idle(),
|
||||
[(WARM, WARM), (cold, 0)],
|
||||
"{name}: the burst given back (kept, with tables; released, with tables)"
|
||||
);
|
||||
let warm = recorded(core, WARM);
|
||||
assert_eq!(
|
||||
core.recorders.idle(),
|
||||
[(0, 0), (cold, 0)],
|
||||
"{name}: the warm ones taken"
|
||||
);
|
||||
give_back(core, warm);
|
||||
assert_eq!(
|
||||
core.recorders.idle(),
|
||||
[(WARM, WARM), (cold, 0)],
|
||||
"{name}: the warm ones given back"
|
||||
);
|
||||
give_back(core, recorded(core, IDLE_MAX));
|
||||
assert_eq!(
|
||||
core.recorders.idle(),
|
||||
[(WARM, WARM), (cold, 0)],
|
||||
"{name}: every idle one taken and given back"
|
||||
);
|
||||
println!(
|
||||
"recorders burst: {name}: {} given back, {WARM} idle kept their memory, {cold} \
|
||||
released it",
|
||||
IDLE_MAX + 8
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user