From a8cc1e694ece9519ac6eee124cfb3331b772fdee Mon Sep 17 00:00:00 2001 From: chrg6 Date: Fri, 13 Nov 2026 17:27:58 -0500 Subject: [PATCH] Write the released textures' room census only while they may keep more than their bound. sweep_pressure's second census, rel_census(cap, 1), ran whenever the released entries held more than their bound and less than 1.25 times what they may keep. Its line says "(kept past it while the card has room)". Without room, or without the hold, vk_tex_release.h trl_keep returns the bound itself, so keep equals cap. The census then also ran for bytes between the bound and 1.25 times it, which drop_stale was taking down anyway, and the label claimed room the card did not have. Now it runs only when keep > cap. The line stays for players: it is what tells why released textures stay past their bound (a 2026-11-13 session held 7,150 MiB against 4,008 and never said why), and at most one walk a minute, 60 a run, costs well under a millisecond. rel_census's comment says when the room census runs. Checks that passed: pass_cc_check on vk_texture.c, no new -Wall -Wextra warnings, tex_release_check (trl_keep's rule). Co-Authored-By: Claude Opus 5.5 --- runtime/vk_texture.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/runtime/vk_texture.c b/runtime/vk_texture.c index 714086d9..0fb27d9b 100644 --- a/runtime/vk_texture.c +++ b/runtime/vk_texture.c @@ -3336,9 +3336,10 @@ static void commit_evict(void) { // tex_lock held, the commit is low and the r // 989 and then 2,172 released entries holding 9.2 and 10.1 GiB against a bound of 4,008 MiB, and its overwritten // render targets "last used 1 presents ago". Each entry counts once, under the first reason that holds. // The same line, at most every REL_CENSUS_ROOM_NS of wall time and REL_CENSUS_ROOM_LINES times a run, while they hold -// more than the bound itself but not a quarter more than what they may keep (room 1): with room on the card trl_keep -// lets them keep twice the bound, and a session that held 7,150 MiB against a bound of 4,008 MiB (2026-11-13) never -// logged what kept them. +// more than the bound itself but not a quarter more than what they may keep (room 1), and only while trl_keep lets +// them keep more than the bound: with room on the card it lets them keep twice the bound, and a session that held +// 7,150 MiB against a bound of 4,008 MiB (2026-11-13) never logged what kept them. Without that room what they may +// keep is the bound, and the line said "kept past it while the card has room" of entries drop_stale was taking. #define REL_CENSUS_SUBS 3600 #define REL_CENSUS_LINES 24 #define REL_CENSUS_ROOM_NS 60000000000ull @@ -3459,7 +3460,7 @@ static void sweep_pressure(void) { // tex_lock held commit_free_now, commit_low_mark)); if (rel_bytes > keep) drop_stale(keep, &n_cap_drops, DROP_CAP); if (keep != UINT64_MAX && rel_bytes > keep + keep / 4) rel_census(keep, 0); // well over it: what holds the rest - else if (cap != UINT64_MAX && rel_bytes > cap) rel_census(cap, 1); + else if (keep > cap && rel_bytes > cap) rel_census(cap, 1); // kept past the bound while the card has room if (rel_bytes > COMMIT_LOW_KEEP && low && !held) more = drop_stale(COMMIT_LOW_KEEP, &n_commit_drops, DROP_COMMIT) == PRESSURE_STEP; }