Keep the plans a draw's resident uses were compared with in place
A draw that switched to a plan whose uses differ pushed the plan into its ResidentOf's compared list (5ab66c0e6b), allocating the list. It then made its uses again under a new ResidentOf, dropping the list. In runtime_lane::frame_costs' window-shaped frame, whose draws switch pipeline state from draw to draw, that was an allocation at nearly every draw. ResidentOf::compared is now an array of COMPARED_PLANS slots. Measured, frame_costs on the M3, debug, --cfg m2v_gpu: 20.33 allocations a draw, from 20.83. Verified on the M3 (potluck), on this tree: - clippy --cfg m2v_gpu of the runtime and the validation crate, all targets; - the runtime suite, debug, --cfg m2v_gpu, hazard filter: 1627 of 1628, the one failure exit_guard's known base failure; - the lanes: 246 of 247, the one failure frame_costs' debug bound at 20.33. (cherry picked from commit 1c237630db1b4273faa14068c653e926952f62fe)
This commit is contained in:
1 parent
2282779a74
commit
fa99ed2c19
1 file changed
+8
-5
@@ -2443,7 +2443,9 @@ pub(crate) fn kept_resident_checks() -> u64 {
|
||||
struct ResidentOf {
|
||||
plan: Weak<BindingPlan>,
|
||||
generation: Option<u64>,
|
||||
compared: Vec<(Weak<BindingPlan>, bool)>,
|
||||
/// Held in place, so a command that switches plan allocates nothing for them: one whose
|
||||
/// plan lists other uses makes its uses again, and its own `ResidentOf`.
|
||||
compared: [Option<(Weak<BindingPlan>, bool)>; COMPARED_PLANS],
|
||||
}
|
||||
|
||||
/// The most plans a [`ResidentOf`] keeps compared with its own: draws of one pipeline state whose
|
||||
@@ -2464,12 +2466,13 @@ impl ResidentOf {
|
||||
if self.plan.as_ptr() == at {
|
||||
return true;
|
||||
}
|
||||
if let Some(&(_, alike)) = self.compared.iter().find(|(of, _)| of.as_ptr() == at) {
|
||||
let found = (self.compared.iter().flatten()).find(|(of, _)| of.as_ptr() == at);
|
||||
if let Some(&(_, alike)) = found {
|
||||
return alike;
|
||||
}
|
||||
let alike = (self.plan.upgrade()).is_some_and(|made| made.uses == plan.uses);
|
||||
if self.compared.len() < COMPARED_PLANS {
|
||||
self.compared.push((Arc::downgrade(plan), alike));
|
||||
if let Some(free) = self.compared.iter_mut().find(|slot| slot.is_none()) {
|
||||
*free = Some((Arc::downgrade(plan), alike));
|
||||
}
|
||||
alike
|
||||
}
|
||||
@@ -2509,7 +2512,7 @@ fn uses_into(
|
||||
into.of = kept.map(|plan| ResidentOf {
|
||||
plan: Arc::downgrade(plan),
|
||||
generation,
|
||||
compared: Vec::new(),
|
||||
compared: Default::default(),
|
||||
});
|
||||
// Kept from one command to the next alone, so the identity of those kept alone
|
||||
// (none where there are none: `prefix` reads it only where there are some).
|
||||
|
||||
Reference in new issue
Block a user