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]
+44 -3
View File
@@ -1825,7 +1825,7 @@ pub(crate) fn room(memory: Option<[u64; 4]>) -> bool {
// used.
Some([budget, used, ..]) => {
used.saturating_sub(crate::pool::texture_room()) + crate::shadow::card_room_kept() + targets_room_kept()
< budget / 100 * room_percent()
< room_line(budget)
}
None => filled < WITHOUT_BUDGET,
}
@@ -1934,7 +1934,7 @@ pub(crate) fn room_terms(memory: Option<[u64; 4]>) -> Option<[u64; 6]> {
crate::pool::texture_room(),
crate::shadow::card_room_kept(),
targets_room_kept(),
budget / 100 * room_percent(),
room_line(budget),
]
.map(|bytes| bytes >> 20),
)
@@ -1965,6 +1965,8 @@ pub(crate) fn room_lately() -> bool {
/// textures wait (runs 170-174); the card copies of title buffers from
/// 1 MiB up take 449 MB more of the card than before (941 against 492),
/// and 94 gives the textures about that much back.
///
/// Unless that switch is set the line is [`line_for`] the budget instead.
#[cfg(windows)]
pub(crate) fn room_percent() -> u64 {
static PERCENT: std::sync::OnceLock<u64> = std::sync::OnceLock::new();
@@ -1976,6 +1978,31 @@ pub(crate) fn room_percent() -> u64 {
})
}
/// The line [`room`] weighs the card's use against, in bytes of a budget
/// of `budget`: `VICTORY_TEXTURE_ROOM_PERCENT`'s share of it if set, else
/// [`line_for`] it.
#[cfg(windows)]
pub(crate) fn room_line(budget: u64) -> u64 {
static SET: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
if *SET.get_or_init(|| std::env::var_os("VICTORY_TEXTURE_ROOM_PERCENT").is_some()) {
budget / 100 * room_percent()
} else {
line_for(budget)
}
}
/// The budget less what is left free for the host's own needs that are
/// made with no room test (render target bursts, buffer copies, upload
/// buffers): 768 MiB or a twentieth of the budget, whichever is more; never
/// under 90 % of it. A flat 90 % left 1,060 MB of a 10,600 MB budget unused
/// while new textures waited (2026-11-26 16:52 run: "no room" at 9,526 to
/// 9,881 MB weighed against 9,519 to 9,583); this gives about 290 MB of it
/// to textures there, and keeps 90 % on cards of 7.5 GB or less.
#[cfg(any(windows, test))]
fn line_for(budget: u64) -> u64 {
budget.saturating_sub((768u64 << 20).max(budget / 20)).max(budget / 100 * 90)
}
/// For the card accounting line ([`card_accounting`]): the title texture
/// made for a view of memory at `address` with the resource description
/// `desc`, if there is one ([`texture_at`] makes it; this does not).
@@ -2244,7 +2271,7 @@ pub(crate) fn let_go_idle() {
let used = used.saturating_sub(crate::pool::texture_room())
+ crate::shadow::card_room_kept()
+ targets_room_kept();
crate::host::vram_keep(budget, used)
crate::host::vram_keep_below(budget, used, room_line(budget))
}
_ => (crate::host::vram_idle_ms(memory), u64::MAX),
};
@@ -4750,6 +4777,20 @@ float4 lit() : SV_Target { return 1.0; }
assert_eq!(texture_floor_bytes(Some(32 * GIB)), 2 * GIB);
}
/// The texture queue's line: the budget less 768 MiB or 5 %, never under
/// 90 % of it.
#[test]
fn room_line_follows_the_budget() {
const MIB: u64 = 1 << 20;
// 10,600 MB: 768 MiB free (92.8 %), not 1,060 MB.
assert_eq!(line_for(10_600 * MIB), 9_832 * MIB);
// 24 GB: 5 % free.
assert_eq!(line_for(24_000 * MIB), 22_800 * MIB);
// 6 GB: 90 % (768 MiB would be more than a tenth).
assert_eq!(line_for(6_000 * MIB), 6_000 * MIB / 100 * 90);
assert_eq!(line_for(0), 0);
}
/// The room kept for render targets goes once the world's targets are
/// made and have stopped growing, and comes back when they grow again.
#[test]