Cost half: the allocator's quiet-period frees and blocks made ahead unused are reported, never gated

What: memory_frees.kept_stale, memory_frees.blocks, memory_frees_posted and blocks_ahead_unused
join pooled_memory_blocks_freed under QUIET in cost.rs's RACY table (41 -> 45 rows).

Why: round 063's whole-set M3 replay (m3-max-10500, tree e9d1d94f36) put all four at 1 where the
measurement's most was 0 on swizzled-storage-rgba8unorm, rotated-planes-store-0-64x16,
render-then-sample-exact and pass-start-barrier-private-read, while the cost leg's measurement of
the same tree passed. Each counts a free that a quiet period decides: a kept empty block freed
after KEPT_EMPTY_FOR without a placement, a block made ahead freed once its pool stopped growing
for 10 s, and the two totals that hold such frees. Whether one lands in a case's window is a
question about elapsed time, the reason pooled_memory_blocks_freed is already reported. Every
other free cause (dedicated, pooled_emptied, kept_for_room, host_import, own_pages, teardown)
stays gated by its own name, so no free a case causes escapes the gate.

Verified: the racy test asserts the four reported and the six other causes gated (gem10 run in
the landing's message trail); records keep their stored bounds, which the check reports and does
not fail on (cost.rs, "Reach moving either way is reported and not fatal").
This commit is contained in:
Anees Iqbal committed 2026-11-08 19:10:47 -08:00
1 parent afcf0ed634
commit cfbf33126e
2 files changed
+34 -1

No files matched your search

+17 -1
View File
@@ -421,6 +421,14 @@ const COMPLEMENT: &str = "which of our own threads ran a command buffer's transi
/// Measured: it reached 1 where the measurement's most was 0 on `sample-positions-custom-2x` in two
/// whole-set replays, and both measurement shapes read 0 — a release that lands in the replay's
/// timing and not in the measurement's is exactly what a quiet period does.
///
/// The same quiet period stands behind `memory_frees.kept_stale` (a kept empty block freed after
/// `KEPT_EMPTY_FOR` without a placement), `blocks_ahead_unused` (a block made ahead freed once
/// its pool had stopped growing for 10 s) and the two totals that count those frees among others,
/// `memory_frees.blocks` and `memory_frees_posted`. Measured: a whole-set replay on this M3 Max
/// put all four at 1 where the measurement's most was 0 on `swizzled-storage-rgba8unorm`,
/// `rotated-planes-store-0-64x16`, `render-then-sample-exact` and
/// `pass-start-barrier-private-read`, and the whole-set measurement of the same tree read 0.
const QUIET: &str = "a pooled memory block freed because it had been kept empty past its quiet \
period, which is a question about elapsed time rather than about the case's work";
@@ -483,7 +491,7 @@ const POOLED: &str = "an object made because no spare was free, where a spare co
/// replays of a larger case set — which reads like a regression and is not one. See [`BORROWED`].
/// `slot_returns` beside it stays gated: it counts work items, one a command buffer, and has held
/// still alone and in both case sets.
const RACY: [(&str, &str); 41] = [
const RACY: [(&str, &str); 45] = [
("fences_made", POOLED),
// What is alive, parked or waiting at the instant the counts were read.
("memory_blocks_live", INSTANTANEOUS),
@@ -564,6 +572,14 @@ const RACY: [(&str, &str); 41] = [
waiter, so it moves with when the GPU finished that work",
),
("pooled_memory_blocks_freed", QUIET),
// The allocator's frees by cause: the quiet-period cause, and the two totals that hold it.
// Every other cause (`memory_frees.dedicated`, `.pooled_emptied`, `.kept_for_room`, the
// imports' and `.teardown`) stays gated by its own name, so reporting the totals drops no
// gate on a free that is a case's own work.
("memory_frees.kept_stale", QUIET),
("memory_frees.blocks", QUIET),
("memory_frees_posted", QUIET),
("blocks_ahead_unused", QUIET),
("finales_folded", FOLDED),
("command_pools_made", POOLED),
("spare_command_pools_", POOLED),
@@ -5100,6 +5100,12 @@ fn a_count_that_says_which_thread_arrived_first_is_never_gated() {
"primaries_begun_ahead",
"completed_where_seen",
"pooled_memory_blocks_freed",
// The same quiet period by the allocator's cause, and the totals holding it: a whole-set
// replay read 1 where the measurement read 0 on four cases.
"memory_frees.kept_stale",
"memory_frees.blocks",
"memory_frees_posted",
"blocks_ahead_unused",
"finales_folded",
// A waiter's own submission of batches the scheduler's thread had not reached yet:
// `xr-gradient-bgra10xr-srgb-unblended-x4` read 1 alone and 0 or 1 across one whole-set
@@ -5112,6 +5118,17 @@ fn a_count_that_says_which_thread_arrived_first_is_never_gated() {
// does what a case allocates even though what the pool hands back does not.
assert!(racy("encoder_command_buffers_begun").is_none());
assert!(racy("pooled_memory_blocks_made").is_none());
// A free by any cause but the quiet period stays gated by its own name.
for count in [
"memory_frees.dedicated",
"memory_frees.pooled_emptied",
"memory_frees.kept_for_room",
"memory_frees.host_import",
"memory_frees.own_pages",
"memory_frees.teardown",
] {
assert!(racy(count).is_none(), "{count}");
}
// `finales_apart` and `scheduled_where_submitted` were left gated by an earlier pass of this
// round *because nothing had been seen to move them*. That was the wrong test, and these two
// assertions are the reversal: "nothing has moved it" is a fact about the afternoon the