spares: a pool keeps what its uses of the last 5 to 10 s handed out (was 1 to 2 s)

A guest's Launchpad walk on the RX 7900 XTX freed 60 to 110 command
buffers a second past their pools' recent uses (spare_command_buffers_
freed_past_recent_uses), with 10 to 14 trims a second, and made them
again: its profile had about 43 ms a second inside allocate_command_buffers
(secondaries for passes not inline, encoder primaries, continuations,
barrier primaries, stocked secondaries) and 39 ms a second in the free
thread's frees and trims. pass_costs on the 780M: a primary made new (its
pool trimmed) costs about 13 us to allocate, 14 to 16 us to begin and 23
to 26 us to free and trim, against 0.6 to 0.9 us to begin one kept.

A frame's count of command buffers varies over seconds, and spans of 1 s
forgot what a pool handed out within two. RECENT_FOR is now 5 s; HELD
(4096) and IDLE_FOR (10 s) still bound what the spares keep.

Verified: tests::spares_walk on lavapipe (msi, job m3-max-25352, release,
two rounds each): spans of 1 s allocated 2.6 and 7.4 command buffers a
second and freed 7.2 and 5.2, with 1.0 and 1.2 trims; spans of 5 s
allocated 0.4 and 0 and freed none. The thread time of each command
buffer did not move past the run's noise (compositor 1,673 and 1,559 us
against 1,677 and 1,563; small 74 and 63 against 65 and 69). The RADV run
(780M) is queued; the walk itself is reims's.
This commit is contained in:
Anees Iqbal committed 2026-11-13 07:42:58 -08:00
1 parent 872b975b9b
commit 5ef0971b1a
1 file changed
+11 -2
+11 -2
View File
@@ -26,6 +26,15 @@
//! at once added pools and filled them: on RADV each command buffer holds 96 KiB of GTT (buffer
//! 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.
//! With spans of 1 s, a guest's walk on an RX 7900 XTX (RADV) freed 60 to 110 command buffers a
//! second past their pools' recent uses, the pools trimmed after, and made them again: its
//! profile had about 43 ms a second in `DeviceShared::allocate_command_buffers` and 39 ms a
//! second in the free thread's frees and trims. A frame's count of command buffers varies over
//! seconds, and with it what each pool it takes hands out. Spans of 5 s keep a use's command
//! buffers 5 to 10 s. `tests::spares_walk` (a frame of 47 to 141 passes about 41 times a second
//! beside about 1,600 small command buffers a second, on lavapipe): spans of 1 s allocated 2.6 to
//! 7.4 command buffers a second and freed 5.2 to 7.2; spans of 5 s allocated 0 to 0.4 and freed
//! none; the spares held 355 to 451 command buffers at a run's start and end, against 342 to 760.
//! 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
@@ -258,8 +267,8 @@ pub(super) const RECENT_USES: usize = 8;
/// The spans of a command pool's uses whose command buffers it keeps besides its last
/// [`RECENT_USES`]: given back, it keeps of each level as many as the most one of its uses in this
/// span and the one before handed out, so that one a use takes again within one to two spans
/// stays (the module docs).
pub(super) const RECENT_FOR: Duration = Duration::from_secs(1);
/// stays: 5 s, as a frame's count of command buffers varies over seconds (the module docs).
pub(super) const RECENT_FOR: Duration = Duration::from_secs(5);
/// How long a spare command pool stays untaken before every command buffer it holds is freed (the
/// module docs).