Ahead: pre-allocate 64 KiB shared and card buffers on a low-priority thread (VICTORY_BUFFERS_AHEAD) #4

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

@⁠adib-cyber007 on GitHub · 2026-12-02 08:40 UTC · original
adib-cyber007:pr/7-buffers-ahead → main · +364 −1 · 4 files · 1 commits · open

Port of trustno1-coder/VIctory-NVIDIA ahead.rs (GPL-3.0) — the #1 next item in docs/FORKS.md.

Why

Creating 64 KiB title buffer copies on the frame thread takes ~0.8 ms each (CreateCommittedResource + MakeResident), contributing to the 3–4 FPS collapse when walking into new areas. This spawns a THREAD_PRIORITY_BELOW_NORMAL worker once the first title buffer copy is requested (never during victory warm/CLI tools) to keep 64 KiB buffers ready.

16 GB RAM / 4 GB VRAM Guardrails

  • Defaults conservatively on ≤20 GiB RAM (residency::very_low_ram()) to 512 initial / 256 kept (16–32 MiB) instead of 4096 / 1024 (256 MiB).
  • Immediately pauses and trims idle buffers under residency::pressured() / critical_commit().
  • Trims device-local buffers whenever VRAM exceeds VICTORY_AHEAD_CARD_PCT (70% default) so it never steals VRAM from textures.

Toggle

  • Disable: VICTORY_BUFFERS_AHEAD=0
  • Tune: VICTORY_BUFFERS_AHEAD=<n>, VICTORY_BUFFERS_KEPT=<n>, VICTORY_AHEAD_CARD_PCT=<10..97>, VICTORY_AHEAD_CARD_KEEP=<n>.

Verification

  • All 4 unit tests in ahead::tests (card_keep_bounds_by_floor_and_cap, trim_idle_releases_only_excess, card_if_ready_stays_inert_without_starting_ahead_thread, retry_gate_rate_limits_failures_independently) and default + --features diagnostics builds passed with zero new warnings.
  • Live walking/streaming frame-time impact needs measurement in-game.
**@⁠adib-cyber007** on GitHub · 2026-12-02 08:40 UTC · [original](https://github.com/ImTaneax/VIctory-RTX3050-4gb/pull/4) `adib-cyber007:pr/7-buffers-ahead` → `main` · +364 −1 · 4 files · 1 commits · open Port of `trustno1-coder/VIctory-NVIDIA` `ahead.rs` (GPL-3.0) — the `#1 next` item in `docs/FORKS.md`. ### Why Creating 64 KiB title buffer copies on the frame thread takes ~0.8 ms each (`CreateCommittedResource` + `MakeResident`), contributing to the 3–4 FPS collapse when walking into new areas. This spawns a `THREAD_PRIORITY_BELOW_NORMAL` worker once the first title buffer copy is requested (never during `victory warm`/CLI tools) to keep 64 KiB buffers ready. ### 16 GB RAM / 4 GB VRAM Guardrails - Defaults conservatively on ≤20 GiB RAM (`residency::very_low_ram()`) to **512 initial / 256 kept (16–32 MiB)** instead of 4096 / 1024 (256 MiB). - Immediately pauses and trims idle buffers under `residency::pressured()` / `critical_commit()`. - Trims device-local buffers whenever VRAM exceeds `VICTORY_AHEAD_CARD_PCT` (70% default) so it never steals VRAM from textures. ### Toggle - Disable: `VICTORY_BUFFERS_AHEAD=0` - Tune: `VICTORY_BUFFERS_AHEAD=<n>`, `VICTORY_BUFFERS_KEPT=<n>`, `VICTORY_AHEAD_CARD_PCT=<10..97>`, `VICTORY_AHEAD_CARD_KEEP=<n>`. ### Verification - All 4 unit tests in `ahead::tests` (`card_keep_bounds_by_floor_and_cap`, `trim_idle_releases_only_excess`, `card_if_ready_stays_inert_without_starting_ahead_thread`, `retry_gate_rate_limits_failures_independently`) and default + `--features diagnostics` builds passed with zero new warnings. - Live walking/streaming frame-time impact needs measurement in-game.
Ported from trustno1-coder/VIctory-NVIDIA (ahead.rs, GPL-3.0) with conservative 16 GB laptop defaults (512 initial / 256 kept = 16-32 MiB on <= 20 GiB RAM) and automatic pause/trim on host memory or VRAM pressure. Eliminates 0.8 ms/buffer synchronous CreateCommittedResource+MakeResident stalls when streaming new areas.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 08:41:45 +00:00
github-bot changed title from ahead: pre-allocate 64 KiB shared and card buffers on a low-priority … to Ahead: pre-allocate 64 KiB shared and card buffers on a low-priority thread (VICTORY_BUFFERS_AHEAD) 2026-12-02 10:22:02 +00:00
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/4/head:github-bot/gh-4'
git switch 'github-bot/gh-4'

Merge

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