A command buffer past one pool takes the spares holding the most
Each spare command pool kept the most its own recent uses handed out, and a taker took the newest spare. Under a load of mixed command buffers, many in flight, the large one landed on every pool in turn, so every pool kept its command buffers: together past HELD (4,096), each give-back then shed the oldest spare, and its next taker made them again. On RADV each command buffer freed and trimmed destroys two buffer objects, each a walk of libdrm's list of free address ranges under its lock; on a guest's run on the RX 7900 XTX the frees thread ran at 41% of a core, 70% of it in that walk, while block frees were about none and spare pools were taken 120 to 640 times a second. Now a taker takes the spare holding a primary begun ahead and the fewest command buffers, else the one holding the fewest. Past ONE_POOL (16) command buffers handed out, a command buffer whose pools hold no more of a level takes the spare holding the most of that level (or makes a pool where there is none), up to TAKEN_PAST_FIRST (16) past its first, makes what it lacks then in the last it took, and gives every pool back with its first. The larger command buffers use the pools that hold the most, the smaller leave them, and the pools' command buffers follow what the load holds at once. HELD and the recent-uses rules stay: no memory is kept beyond them, so no FAST-PATHS row. Counted: WorkCounts::spare_command_pools_taken_past_first (api_signatures re-blessed). Tests: the mixed-load device test of the commit before now asserts a take past a first pool too; a unit test of both take orders.
This commit is contained in:
1 parent
7e8824f23d
commit
605b768750
5 files changed
+234
-40
No files matched your search
@@ -734,6 +734,10 @@ pub(super) struct State {
|
||||
/// The pool every `VkCommandBuffer` of this command buffer comes from, with those made from
|
||||
/// it; `None` until the first, and once given back to the device's spares.
|
||||
pool: Option<CommandPool>,
|
||||
/// The spare pools it took past `pool`, each once its pools handed out every
|
||||
/// `VkCommandBuffer` of a level they held, which hand out theirs before `pool` makes one
|
||||
/// (`spares.rs`); given back with `pool`.
|
||||
pools_past_first: Vec<CommandPool>,
|
||||
/// The pool of a predicated loop's check while it records again the work its laying left
|
||||
/// apart (`rerun.rs`): every `VkCommandBuffer` the command buffer hands out meanwhile comes
|
||||
/// from it, and goes back to it for the next run again.
|
||||
@@ -1920,6 +1924,13 @@ impl State {
|
||||
}
|
||||
}
|
||||
|
||||
/// Its command pools, taken out to go back to the device's spares: its first, then those it
|
||||
/// took past it (`spares.rs`); none where it has no pool.
|
||||
fn pools(&mut self) -> Vec<CommandPool> {
|
||||
let past = self.pools_past_first.drain(..);
|
||||
self.pool.take().into_iter().chain(past).collect()
|
||||
}
|
||||
|
||||
/// Give back every take of a copy taken at use its ended encoders and the recordings of
|
||||
/// their segments took (`shadow::Takes::give_back`): none of them runs.
|
||||
fn give_back_takes(&self) {
|
||||
@@ -2221,10 +2232,10 @@ impl Drop for CommandBufferShared {
|
||||
if state.status == CommandBufferStatus::NotEnqueued {
|
||||
state.give_back_takes();
|
||||
}
|
||||
state.pool.take()
|
||||
state.pools()
|
||||
};
|
||||
if let Some(pool) = pool {
|
||||
let shared = self.device.shared();
|
||||
let shared = self.device.shared();
|
||||
for pool in pool {
|
||||
shared.spares.give_command_pool(shared, pool, false);
|
||||
}
|
||||
}
|
||||
@@ -2267,6 +2278,7 @@ impl CommandBuffer {
|
||||
called_over_mutable_map: false,
|
||||
committing: false,
|
||||
pool: None,
|
||||
pools_past_first: Vec::new(),
|
||||
rerun_pool: None,
|
||||
kept: None,
|
||||
own_reached: 0,
|
||||
@@ -2570,12 +2582,13 @@ impl CommandBuffer {
|
||||
/// one.
|
||||
#[cfg(all(test, any(m2v_gpu, m2v_cpu_icd)))]
|
||||
pub(crate) fn give_pool_back_early(&self) -> bool {
|
||||
let Some(pool) = self.state().pool.take() else {
|
||||
return false;
|
||||
};
|
||||
let pools = self.state().pools();
|
||||
let shared = self.0.device.shared();
|
||||
shared.spares.give_command_pool(shared, pool, false);
|
||||
true
|
||||
let held = !pools.is_empty();
|
||||
for pool in pools {
|
||||
shared.spares.give_command_pool(shared, pool, false);
|
||||
}
|
||||
held
|
||||
}
|
||||
|
||||
/// Whether `waiting` holds this command buffer.
|
||||
@@ -5002,18 +5015,48 @@ impl CommandBufferShared {
|
||||
self.allocate(state, level)
|
||||
}
|
||||
|
||||
/// A `VkCommandBuffer` of `level` from this command buffer's pool, made on first use: a
|
||||
/// spare of the device's, or a new one. A command buffer the pool made before this command
|
||||
/// buffer took it is handed out again before a new one is made; its begin resets it (the
|
||||
/// pool's `VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT`, `spares.rs`). The caller holds
|
||||
/// `state` (the pool is externally synchronized).
|
||||
/// A `VkCommandBuffer` of `level` from this command buffer's pools, its first made on first
|
||||
/// use: a spare of the device's, or a new one. A command buffer a pool made before this
|
||||
/// command buffer took it is handed out again before a new one is made; its begin resets it
|
||||
/// (the pool's `VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT`, `spares.rs`). Past
|
||||
/// `ONE_POOL` handed out, once its pools handed out every one of `level` they held, it takes
|
||||
/// the spare holding the most of them, up to `TAKEN_PAST_FIRST` past its first, and makes
|
||||
/// what it lacks then in the last it took (`spares.rs`). The caller holds `state` (the pools
|
||||
/// are externally synchronized).
|
||||
#[cfg_attr(test, track_caller)]
|
||||
fn allocate(
|
||||
&self,
|
||||
state: &mut State,
|
||||
level: vk::CommandBufferLevel,
|
||||
) -> Result<vk::CommandBuffer, Error> {
|
||||
hand_out(&self.device, self.pool(state)?, level)
|
||||
let first = self.pool(state)?;
|
||||
if let Some(buffer) = first.reuse(level) {
|
||||
return Ok(buffer);
|
||||
}
|
||||
let mut handed = first.handed_out();
|
||||
for pool in state.pools_past_first.iter_mut().rev() {
|
||||
if let Some(buffer) = pool.reuse(level) {
|
||||
return Ok(buffer);
|
||||
}
|
||||
handed += pool.handed_out();
|
||||
}
|
||||
// A section takes no spare, and makes no pool past its first (`spares.rs`).
|
||||
let taken = state.pools_past_first.len();
|
||||
let grows = handed >= crate::spares::ONE_POOL && !exit_guard::in_section();
|
||||
if grows && taken < crate::spares::TAKEN_PAST_FIRST {
|
||||
let shared = self.device.shared();
|
||||
let family = shared.queue_family_of(self.queue.vk_queue());
|
||||
let spare = shared.spares.command_pool_holding(shared, family, level)?;
|
||||
let spare = match spare {
|
||||
Some(spare) => spare,
|
||||
None => command_pool(&self.device, family)?,
|
||||
};
|
||||
state.pools_past_first.push(spare);
|
||||
}
|
||||
match state.pools_past_first.last_mut() {
|
||||
Some(last) => hand_out(&self.device, last, level),
|
||||
None => hand_out(&self.device, self.pool(state)?, level),
|
||||
}
|
||||
}
|
||||
|
||||
/// [`CommandBuffer::encoder_primary`].
|
||||
@@ -5779,15 +5822,19 @@ impl CommandBufferShared {
|
||||
// wait), so nothing of its pools is pending: its command pool goes to the device's
|
||||
// spares whatever its status, never released on this thread (`spares.rs`); its
|
||||
// descriptor pools go once its completed handlers ran (below).
|
||||
if let Some(pool) = state.pool.take() {
|
||||
// None of the pool's command buffers is recording where it completed and ended
|
||||
// every one the pool handed out: a recording it left unused leaves one so.
|
||||
let pools = state.pools();
|
||||
if let Some(first) = pools.first() {
|
||||
// None of the pools' command buffers is recording where it completed and ended
|
||||
// every one the pools handed out: a recording it left unused leaves one so.
|
||||
let ended = self.raws_ended.load(Ordering::Relaxed);
|
||||
let handed: usize = pools.iter().map(CommandPool::handed_out).sum();
|
||||
let settled = state.status == CommandBufferStatus::Completed
|
||||
&& u64::try_from(pool.handed_out()).is_ok_and(|handed| handed == ended);
|
||||
settled_pool = settled.then_some(pool.raw);
|
||||
&& u64::try_from(handed).is_ok_and(|handed| handed == ended);
|
||||
settled_pool = settled.then_some(first.raw);
|
||||
let shared = self.device.shared();
|
||||
shared.spares.give_command_pool(shared, pool, settled);
|
||||
for pool in pools {
|
||||
shared.spares.give_command_pool(shared, pool, settled);
|
||||
}
|
||||
}
|
||||
state.unplaced();
|
||||
parked = state.parked > 0;
|
||||
|
||||
@@ -27,6 +27,22 @@
|
||||
//! objects of 80 and 16 KiB) until its pool is trimmed. Kept by the last [`RECENT_USES`] uses
|
||||
//! alone, a pool freed what a use took again a few dozen uses later, and made it again then.
|
||||
//! Counted: `Spares::command_buffers_held` and `Spares::churn` (the crate's tests).
|
||||
//! - **A command buffer past one pool takes the spares holding the most.** A taker takes the
|
||||
//! spare holding a primary begun ahead and the fewest command buffers, else the one holding the
|
||||
//! fewest ([`take_command_pool`]), as a command buffer's size is unknown as it takes its pool.
|
||||
//! Past [`ONE_POOL`] command buffers handed out, one whose pools hold no more of a level takes
|
||||
//! the spare holding the most of that level ([`take_command_pool_holding`]), or makes a pool
|
||||
//! where there is no spare, up to [`TAKEN_PAST_FIRST`] past its first, and makes what it lacks
|
||||
//! then in the last it took; each goes back with its first (`command_buffer/mod.rs`'s
|
||||
//! `CommandBufferShared::allocate`). So the larger command buffers of a load use the pools that
|
||||
//! hold the most, which the smaller leave, and the pools' command buffers follow what the load
|
||||
//! holds at once. Each pool taking the newest spare and keeping its own uses' most, a load of
|
||||
//! 64 command buffers in flight, a cycle of one of 200 blit encoders and nine of 2, had every
|
||||
//! pool keep the large one's; past [`HELD`] together, each give-back then shed the oldest
|
||||
//! spare, whose next taker made its command buffers again (`tests::spares`). On RADV each
|
||||
//! command buffer freed and trimmed destroys two buffer objects, each a walk of libdrm's list of
|
||||
//! free address ranges under its lock, which every other buffer object's making and freeing
|
||||
//! takes too. Counted: `WorkCounts::spare_command_pools_taken_past_first`.
|
||||
//! - **The spares hold at most [`HELD`] command buffers together.** Counted with them: the pool
|
||||
//! given back, and what each pool out of the spares held as it went out, taken by a command
|
||||
//! buffer, freeing command buffers or beginning a primary ahead ([`CommandPools::out`]), whose
|
||||
@@ -157,8 +173,8 @@
|
||||
//! never the begun one. A pool whose taker resets it (one given back unsettled) resets the begun
|
||||
//! primary with the rest, which is then an ordinary one again. A pool given back unsettled, or
|
||||
//! while a thread waited, or whose begin fails, holds none; nor does one holding no primary
|
||||
//! where the spares hold [`HELD`] command buffers. A taker takes the newest spare
|
||||
//! holding one first ([`take_command_pool`]). Counted: `WorkCounts::primaries_begun_ahead`, and
|
||||
//! where the spares hold [`HELD`] command buffers. A taker takes a spare holding one first
|
||||
//! ([`take_command_pool`]). Counted: `WorkCounts::primaries_begun_ahead`, and
|
||||
//! those encoders took, `WorkCounts::encoder_primaries_begun_ahead`.
|
||||
//! - **Descriptor pools are reset by the taker**, on the thread that encodes: the program's own, or
|
||||
//! one running the program's code (a handler).
|
||||
@@ -187,6 +203,7 @@ use super::exit_guard::{self, Call};
|
||||
use super::pending_audit::Freeing;
|
||||
use super::release::{self, Released};
|
||||
use ash::vk;
|
||||
use std::cmp::Reverse;
|
||||
use std::collections::VecDeque;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::{Duration, Instant};
|
||||
@@ -221,6 +238,15 @@ pub(super) const FREED_AT_ONCE: usize = 32;
|
||||
/// command buffers with recordings a device on ANV below Xe-HP holds at once (the module docs).
|
||||
pub(super) const HELD: usize = 4096;
|
||||
|
||||
/// The command buffers a command buffer hands out of its first pool alone, making those it lacks
|
||||
/// there; past them, its pools out of one of a level, it takes a spare holding the most of that
|
||||
/// level (the module docs).
|
||||
pub(super) const ONE_POOL: usize = 16;
|
||||
|
||||
/// The most spare command pools a command buffer takes past its first (the module docs); past
|
||||
/// them it makes the command buffers it lacks in the last it took.
|
||||
pub(super) const TAKEN_PAST_FIRST: usize = 16;
|
||||
|
||||
/// The index of `level`'s list in a [`CommandPool`]: primary 0, secondary 1.
|
||||
fn level_index(level: vk::CommandBufferLevel) -> usize {
|
||||
usize::from(level == vk::CommandBufferLevel::SECONDARY)
|
||||
@@ -616,13 +642,43 @@ impl Spares {
|
||||
&self,
|
||||
device: &DeviceShared,
|
||||
family: u32,
|
||||
) -> Result<Option<CommandPool>, Error> {
|
||||
self.take(device, |pools| take_command_pool(pools, family))
|
||||
}
|
||||
|
||||
/// [`command_pool`](Self::command_pool), the spare of queue family `family` holding the most
|
||||
/// command buffers of `level` ([`take_command_pool_holding`]), for a command buffer past
|
||||
/// [`ONE_POOL`] command buffers whose pools handed out every one of that level they held (the
|
||||
/// module docs); `None` where there is no spare.
|
||||
pub(super) fn command_pool_holding(
|
||||
&self,
|
||||
device: &DeviceShared,
|
||||
family: u32,
|
||||
level: vk::CommandBufferLevel,
|
||||
) -> Result<Option<CommandPool>, Error> {
|
||||
let taken = self.take(device, |pools| {
|
||||
take_command_pool_holding(pools, family, level)
|
||||
})?;
|
||||
if taken.is_some() {
|
||||
device.counts.spare_command_pool_taken_past_first();
|
||||
}
|
||||
Ok(taken)
|
||||
}
|
||||
|
||||
/// The spare command pool `pick` takes out of the spares, reset where one of its command
|
||||
/// buffers may be recording (the module docs); `None` when it takes none, or this thread is
|
||||
/// in a section.
|
||||
fn take(
|
||||
&self,
|
||||
device: &DeviceShared,
|
||||
pick: impl FnOnce(&mut Vec<CommandPool>) -> Option<CommandPool>,
|
||||
) -> Result<Option<CommandPool>, Error> {
|
||||
if exit_guard::in_section() {
|
||||
return Ok(None);
|
||||
}
|
||||
let taken = {
|
||||
let mut pools = lock(&self.command_pools);
|
||||
take_command_pool(&mut pools.spares, family).map(|mut pool| {
|
||||
pick(&mut pools.spares).map(|mut pool| {
|
||||
pools.went_out(&mut pool);
|
||||
pool
|
||||
})
|
||||
@@ -1009,21 +1065,36 @@ pub(super) fn past_held(
|
||||
}
|
||||
|
||||
/// Keep `pool`, a spare whose command buffers its idleness or [`HELD`] freed, among the spare
|
||||
/// command pools `pools` as the oldest: a taker takes the newest, which still holds its command
|
||||
/// buffers.
|
||||
/// command pools `pools` as the oldest, which [`take_idle`] and [`past_held`] reach first.
|
||||
pub(super) fn keep_idle_command_pool(pools: &mut Vec<CommandPool>, pool: CommandPool) {
|
||||
pools.insert(0, pool);
|
||||
}
|
||||
|
||||
/// The newest of the spare command pools `pools` made for queue family `family` that holds a
|
||||
/// primary begun ahead, else the newest of them, taken out.
|
||||
/// The spare command pool of `pools` (oldest first) made for queue family `family` that holds a
|
||||
/// primary begun ahead and the fewest command buffers, else the one of them that holds the
|
||||
/// fewest, the newest of those, taken out: a command buffer's size is unknown as it takes its
|
||||
/// pool, and one that grows past its first takes the spares holding the most
|
||||
/// ([`take_command_pool_holding`], the module docs).
|
||||
pub(super) fn take_command_pool(pools: &mut Vec<CommandPool>, family: u32) -> Option<CommandPool> {
|
||||
let of_family = |pool: &CommandPool| pool.family == family;
|
||||
let at = (pools
|
||||
.iter()
|
||||
.rposition(|pool| of_family(pool) && pool.begun.is_some()))
|
||||
.or_else(|| pools.iter().rposition(of_family))?;
|
||||
Some(pools.remove(at))
|
||||
let (fewest, _) = (pools.iter().enumerate())
|
||||
.filter(|(_, pool)| pool.family == family)
|
||||
.min_by_key(|&(index, pool)| (pool.begun.is_none(), pool.held(), Reverse(index)))?;
|
||||
Some(pools.remove(fewest))
|
||||
}
|
||||
|
||||
/// The spare command pool of `pools` (oldest first) made for queue family `family` that holds the
|
||||
/// most command buffers of `level`, of those the one holding no primary begun ahead, then the
|
||||
/// newest, taken out: where none holds one, the spare a command buffer grows into.
|
||||
pub(super) fn take_command_pool_holding(
|
||||
pools: &mut Vec<CommandPool>,
|
||||
family: u32,
|
||||
level: vk::CommandBufferLevel,
|
||||
) -> Option<CommandPool> {
|
||||
let at = level_index(level);
|
||||
let (most, _) = (pools.iter().enumerate())
|
||||
.filter(|(_, pool)| pool.family == family)
|
||||
.max_by_key(|&(index, pool)| (pool.made[at].len(), pool.begun.is_none(), index))?;
|
||||
Some(pools.remove(most))
|
||||
}
|
||||
|
||||
/// Keep `pool` among the spare command pools `pools`, newest last: every one, however many
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
use crate::descriptor_arena::{Room, SetNeeds};
|
||||
use crate::spares::{
|
||||
keep_command_pool, keep_descriptor_pool, keep_idle_command_pool, past_held, take_command_pool,
|
||||
take_descriptor_pool, take_idle, CommandPool, CommandPools, DescriptorPool, DESCRIPTORS,
|
||||
DESCRIPTOR_POOLS, HELD, IDLE_FOR, RECENT_FOR, RECENT_USES,
|
||||
take_command_pool_holding, take_descriptor_pool, take_idle, CommandPool, CommandPools,
|
||||
DescriptorPool, DESCRIPTORS, DESCRIPTOR_POOLS, HELD, IDLE_FOR, RECENT_FOR, RECENT_USES,
|
||||
};
|
||||
use ash::vk::{self, Handle};
|
||||
use std::collections::VecDeque;
|
||||
@@ -113,8 +113,8 @@ fn a_primary_begun_ahead_goes_to_the_first_encoder_alone() {
|
||||
assert_eq!(reset.reuse(primary), Some(vk::CommandBuffer::from_raw(20)));
|
||||
}
|
||||
|
||||
/// A command buffer takes the newest spare command pool of its queue's family that holds a
|
||||
/// primary begun ahead, else the newest of that family.
|
||||
/// A command buffer takes a spare command pool of its queue's family that holds a primary begun
|
||||
/// ahead, else one of that family, the newest of those holding the fewest command buffers.
|
||||
#[test]
|
||||
fn a_spare_command_pool_holding_a_begun_primary_is_taken_first() {
|
||||
let mut pools = Vec::new();
|
||||
@@ -134,6 +134,61 @@ fn a_spare_command_pool_holding_a_begun_primary_is_taken_first() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A command buffer takes the spare holding the fewest command buffers of those holding a primary
|
||||
/// begun ahead, then of the rest; one past its first pool takes the spare holding the most of the
|
||||
/// level it lacks, one holding no primary begun ahead first, and any spare where none holds one.
|
||||
#[test]
|
||||
fn a_taker_takes_the_fewest_and_one_past_its_first_pool_the_most() {
|
||||
let primary = vk::CommandBufferLevel::PRIMARY;
|
||||
let secondary = vk::CommandBufferLevel::SECONDARY;
|
||||
let mut pools = vec![
|
||||
holding(1, 5, 1),
|
||||
holding(2, 40, 1),
|
||||
holding(3, 2, 1),
|
||||
holding(4, 40, 0),
|
||||
holding(5, 9, 1),
|
||||
];
|
||||
pools[0].begun = Some(vk::CommandBuffer::from_raw(10));
|
||||
pools[1].begun = Some(vk::CommandBuffer::from_raw(20));
|
||||
let raws = |pools: &[CommandPool]| pools.iter().map(|p| p.raw.as_raw()).collect::<Vec<_>>();
|
||||
let taken = |pool: Option<CommandPool>| pool.map(|pool| pool.raw.as_raw());
|
||||
assert_eq!(
|
||||
taken(take_command_pool_holding(&mut pools, 0, primary)),
|
||||
Some(4)
|
||||
);
|
||||
assert_eq!(
|
||||
taken(take_command_pool_holding(&mut pools, 0, primary)),
|
||||
Some(2)
|
||||
);
|
||||
assert_eq!(
|
||||
taken(take_command_pool_holding(&mut pools, 0, secondary)),
|
||||
Some(5)
|
||||
);
|
||||
assert_eq!(
|
||||
taken(take_command_pool_holding(&mut pools, 1, primary)),
|
||||
None
|
||||
);
|
||||
assert_eq!(raws(&pools), [1, 3]);
|
||||
let mut pools = vec![
|
||||
holding(1, 5, 1),
|
||||
holding(2, 40, 1),
|
||||
holding(3, 2, 1),
|
||||
holding(4, 0, 0),
|
||||
holding(5, 9, 1),
|
||||
];
|
||||
pools[0].begun = Some(vk::CommandBuffer::from_raw(10));
|
||||
pools[1].begun = Some(vk::CommandBuffer::from_raw(20));
|
||||
for expected in [1, 2, 4, 3, 5] {
|
||||
assert_eq!(taken(take_command_pool(&mut pools, 0)), Some(expected));
|
||||
}
|
||||
let mut empty = vec![holding(6, 0, 0)];
|
||||
assert_eq!(
|
||||
taken(take_command_pool_holding(&mut empty, 0, secondary)),
|
||||
Some(6),
|
||||
"a spare to grow into"
|
||||
);
|
||||
}
|
||||
|
||||
/// A command buffer takes the newest spare command pool made for its queue's family, never one
|
||||
/// of another family.
|
||||
#[test]
|
||||
@@ -442,8 +497,7 @@ fn a_steady_workload_makes_its_command_buffers_once() {
|
||||
|
||||
/// The oldest spare no command buffer took for [`IDLE_FOR`] since it was given back, and that
|
||||
/// holds a command buffer, is taken out of the spares to shed them all, the primary begun ahead
|
||||
/// first, and goes back as the oldest, so that a taker takes a spare that still holds its command
|
||||
/// buffers first.
|
||||
/// first, and goes back as the oldest.
|
||||
#[test]
|
||||
fn a_spare_left_idle_sheds_its_command_buffers_and_goes_back_the_oldest() {
|
||||
let primary = vk::CommandBufferLevel::PRIMARY;
|
||||
@@ -857,11 +911,13 @@ mod device {
|
||||
churn.past_held - churn_warm.past_held,
|
||||
churn.shed - churn_warm.shed,
|
||||
];
|
||||
let past_first =
|
||||
counts.spare_command_pools_taken_past_first - warm.spare_command_pools_taken_past_first;
|
||||
let trims = counts.spare_command_pool_trims - warm.spare_command_pool_trims;
|
||||
println!(
|
||||
"SPARES-MIXED {}: {MIXED_IN_FLIGHT} in flight of {MIXED:?}, {} cycles once warm: made \
|
||||
{allocated} command buffers, freed {freed:?} (past recent uses, past the bound, \
|
||||
shed), {trims} trims; the spares hold \
|
||||
shed), {trims} trims; {past_first} spares taken past a first pool; the spares hold \
|
||||
{} of {} begun",
|
||||
device.name(),
|
||||
MIXED_CYCLES - MIXED_WARM,
|
||||
@@ -873,6 +929,10 @@ mod device {
|
||||
(0, [0; 3], 0),
|
||||
"the load made and freed command buffers once warm"
|
||||
);
|
||||
assert!(
|
||||
past_first > 0,
|
||||
"no command buffer took a spare past its first pool"
|
||||
);
|
||||
drop((target, queue, device));
|
||||
let _ = std::fs::remove_dir_all(&scratch);
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ pub(crate) struct Counters {
|
||||
commands: CommandTallies,
|
||||
command_pools_made: AtomicU64,
|
||||
spare_command_pools_taken: AtomicU64,
|
||||
spare_command_pools_taken_past_first: AtomicU64,
|
||||
spare_command_pools_reset: AtomicU64,
|
||||
/// The command buffers the spare command pools freed, by why (`spares.rs`): past a pool's
|
||||
/// recent uses, past `HELD` of a pool given back, and shed by a spare; then the trims of
|
||||
@@ -1894,6 +1895,13 @@ impl Counters {
|
||||
.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// Of those, a command buffer took one past its first, its pools having handed out every
|
||||
/// command buffer of a level they held (`spares.rs`).
|
||||
pub(crate) fn spare_command_pool_taken_past_first(&self) {
|
||||
self.spare_command_pools_taken_past_first
|
||||
.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// A command buffer took a spare command pool that one of its command buffers may still be
|
||||
/// recording in, and reset it first (`spares.rs`).
|
||||
pub(crate) fn spare_command_pool_reset(&self) {
|
||||
@@ -4975,6 +4983,10 @@ pub struct WorkCounts {
|
||||
/// where the command buffer that gave it back completed and ended every command buffer of it
|
||||
/// it was handed: each is reset as it is begun again.
|
||||
pub spare_command_pools_taken: u64,
|
||||
/// Of `spare_command_pools_taken`, those a command buffer took past its first, once its pools
|
||||
/// had handed out every `VkCommandBuffer` of a level they held: the spare holding the most of
|
||||
/// that level, whose command buffers it hands out before it makes any (`spares.rs`).
|
||||
pub spare_command_pools_taken_past_first: u64,
|
||||
/// The spare `VkCommandPool`s among those taken that were reset first, as one of their
|
||||
/// command buffers may still have been recording: the command buffer that gave the pool back
|
||||
/// failed, was dropped unsubmitted, or left a command buffer of it unended (a recording it did
|
||||
@@ -8825,6 +8837,9 @@ impl Device {
|
||||
copy_sites: self.shared().vk().copy_sites(),
|
||||
copy_regions_split: self.shared().vk().copy_regions_split(),
|
||||
spare_command_pools_taken: counters.spare_command_pools_taken.load(Ordering::Relaxed),
|
||||
spare_command_pools_taken_past_first: counters
|
||||
.spare_command_pools_taken_past_first
|
||||
.load(Ordering::Relaxed),
|
||||
spare_command_pools_reset: counters.spare_command_pools_reset.load(Ordering::Relaxed),
|
||||
spare_command_buffers_freed_past_recent_uses: counters.spare_command_buffers_freed[0]
|
||||
.load(Ordering::Relaxed),
|
||||
|
||||
@@ -3339,6 +3339,7 @@ field metal2vulkan-runtime::WorkCounts.spare_command_buffers_shed pub spare_comm
|
||||
field metal2vulkan-runtime::WorkCounts.spare_command_pool_trims pub spare_command_pool_trims: u64
|
||||
field metal2vulkan-runtime::WorkCounts.spare_command_pools_reset pub spare_command_pools_reset: u64
|
||||
field metal2vulkan-runtime::WorkCounts.spare_command_pools_taken pub spare_command_pools_taken: u64
|
||||
field metal2vulkan-runtime::WorkCounts.spare_command_pools_taken_past_first pub spare_command_pools_taken_past_first: u64
|
||||
field metal2vulkan-runtime::WorkCounts.stage_entries_shared pub stage_entries_shared: u64
|
||||
field metal2vulkan-runtime::WorkCounts.stage_entries_specialized pub stage_entries_specialized: u64
|
||||
field metal2vulkan-runtime::WorkCounts.stage_tables_read pub stage_tables_read: u64
|
||||
|
||||
|
Can't render this file because it is too large.
|
Reference in new issue
Block a user