perf: the texture pool keeps only the empty blocks that fit under the 85 % line (8 GB: -512 MB at the peak, no 640 MB churn) #550
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/550"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LooperSalty/AnyXboxX. Originally posted by KainanP on 2026-11-27T21:00:59Z.
Change
The texture pool (
victory-gpupool.rs) keeps empty 64 MB blocks while the card is under a line, and makes 12 of them ahead of need (VICTORY_RIPE_BLOCKS). Since #564 that line isresource::room_percent() − 5: 80 % under theLowVrampreset (VICTORY_TEXTURE_ROOM_PERCENT=85), 85 % by default. Below the linemainkeeps a flat 64 empty blocks (4 GiB), whatever room is left under it. So the 12 blocks made ahead (768 MB) land at once, even when the card is a few blocks short of the line.On an 8 GB card that is the normal place to be:
resource::roomdoes not count the empty blocks, so the card's real use sits at the texture share plus the empty blocks. What happens then, measured below:pool::room) sees the card over the line and lets 10 of them go;That is 640 MB made and given back every two seconds. While the blocks are there the card is that much closer to its budget, which is where the system starts moving memory to the PC.
Now, below the line, the pool keeps the empty blocks it has plus as many more as fit under the line, between
SPARE(2) andSPARE_KEPT(64). The blocks made ahead follow that count (Ripe::nowalready takes the smaller of 12 and it).pool.empty().SPARE(akimfomin).Nothing else changes:
Linked issue: Refs #549, the VRAM census of the base under
LowVramthat found it. The 8 GB numbers that motivated it are on VIctory #3505: RTX 4060 Laptop 8 GB, AnyXboxX main with the LowVram values, 6,559 → 7,145 MiB against a budget of about 6.4 GB.Verification
RTX 4060 Laptop 8 GB (budget 7,188 MB) and Intel UHD;
third_party/victoryon main132da615;CARGO_TARGET_DIRoutside the tree.Device check
pool::tests::blocks_made_ahead_stay_under_the_line, run withVICTORY_TEXTURE_ROOM_PERCENT=85(line 80 % = 5,750 MB). The test is ignored because it fills the card to the line minus 5 blocks with buffers of ours. It then tells the pool the room, as the host does once a second, and asks for 16 textures of 1 MiB after each of four looks. Three runs each, identical:main's rule)So −512 MB at the peak, and no block made and let go every other second.
Oracle and test data
The fixtures follow the effective line,
line_percent()of the test process, throughby_the_line(budget, n): the use sits n and a half blocks under the line, or n blocks over it.empty_blocks_kept_fit_under_the_lineSPARE, and the kept blocks plus the use stay under the line. Fails withmain's rule.a_busy_pool_keeps_the_last_counta_busy_pool_over_the_line_comes_down_to_spare(akimfomin)4, 4, 4, 4, 4, 2, 2, 2, 2, 2. Fails without the busy-lock lowering.a_12_gb_card_keeps_its_blocks_below_the_linesparesis tested, with an assumed budget of 11,000 MB; no such card was at hand. With 4 GiB or more under the line the count is the old one. The blocks made ahead are the old ones while 768 MB fit. The count is never under the empty blocks there are. At line 80 % it differs from 4,720 MB in use, and the blocks made ahead from 8,048 MB. A native datapoint is asked on PortBridge#132.empty_blocks_stay_while_the_card_has_room,spares_scales_with_room_target(from #564)blocks_made_ahead_stay_under_the_line(device, ignored)No test data from a title.
Not measured: a game run. What it can change in game is the card's use while textures stream in near the line, which should stay lower and steady. It does not change the frame time directly.
Checklist
E_NOTIMPL), never a fake success. (n/a)Suggested-by: akimfomin).AI use: made with Claude Code (Claude Opus 5.5): code reading, the census, the change, the tests and this description. The device checks were run on my RTX 4060 Laptop.
🤖 Generated with Claude Code
Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T21:24:03Z.
Thanks, the fit-under-the-line rule reads right and
empty_blocks_kept_fit_under_the_linefails without it. One issue inpool.rsroom()(line 47): whenTEXTURES.try_lock()fails,emptyfalls back toSPARES.load(), which is the previous limit, not a count of empty blocks. The next limit is then computed from it, so under repeated contention the limit can climb back towardSPARE_KEPT, which undoes the fix. On a busy lock, please keep the last limit unchanged (skip the update this tick) instead of feeding it back in asempty. Since this changes the default on every card, a check on a 12 GB card that the limit stays at its old value below the line would also help.Imported from LooperSalty/AnyXboxX. Originally posted by akimfomin on 2026-11-27T23:02:14Z.
I replayed LooperSalty's lock-contention case with the policy at
a088a1c. At a 7,188 MiB budget and a fixed use of 5,822 MiB, four busy ticks turn an allowed limit of 4 into 8 → 12 → 16 → 20, even if no empty block was created.A useful boundary for the correction: a busy lock can hold the last limit below the line, but it should still be able to lower the limit when the process crosses 85% or pressure is active. Those branches already know they want 2 without inspecting the pool. Keep staging reclamation on its existing separate path. With that rule, the arithmetic control gives 4 → 4 → 4 → 4 → 4 below the line and 4 → 2 → 2 → 2 → 2 after crossing it. The roomy 12 GiB control (6 GiB used) still allows 64 blocks, while at 80% only 9 additional empty blocks fit. That last pair is an arithmetic check and still needs the physical check requested above.
PortBridge modeled the public code with Codex. This is a deterministic policy check, with no new GPU or in-game run.
Imported from LooperSalty/AnyXboxX. Originally posted by KainanP on 2026-11-27T23:14:59Z.
Merci, bien vu : c'était exactement ça. Corrigé dans
0ea1c912(poussé sur la même branche).Correctif.
room()ne calcule plus la limite que sous le verrou deTEXTURES, à partir depool.empty(). Si le verrou est pris, ce passage ne change rien :SPARESgarde la valeur du passage précédent, et le suivant (une seconde plus tard) la recalcule. Le pool de staging est toujours repris avec cette dernière limite. La limite n'est donc plus jamais réinjectée comme nombre de blocs vides.Test qui échoue sur l'ancienne tête (
a088a1c4).pool::tests::a_busy_pool_keeps_the_last_counttient le verrou du pool et metSPARESà 4. Le budget est de 7 188 MB à 81 % (4 blocs tiennent sous la ligne des 85 %). Il appelle ensuiteroom()16 fois.room():FAILED, compte à chaque passage[8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 64], soit la remontée jusqu'àSPARE_KEPTque tu décrivais ;ok, 4 à chaque passage.Carte de 12 Go : SIMULÉE. Je n'ai pas de carte de 12 Go.
pool::tests::a_12_gb_card_keeps_its_blocks_below_the_lineteste seulement le calcul (spares), avec un budget de 11 000 MB supposé, soit à peu près ce que le système donne à une telle carte en jeu. Pour chaque utilisation de 0 à la ligne (9 350 MB, par pas de 16 MB) et 0, 3, 12, 40 ou 64 blocs déjà vides, il compare à l'ancienne règle (64 sous 85 %, sinon 2). Réponse franche : la limite ne reste pas partout à son ancienne valeur, mais ce que fait le pool, si, sauf près de la ligne.vides + ce qui tient, donc moins que 64.min(12, limite)) sont les mêmes qu'avant tant que 768 MB tiennent sous la ligne, soit jusqu'à 8 592 MB utilisés (78 %). Au-delà, il y en a moins : c'est le correctif lui-même.vides + ce qui tientpartent dans la même seconde, les blocs vidés au-delà de la limite sont lâchés au lieu d'être gardés (l'ancienne règle en gardait jusqu'à 64). Ils redeviennent des blocs à refaire si des textures reviennent.Une vérification sur une vraie carte de 12 Go reste à faire. Si quelqu'un en a une,
pool::tests::blocks_made_ahead_stay_under_the_line(ignoré) donne la mesure en une seconde.Vérifications (RTX 4060 Laptop 8 Go, Intel UHD) :
Imported from LooperSalty/AnyXboxX. Originally posted by KainanP on 2026-11-27T23:21:56Z.
@akimfomin merci, tu as raison :
0ea1c912gardait la dernière limite sur tout passage où le verrou était pris, même une fois la carte passée au-dessus de 85 % ou sous pression mémoire. Une limite de 64 pouvait alors rester tant qu'aucun passage ne trouvait le verrou libre.Corrigé dans
4d8fb188avec ta règle :SPARE(2), ce qui ne demande rien au pool. L'allocateur lâche les blocs en trop à sa prochaine prise de morceau.Test
pool::tests::a_busy_pool_over_the_line_comes_down_to_spare(verrou tenu, limite à 4, cinq passages à 81 % puis cinq à 90 %) :0ea1c912:FAILED,[4, 4, 4, 4, 4, 4, 4, 4, 4, 4];4d8fb188:[4, 4, 4, 4, 4, 2, 2, 2, 2, 2], ta séquence.Les deux tests de verrou pris attendent maintenant 2 sous la ligne si la machine est sous pression mémoire au moment du test. Sinon ils échoueraient pour une autre raison que celle qu'ils testent.
Imported from LooperSalty/AnyXboxX. Originally posted by akimfomin on 2026-11-28T00:00:35Z.
I checked
4d8fb188against current main4079f2b. There's one conflict, inpool.rs. Main now derives the threshold fromresource::room_percent().saturating_sub(5). On rebase, use that same threshold for both the real empty-count branch and the busy-lock lowering branch. The hardware test currently fills to 81%, so at a configured room of 85% that fill would already be over the new 80% threshold. A fixture tied to the effective limit would still exercise the intended below-line case.I opened one PortBridge Test Lab request for the missing native 12 GB datapoint. It names your existing fixture and keeps the current head separate from the rebased result. Your 8 GB result and the new busy-lock tests are already recorded.
Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-28T00:15:37Z.
Main just took #563 (the VIctory copy moved to Vice-Tay
4f15f09e) and #564 (memory stack), and this PR now conflicts inthird_party/victory/crates/victory-gpu/src/pool.rs. Please rebase on current main, rerun the tests for the files you touch, and force-push. (akimfomin's note on thepool.rsconflict above applies.)Imported from LooperSalty/AnyXboxX. Originally posted by KainanP on 2026-11-28T00:32:45Z.
Rebasée sur
main(132da615, avec #563 et #564) :b45603a0. J'ai réuni les trois commits en un seul, puisqueroom()etspares()étaient réécrits des deux côtés. Les crédits sont dans le message de commit. Merci @akimfomin pour les deux indications, je les ai appliquées toutes les deux.Seuil de
main, pour les deux branches.line_percent()=resource::room_percent().saturating_sub(5), comme dans #564, soit 80 % avec le préréglage 8 Go. Ce même seuil sert :spares_for(memory, keep, pool.empty(), line), vides + ce qui tient sous la ligne) ;SPAREquand le verrou est pris (below_line(memory, keep, line)).Le pool de staging reste sur son chemin séparé, sans changement.
Ce que #564 a changé dans le pool. Seulement le seuil (85 →
room_percent − 5), plus l'argumentfirst_attemptdetexture(). Rien n'y remplace la règle de cette PR : sous le seuil,maingarde toujours 64 blocs vides quelle que soit la place restante. La PR reste donc nécessaire, avec ce nouveau seuil. J'ai adaptéspares_scales_with_room_target(le test de #564) à la nouvelle signature. À 1 Gio sous la ligne il attend maintenant les 16 blocs qui tiennent, au lieu de 64. Les autres cas sont inchangés.Fixtures liées à la limite effective. Elles suivent
line_percent()du processus de test au lieu d'un 81 % fixe :by_the_line(budget, n)place l'utilisation à n blocs et demi sous la ligne, ou n blocs au-dessus ;Le cas « sous la ligne » reste donc sous la ligne quel que soit
VICTORY_TEXTURE_ROOM_PERCENT.Résultats (RTX 4060 Laptop 8 Go, Intel UHD) :
La carte de 12 Go reste simulée : seul le calcul est testé, avec un budget supposé de 11 000 MB (
a_12_gb_card_keeps_its_blocks_below_the_line). Merci aussi pour PortBridge#132 : une mesure native sur 12 Go dira si ce budget supposé est le bon.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.