Reclaim bench: each phase's pooled blocks made and freed, in bytes, and why they were freed
Test-side counters of the bytes of the pooled blocks added to and freed from their pools, and of the blocks made ahead and freed unused. Each phase prints the blocks made and freed with their bytes, those made ahead and freed unused, and the pooled frees by cause (emptied, stale, for room): the churn a guest's scroll showed with small blocks. What they read on a Radeon 780M (job 12560, two runs each, identical in both), per phase, blocks made (MiB) and made ahead and freed unused: - Images one a frame, 16 MiB blocks: RT 1987 64 (1024) and 64 (1024), none unused; RT 1991 and the change before this one, quiet 64 (1024), pressed 73 (1168) with 9 (144 MiB) unused. - Mixed sizes, 16 MiB blocks: RT 1987 36 (576) both phases; RT 1991 and after, pressed 45 (720) with 9 unused. - Bursts, 16 MiB blocks: as images one a frame. - The 64 MiB arms: 13 or 14 blocks (832 or 896 MiB) a phase at every tree, none unused. No phase freed an emptied block or one for room. The 9 unused blocks a device are the rest of a block's worth queued behind each kept pool's first block (the next change). The 64 blocks of 16 MiB against 13 of 64 MiB for the same 192 textures are their packing: three to a 16 MiB block, fifteen to a 64 MiB one. (cherry picked from commit 2bbb07158444ddfd2e6309bdcd11aa471573e121)
This commit is contained in:
1 parent
40831926fd
commit
5545b2eb51
2 files changed
+68
-4
No files matched your search
@@ -857,6 +857,11 @@ pub(super) struct Pool<T> {
|
||||
/// The pooled blocks added and freed so far ([`Pool::turnover`]).
|
||||
made: u64,
|
||||
freed: u64,
|
||||
/// Their bytes, for the crate's device tests ([`Pool::turnover_bytes`]).
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
made_bytes: u64,
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
freed_bytes: u64,
|
||||
/// The bytes of its live blocks with nothing placed in them: the empty blocks it keeps
|
||||
/// ([`Pool::kept_bytes`]).
|
||||
kept_bytes: u64,
|
||||
@@ -912,6 +917,10 @@ impl<T> Default for Pool<T> {
|
||||
visited: 0,
|
||||
made: 0,
|
||||
freed: 0,
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
made_bytes: 0,
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
freed_bytes: 0,
|
||||
kept_bytes: 0,
|
||||
grew: None,
|
||||
large: None,
|
||||
@@ -1041,6 +1050,10 @@ impl<T> Pool<T> {
|
||||
placed_to: used,
|
||||
});
|
||||
self.made += u64::from(!dedicated);
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
{
|
||||
self.made_bytes += if dedicated { 0 } else { size };
|
||||
}
|
||||
if used == 0 {
|
||||
self.kept_bytes += size;
|
||||
}
|
||||
@@ -1236,6 +1249,10 @@ impl<T> Pool<T> {
|
||||
fn take(&mut self, index: usize) -> Option<T> {
|
||||
let block = self.blocks.get_mut(index)?.take()?;
|
||||
self.freed += u64::from(!block.dedicated);
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
{
|
||||
self.freed_bytes += if block.dedicated { 0 } else { block.size };
|
||||
}
|
||||
if block.empty() {
|
||||
self.kept_bytes -= block.size;
|
||||
}
|
||||
@@ -1248,6 +1265,12 @@ impl<T> Pool<T> {
|
||||
(self.made, self.freed)
|
||||
}
|
||||
|
||||
/// The bytes of the pooled blocks added and freed so far, for the crate's device tests.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(super) fn turnover_bytes(&self) -> (u64, u64) {
|
||||
(self.made_bytes, self.freed_bytes)
|
||||
}
|
||||
|
||||
/// When it last grew: a pooled block was added to it while it held another, at `now` where
|
||||
/// `adding` names one being added. Blocks made ahead are made for a pool that grew, and for
|
||||
/// one near its next block ([`Pool::near_next`], `memory/ready.rs`).
|
||||
@@ -2002,6 +2025,9 @@ pub(super) struct Memory {
|
||||
/// bytes, since a test last cleared it ([`AheadBlocks::made_in_place`]).
|
||||
#[cfg(test)]
|
||||
pub(crate) in_place_bytes: std::collections::BTreeMap<u64, u64>,
|
||||
/// The bytes of the blocks made ahead and freed unused ([`AheadBlocks::unused`]).
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
unused_bytes: u64,
|
||||
/// Blocks of images are allocated with `VK_MEMORY_ALLOCATE_ZERO_INITIALIZE_BIT_EXT`
|
||||
/// ([`Memory::zero_image_blocks`]).
|
||||
zero_images: bool,
|
||||
@@ -2191,6 +2217,8 @@ impl Memory {
|
||||
longest_making: Duration::ZERO,
|
||||
#[cfg(test)]
|
||||
in_place_bytes: std::collections::BTreeMap::new(),
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
unused_bytes: 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3315,6 +3343,10 @@ impl Memory {
|
||||
}
|
||||
for block in self.readying.swap_remove(at).stop() {
|
||||
self.ahead.unused += 1;
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
{
|
||||
self.unused_bytes += block.size;
|
||||
}
|
||||
// SAFETY: nothing was placed in the block, and no command reads it.
|
||||
drop(unsafe { self.let_go(device, block, FreeCause::KeptStale, None) });
|
||||
}
|
||||
@@ -3356,6 +3388,18 @@ impl Memory {
|
||||
})
|
||||
}
|
||||
|
||||
/// The bytes of [`Memory::turnover`]'s blocks, and of those of them made ahead and freed
|
||||
/// unused, for the crate's device tests.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) fn turnover_bytes(&self) -> (u64, u64, u64) {
|
||||
let unused = self.unused_bytes;
|
||||
let (made, freed) = (self.pools.iter().map(Pool::turnover_bytes))
|
||||
.fold((unused, unused), |(made, freed), (m, f)| {
|
||||
(made + m, freed + f)
|
||||
});
|
||||
(made, freed, unused)
|
||||
}
|
||||
|
||||
/// Free `block`, or where the device parks freed memory (`freed_memory.rs`), destroy its
|
||||
/// buffer of addresses and let its memory wait, with `after`, for the batches submitted
|
||||
/// before now, unless they completed. `after`, given back where the memory was freed here.
|
||||
|
||||
@@ -595,11 +595,12 @@ fn phase(
|
||||
(length, making): (Duration, Making),
|
||||
made: &mut Made,
|
||||
) {
|
||||
{
|
||||
let bytes_before = {
|
||||
let mut memory = crate::device::lock(&device.shared().memory);
|
||||
memory.longest_making = Duration::ZERO;
|
||||
memory.in_place_bytes.clear();
|
||||
}
|
||||
memory.turnover_bytes()
|
||||
};
|
||||
let before = (vmstat(), device.work_counts());
|
||||
let stop = AtomicBool::new(false);
|
||||
let (submits, turnarounds, makes) = std::thread::scope(|scope| {
|
||||
@@ -619,12 +620,16 @@ fn phase(
|
||||
(submits, turnarounds, maker.join().unwrap())
|
||||
});
|
||||
let after = (vmstat(), device.work_counts());
|
||||
let (longest, in_place) = {
|
||||
let (longest, in_place, bytes_after) = {
|
||||
let memory = crate::device::lock(&device.shared().memory);
|
||||
let sizes: Vec<String> = (memory.in_place_bytes.iter())
|
||||
.map(|(bytes, count)| format!("{count} of {} MiB", bytes >> 20))
|
||||
.collect();
|
||||
(memory.longest_making, sizes.join(", "))
|
||||
(
|
||||
memory.longest_making,
|
||||
sizes.join(", "),
|
||||
memory.turnover_bytes(),
|
||||
)
|
||||
};
|
||||
let over = |times: &[(Duration, f64)], bound: f64| {
|
||||
(times.iter())
|
||||
@@ -682,6 +687,21 @@ fn phase(
|
||||
counts.empty_memory_blocks_live,
|
||||
meminfo("MemAvailable") >> 20,
|
||||
);
|
||||
let (frees, earlier_frees) = (&counts.memory_frees, &earlier.memory_frees);
|
||||
eprintln!(
|
||||
"RECLAIM-SUBMIT {arm}, {name}: churn: pooled blocks made {} ({} MiB), freed {} ({} MiB); \
|
||||
of them made ahead and freed unused {} ({} MiB); pooled frees emptied {}, stale {}, \
|
||||
for room {}",
|
||||
counts.pooled_memory_blocks_made - earlier.pooled_memory_blocks_made,
|
||||
(bytes_after.0 - bytes_before.0) >> 20,
|
||||
counts.pooled_memory_blocks_freed - earlier.pooled_memory_blocks_freed,
|
||||
(bytes_after.1 - bytes_before.1) >> 20,
|
||||
counts.blocks_ahead_unused - earlier.blocks_ahead_unused,
|
||||
(bytes_after.2 - bytes_before.2) >> 20,
|
||||
frees.pooled_emptied - earlier_frees.pooled_emptied,
|
||||
frees.kept_stale - earlier_frees.kept_stale,
|
||||
frees.kept_for_room - earlier_frees.kept_for_room,
|
||||
);
|
||||
eprintln!("RECLAIM-SUBMIT {arm}, {name}: slowest submissions {slow}");
|
||||
eprintln!("RECLAIM-SUBMIT {arm}, {name}: slowest turnarounds {slow_turns}");
|
||||
eprintln!("RECLAIM-SUBMIT {arm}, {name}: slowest makings {slow_makes}");
|
||||
|
||||
Reference in new issue
Block a user