Texture room line from the budget; time host-copy creation in the pass

The texture queue made no new host copies from 90 % of the card's budget
on; in play (2026-11-26 16:52 run) it said "no room" at 9,526-9,881 MB
weighed against 9,519-9,583 MB, with 1,060 MB of 10,600 left free. The
line is now the budget less 768 MiB or 5 % of it, whichever is more, and
never under 90 % (92.8 % here: about 290 MB more for textures; 95 % on
24 GB cards; 90 % from 7.5 GB down). The idle sweep moves with it: none
go 2 % under the line, those idle 5 s go down to 5 % under it, those idle
1.5 s from 5 % over it (88, 85 and 95 % at a line of 90 %, as before).
VICTORY_TEXTURE_ROOM_PERCENT set: a flat percentage, as before.

The pass's 5-second timing line found its four timed parts a third of
the pass (16:52 run, 11:24:35: 3,175 ms in 5 s, 1,038 of them staging
uploads, 95 the rest of the four); re-checks are 1 %, so they are not
capped. The line now also times making host copies (creation and
residency) and making the slots' views, and gives the rest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
readmet3xt-labandClaude Opus 5.5 committed 2026-11-26 17:08:48 +05:30
1 parent 082ebaf3b8
commit ff5d931657
2 files changed
+75 -13

No files matched your search

+31 -10
View File
@@ -149,20 +149,31 @@ pub(crate) fn available_physical_ram() -> Option<u64> {
/// (By those times everything idle for 2.5 s went from 75 % of the budget
/// on: 61,000 of them in the first 300 s of session play-1125-0203, at 78 to
/// 80 %, of which 13,000 were made and uploaded again.)
#[cfg_attr(not(test), allow(dead_code))]
pub(crate) fn vram_keep(budget: u64, used: u64) -> (u64, u64) {
vram_keep_below(budget, used, budget / 100 * 90)
}
/// [`vram_keep`] around the texture queue's line `line` (`crate::resource::room_line`)
/// instead of 90 % of the budget: none go while `used` is 2 % of the budget
/// under it or more, those idle 5 s go down to 5 % under it while it is
/// under 5 % over it, those idle 1.5 s above that. (At a line of 90 %: 88,
/// 85 and 95 %, as [`vram_keep`] was.)
pub(crate) fn vram_keep_below(budget: u64, used: u64, line: u64) -> (u64, u64) {
const KEPT_MS: u64 = 600_000;
const IDLE_MS: u64 = 5_000;
const SHORT_MS: u64 = 1_500;
if budget == 0 {
return (IDLE_MS, u64::MAX);
}
let share = |percent: u64| budget / 100 * percent;
if used < share(88) {
let step = budget / 100;
let aim = line.saturating_sub(5 * step);
if used < line.saturating_sub(2 * step) {
(KEPT_MS, u64::MAX)
} else if used < share(95) {
(IDLE_MS, used - share(85))
} else if used < line + 5 * step {
(IDLE_MS, used.saturating_sub(aim))
} else {
(SHORT_MS, used - share(85))
(SHORT_MS, used.saturating_sub(aim))
}
}
@@ -8849,16 +8860,21 @@ impl Meter {
tracing::info!(
"the texture queue's room: {used} MB in use - {blocks} MB free in texture blocks + {buffers} MB kept for \
card copies of title buffers + {targets} MB kept for render targets = {weighed} MB against a line of \
{line} MB ({} % of a budget of {budget} MB): {}",
crate::resource::room_percent(),
{line} MB ({:.1} % of a budget of {budget} MB): {}",
line as f64 * 100.0 / budget.max(1) as f64,
if weighed < line { "room" } else { "no room, new textures wait" }
);
}
let [looks, mapped, same, made, all] =
[0, 1, 2, 3, 4].map(|i| crate::draw::HEAP_TEXTURE_MICROS[i].swap(0, Ordering::Relaxed) / 1000);
let [looks, mapped, same, staged, all, made, views] =
[0, 1, 2, 3, 4, 5, 6].map(|i| crate::draw::HEAP_TEXTURE_MICROS[i].swap(0, Ordering::Relaxed) / 1000);
if all > 0 {
tracing::info!(
"the pass over textures picked by index, in the last 5 seconds: {all} ms in all, of them {looks} ms looking again at slots uploaded whole, {mapped} ms asking what of a texture's memory is mapped, {same} ms asking whether a host copy holds what memory holds, {made} ms making host copies and staging uploads; uploaded since the start: {} textures, {} MB",
"the pass over textures picked by index, in the last 5 seconds: {all} ms in all, of them {looks} ms looking \
again at slots uploaded whole, {mapped} ms asking what of a texture's memory is mapped, {same} ms asking \
whether a host copy holds what memory holds, {made} ms making host copies (creation and residency), \
{views} ms making the slots' views, {staged} ms staging uploads, {} ms the rest; uploaded since the start: \
{} textures, {} MB",
all.saturating_sub(looks + mapped + same + staged + made + views),
crate::draw::HEAP_TEXTURES.load(Ordering::Relaxed),
crate::draw::HEAP_TEXTURE_BYTES.load(Ordering::Relaxed) >> 20
);
@@ -10691,6 +10707,11 @@ mod batch { // Batch::texture_due lives here; `mod tests` is already taken at
assert_eq!((ms, bytes), (5_000, 5 * gib));
assert_eq!(vram_keep(100 * gib, 120 * gib), (1_500, 35 * gib));
assert_eq!(vram_keep(0, 7).0, 5_000);
// Around a line of 93 % instead: kept under 91 %, down to 88 %.
use super::vram_keep_below;
assert_eq!(vram_keep_below(100 * gib, 90 * gib, 93 * gib).0, 600_000);
assert_eq!(vram_keep_below(100 * gib, 92 * gib, 93 * gib), (5_000, 4 * gib));
assert_eq!(vram_keep_below(100 * gib, 99 * gib, 93 * gib), (1_500, 11 * gib));
}
#[test]