Pack & pool: pack tiny before-twin hash buffers in 4 MiB chunks (VICTORY_PACK_SMALL) and trim idle pools (VICTORY_POOL_TRIM) #11

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

@⁠adib-cyber007 on GitHub · 2026-12-02 16:30 UTC · original
adib-cyber007:pr/10-pack-small-and-pool-trim → main · +623 −21 · 5 files · 1 commits · open

Port of trustno1-coder/VIctory-NVIDIA 8f7f28a7 (GPL-3.0), adapted cleanly for 4 GB VRAM GPUs without requiring cardledger.rs.

Why (~200 MB real VRAM + host pool savings)

  1. Pack tiny before-twin hash buffers (VICTORY_PACK_SMALL=1, off by default):
    • Every D3D12 committed buffer consumes at least 64 KiB of VRAM (D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT). Each 64 KiB card copy's before hash table is only 48 bytes, yet ~3,200 of them burn ~200 MB of real VRAM (and Issue #1's log showed 4,775 committed card buffers).
    • With VICTORY_PACK_SMALL=1, crate::pack::BEFORE sub-allocates power-of-two slots (256 B ..= 32 KiB) inside shared 4 MiB UAV chunks (3,200 typical before-twin tables fit in one 4 MiB chunk).
    • Chunks stay in COMMON (implicit UAV promotion per command list), are only accessed via root UAV GPU virtual addresses (shadow.card_before_gpu()), and dropped slots return safely through host::retire behind in-flight submissions + bury_lag.
  2. Idle pool trimming (VICTORY_POOL_TRIM=1, off by default):
    • Tracks Pool::grew on every block allocation; once VICTORY_POOL_TRIM_SECS (default 10 s) passes without growth, staging releases empty blocks down to at most 1.
    • Drops empty texture pool blocks to 0 whenever VRAM usage exceeds VICTORY_POOL_TRIM_CARD_MB (defaults to 85% of DXGI budget on ≤6 GiB GPUs, or 10,000 MB on larger cards).

Toggles

  • VICTORY_PACK_SMALL=1 (default off for clean A/B testing)
  • VICTORY_POOL_TRIM=1 (default off; optional VICTORY_POOL_TRIM_SECS=<n>, VICTORY_POOL_TRIM_CARD_MB=<mb>)

Verification

  • Live RTX 3050 Laptop 4 GB GPU hardware test: host::tests::packed_hash_slots_compare_as_buffers_of_their_own passed (verifying bit-exact compute shader hashing/comparison across multiple packed slots in one 4 MiB chunk + clean slot reuse).
  • All 4 pack::tests (power-of-two classes, 20,000-op randomized non-overlap/alignment fuzz, 3,200 downtown hashes fitting 1 chunk, alignment gap splitting) passed.
  • All 10 pool::tests (including trimmed_pools_keep_empty_blocks_only_after_recent_growth and card_over_target_scales_for_4gb_gpus) passed.
  • Default workspace and --features diagnostics checks compile with zero new warnings.
  • Live VRAM savings need measurement in-game with VICTORY_PACK_SMALL=1 and VICTORY_POOL_TRIM=1.
**@⁠adib-cyber007** on GitHub · 2026-12-02 16:30 UTC · [original](https://github.com/ImTaneax/VIctory-RTX3050-4gb/pull/11) `adib-cyber007:pr/10-pack-small-and-pool-trim` → `main` · +623 −21 · 5 files · 1 commits · open Port of `trustno1-coder/VIctory-NVIDIA` `8f7f28a7` (GPL-3.0), adapted cleanly for 4 GB VRAM GPUs without requiring `cardledger.rs`. ### Why (~200 MB real VRAM + host pool savings) 1. **Pack tiny `before-twin` hash buffers (`VICTORY_PACK_SMALL=1`, off by default):** - Every D3D12 committed buffer consumes at least 64 KiB of VRAM (`D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT`). Each 64 KiB card copy's `before` hash table is only **48 bytes**, yet ~3,200 of them burn **~200 MB of real VRAM** (and Issue #1's log showed 4,775 committed card buffers). - With `VICTORY_PACK_SMALL=1`, `crate::pack::BEFORE` sub-allocates power-of-two slots (`256 B ..= 32 KiB`) inside shared **4 MiB** UAV chunks (3,200 typical `before-twin` tables fit in **one 4 MiB chunk**). - Chunks stay in `COMMON` (implicit UAV promotion per command list), are only accessed via root UAV GPU virtual addresses (`shadow.card_before_gpu()`), and dropped slots return safely through `host::retire` behind in-flight submissions + `bury_lag`. 2. **Idle pool trimming (`VICTORY_POOL_TRIM=1`, off by default):** - Tracks `Pool::grew` on every block allocation; once `VICTORY_POOL_TRIM_SECS` (default `10` s) passes without growth, staging releases empty blocks down to at most `1`. - Drops empty texture pool blocks to `0` whenever VRAM usage exceeds `VICTORY_POOL_TRIM_CARD_MB` (defaults to **85% of DXGI budget on ≤6 GiB GPUs**, or `10,000 MB` on larger cards). ### Toggles - `VICTORY_PACK_SMALL=1` (default off for clean A/B testing) - `VICTORY_POOL_TRIM=1` (default off; optional `VICTORY_POOL_TRIM_SECS=<n>`, `VICTORY_POOL_TRIM_CARD_MB=<mb>`) ### Verification - **Live RTX 3050 Laptop 4 GB GPU hardware test:** `host::tests::packed_hash_slots_compare_as_buffers_of_their_own` passed (verifying bit-exact compute shader hashing/comparison across multiple packed slots in one 4 MiB chunk + clean slot reuse). - All 4 `pack::tests` (power-of-two classes, 20,000-op randomized non-overlap/alignment fuzz, 3,200 downtown hashes fitting 1 chunk, alignment gap splitting) passed. - All 10 `pool::tests` (including `trimmed_pools_keep_empty_blocks_only_after_recent_growth` and `card_over_target_scales_for_4gb_gpus`) passed. - Default workspace and `--features diagnostics` checks compile with zero new warnings. - Live VRAM savings need measurement in-game with `VICTORY_PACK_SMALL=1` and `VICTORY_POOL_TRIM=1`.
Port of trustno1-coder/VIctory-NVIDIA 8f7f28a7 (GPL-3.0), adapted cleanly for 4 GB GPUs:
- pack.rs / shadow.rs / host.rs: VICTORY_PACK_SMALL=1 packs 256 B..32 KiB before-twin hash tables (48 B per 64 KiB card copy, previously ~3,200 committed 64 KiB buffers = ~200 MB of wasted VRAM) into shared 4 MiB UAV chunks with host::retire lifetime safety.
- pool.rs: VICTORY_POOL_TRIM=1 releases empty staging pool blocks past 1 after VICTORY_POOL_TRIM_SECS (default 10 s) without growth, and drops empty texture blocks to 0 whenever VRAM exceeds VICTORY_POOL_TRIM_CARD_MB (default 85% of budget on <= 6 GiB cards, else 10,000 MB).
- Verified with all pack::tests, pool::tests, live RTX 3050 GPU hardware test packed_hash_slots_compare_as_buffers_of_their_own, and default + diagnostics checks.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 17:06:57 +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/11/head:github-bot/gh-11'
git switch 'github-bot/gh-11'

Merge

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