gpu: windows outside buffers on a 1 MiB grid with tails by default (1-2 GB less RAM) #106

Open
github-bot wants to merge 1 commit from github-bot/gh-106 into main AGit
Owner

@⁠martindevbr on GitHub · 2026-11-26 00:29 UTC · original
martindevbr:pr/window-grid → main · +26 −15 · 1 files · 1 commits · open

Problema / Problem

Uma janela de memória do título fora de buffers é um buffer do host na RAM do PC, inteiro residente por menos que seja lido: 2,5–3,3 GB numa rodada, cerca de metade fora do que foi pedido. Numa máquina de 32 GB a RAM livre acaba enquanto o mundo faz streaming, e os quadros acima de 1 s (page faults, remaps esperando o kernel) dominam o fps.

Windows of title memory outside buffers are fully resident host buffers: 2.5–3.3 GB per run, about half never asked for. On 32 GB machines free RAM runs out during streaming and >1 s frames dominate.

Mudança / Change

Liga por padrão os switches que já existiam (desligados): VICTORY_WINDOW_KB=1024 e VICTORY_WINDOW_TAILS=1. Para voltar: VICTORY_WINDOW_KB=4096 VICTORY_WINDOW_TAILS=0. Testes de grade/tails atualizados (cargo test -p victory-gpu window: 10 ok).

Medido / Measured

RTX 3060 12 GB, Ryzen 5 5600GT, 32 GB RAM, preset do README; 3 rodadas de cada lado + 1 de confirmação com o padrão novo; primeiros 120 s no mundo (as rodadas entram no mundo em momentos diferentes):

antes / before depois / after
janelas / windows 2,5–3,1 GB 1,4–1,8 GB
memória privada / private 25,5–27,1 GB 23,4–24,8 GB
page faults em quadros >1 s 4,4–7,2 mi 1,4–3,9 mi
quadros >1 s 41–75 s 28–52 s (faixas se sobrepõem)
quadro usual 103–152 ms 82–131 ms

Sem perda de dispositivo nem crash; últimos quadros renderizam normalmente (não comparados no mesmo ponto da cena). Como o próprio código das janelas avisa, uma grade mais fina pode manter a mesma memória em mais de uma janela: os bytes copiados por quadro subiram na única amostra comparada (380 vs 262 MB). A redução de RAM se repetiu em todas as rodadas; o efeito nos quadros longos vai na direção certa mas ainda está dentro do ruído.

**@⁠martindevbr** on GitHub · 2026-11-26 00:29 UTC · [original](https://github.com/uiliannn/VItoriaBr/pull/106) `martindevbr:pr/window-grid` → `main` · +26 −15 · 1 files · 1 commits · open ## Problema / Problem Uma janela de memória do título fora de buffers é um buffer do host na RAM do PC, **inteiro residente** por menos que seja lido: 2,5–3,3 GB numa rodada, cerca de metade fora do que foi pedido. Numa máquina de 32 GB a RAM livre acaba enquanto o mundo faz streaming, e os quadros acima de 1 s (page faults, remaps esperando o kernel) dominam o fps. Windows of title memory outside buffers are fully resident host buffers: 2.5–3.3 GB per run, about half never asked for. On 32 GB machines free RAM runs out during streaming and >1 s frames dominate. ## Mudança / Change Liga por padrão os switches que já existiam (desligados): `VICTORY_WINDOW_KB=1024` e `VICTORY_WINDOW_TAILS=1`. Para voltar: `VICTORY_WINDOW_KB=4096 VICTORY_WINDOW_TAILS=0`. Testes de grade/tails atualizados (`cargo test -p victory-gpu window`: 10 ok). ## Medido / Measured RTX 3060 12 GB, Ryzen 5 5600GT, 32 GB RAM, preset do README; 3 rodadas de cada lado + 1 de confirmação com o padrão novo; primeiros 120 s no mundo (as rodadas entram no mundo em momentos diferentes): | | antes / before | depois / after | |---|---|---| | janelas / windows | 2,5–3,1 GB | **1,4–1,8 GB** | | memória privada / private | 25,5–27,1 GB | **23,4–24,8 GB** | | page faults em quadros >1 s | 4,4–7,2 mi | 1,4–3,9 mi | | quadros >1 s | 41–75 s | 28–52 s (faixas se sobrepõem) | | quadro usual | 103–152 ms | 82–131 ms | Sem perda de dispositivo nem crash; últimos quadros renderizam normalmente (não comparados no mesmo ponto da cena). Como o próprio código das janelas avisa, uma grade mais fina pode manter a mesma memória em mais de uma janela: os bytes copiados por quadro subiram na única amostra comparada (380 vs 262 MB). A redução de RAM se repetiu em todas as rodadas; o efeito nos quadros longos vai na direção certa mas ainda está dentro do ruído.
A window of title memory outside buffers is a host buffer in the PC's
memory, all of it resident however little of it is read: 2.5-3.3 GB of a
run, about half of it outside what was ever asked for. On a 32 GB machine
the PC runs out of free memory while the world streams in, and frames
over 1 s (page faults, remaps waiting on the kernel) dominate the frame
rate. VICTORY_WINDOW_KB=1024 and VICTORY_WINDOW_TAILS=1 (both already
there, off) are now the default.

RTX 3060 12 GB, Ryzen 5 5600GT, 32 GB of RAM, the README preset, three
runs each way plus one confirming run with the new default, measured over
the first 120 s in the world (runs enter the world at different times):
- windows 2.5-3.1 GB -> 1.4-1.8 GB
- private bytes 25.5-27.1 GB -> 23.4-24.8 GB
- page faults in frames over 1 s: 4.4-7.2 -> 1.4-3.9 million
- frames over 1 s: 41-75 s -> 28-52 s (ranges overlap: noise is large)
- usual frame 103-152 ms -> 82-131 ms
No device loss, no crash; last frames of the runs render normally (not
compared at one point of the scene). As the window code notes, a finer
grid can hold the same memory in more than one window: title bytes copied
a frame went up in the one sample compared (380 vs 262 MB).

VICTORY_WINDOW_KB=4096 VICTORY_WINDOW_TAILS=0 go back to whole 4 MiB
windows.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:44:09 +00:00
Author
Owner

@⁠fladit123 on GitHub · 2026-11-26 19:56 UTC · original

I reviewed the window allocation path on current VItoriaBr main (1361e190).

The smaller grid and tails proposed here look promising. However, loose() can still allocate overlapping windows when an existing containing window begins in an earlier 4 MiB cell.

I reproduced this behavior in a small synthetic model of the selection algorithm: three requests produced 5 MiB of logical window allocations, although one existing 3 MiB window could satisfy all three.

This is an algorithm-level result, not a D3D12 or gameplay measurement.

I also found fxceless/victory-fork#1362, which implements opt-in window reuse and superseded-window reclamation, with encouraging results on an RTX 3060 Ti 8 GB.

I would like to investigate adapting and independently validating that approach on VItoriaBr with my RTX 4060 8 GB and 32 GB of RAM, preserving the original author's attribution.

A four-way comparison could separate the effects of the smaller grid, window reuse, and their combination.

Would this be a useful complementary contribution to your PR?

AI-assisted source analysis using OpenAI ChatGPT.

**@⁠fladit123** on GitHub · 2026-11-26 19:56 UTC · [original](https://github.com/uiliannn/VItoriaBr/pull/106#issuecomment-7202134206) I reviewed the window allocation path on current VItoriaBr main (`1361e190`). The smaller grid and tails proposed here look promising. However, `loose()` can still allocate overlapping windows when an existing containing window begins in an earlier 4 MiB cell. I reproduced this behavior in a small synthetic model of the selection algorithm: three requests produced 5 MiB of logical window allocations, although one existing 3 MiB window could satisfy all three. This is an algorithm-level result, not a D3D12 or gameplay measurement. I also found fxceless/victory-fork#1362, which implements opt-in window reuse and superseded-window reclamation, with encouraging results on an RTX 3060 Ti 8 GB. I would like to investigate adapting and independently validating that approach on VItoriaBr with my RTX 4060 8 GB and 32 GB of RAM, preserving the original author's attribution. A four-way comparison could separate the effects of the smaller grid, window reuse, and their combination. Would this be a useful complementary contribution to your PR? AI-assisted source analysis using OpenAI ChatGPT.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/106/head:github-bot/gh-106'
git switch 'github-bot/gh-106'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-106'
git switch 'github-bot/gh-106'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-106'
git switch 'github-bot/gh-106'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-106'
git switch 'main'
git merge --squash 'github-bot/gh-106'
git switch 'main'
git merge --ff-only 'github-bot/gh-106'
git switch 'main'
git merge 'github-bot/gh-106'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.