GPU/VRAM: texture pool admission counts resting and fragmented memory as reusable capacity #262
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX#262
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@FunWithFlagsDev on GitHub · 2026-11-26 13:34 UTC · original
<html>Summary
While investigating memory management on NVIDIA GPUs with limited VRAM, I identified a mismatch between the texture pool's reported reusable capacity and the capacity that its allocator can actually reuse for a particular request.
The current accounting may include:
Released pieces that are still subject to the mandatory 2,500 ms resting period.
Fragmented free ranges that cannot accommodate the requested allocation.
Pieces reserved for an allocation whose resource creation has not yet completed.
Pool capacity credited toward requests that cannot use pooled allocation.
This capacity is subtracted from reported local video memory usage when evaluating texture admission.
Consequently, the automatic admission policy may allow additional texture preparation even when the allocator cannot reuse existing memory and must attempt another allocation.
This is particularly relevant to 8–12 GiB GPUs, where the available local memory budget can be substantially smaller than physical VRAM capacity.
The attached archive contains source references, an executable synthetic model, 11 regression tests and a matrix of 360 deterministic evaluations.
1. Affected revision
Repository:
avatarmanz/VIctory-7900XTXCommit:
c9c932cbcc38defd8f1683d62dd298187f565031Primary files:
crates/victory-gpu/src/pool.rscrates/victory-gpu/src/resource.rs2. Current pool accounting
pool.rs:365–374This calculates the difference between total allocated block capacity and the bytes counted as held by textures.
However, this difference is not necessarily equivalent to immediately allocatable capacity.
The allocator itself operates on contiguous, aligned free ranges within individual blocks.
3. Resting pieces are counted before they become reusable
When the final reference to a pooled texture is released, its piece is returned through the following sequence:
pool.rs:450–465However,
Pool::give()does not immediately restore that piece to the allocator's free ranges.The mandatory resting period is:
Only after the deadline is reached can
Pool::reclaim()restore the piece to the block's free ranges.See
pool.rs:315–340.Therefore:
State of a released 64 MiB block | Current accounting credit | Reusable capacity -- | -- | -- Before release | 0 MiB | 0 MiB Immediately after release | 64 MiB | 0 MiB After 2,499 ms | 64 MiB | 0 MiB After the deadline and reclamation | 64 MiB | 64 MiBThe test should exercise the actual allocator and accounting implementation rather than only reproducing their formulas.
No title files, proprietary shaders or physical GPU memory exhaustion are necessary for the initial regression.
11. Relationship to existing VRAM work
I inspected the following related PR revisions.
#119 — Adaptive spare-block retention
Revision:
d39a0b5185cc73bf85ee8ac2d6ca884c9290ae90This proposal reduces empty block retention according to remaining DXGI headroom.
It retains the existing
texture_room()calculation.#205 — Host RAM reduction
Revision:
5a26c94b59cb4d6539a8b2d989177a5d6d2b71abThis proposal introduces idle memory trimming and additional reclamation policies.
It also retains the existing
texture_room()calculation.#212 — Fence-safe LRU eviction and adaptive mip clamping
Revision:
1e710c4bbeb03ce24bd3f2398621c0cb1c572702This proposal introduces texture eviction and budget-aware mip clamping.
It continues using the pool credit when evaluating automatic texture admission, idle texture retention and adaptive mip policy.
The accounting issue may therefore also affect those decisions.
I suggest coordinating any production correction with these contributors rather than creating another independent eviction architecture.
The duplicate search was limited to selected issues, PRs and source paths.
12. Relevance to NVIDIA GPUs with 8 GiB of VRAM
On memory-constrained GPUs, even a small number of temporarily unavailable 64 MiB blocks can materially affect the difference between reported usage and the adjusted admission calculation.
The proposed direction complements:
Adaptive spare-block retention.
Fence-safe texture eviction.
Mip-tail clamping.
Descriptor recycling.
Recovery after transient allocation failure.
The objective is not to reduce texture quality unnecessarily or to reclaim memory that may still be in use.
The objective is to make admission decisions more accurately reflect existing allocation opportunities and the incremental cost of new allocations.
Attachment
avatar_pool_room_audit.zipContents:
README.mdmodel.pytest_model.pymatrix.csvresults.txtReproduction:
No external Python dependencies are required.
Requested verification
Could an independent contributor validate the resting-capacity counterexample using the existing generic
Pool<B>test infrastructure?If reproduced, I suggest first establishing a regression for allocator availability and then evaluating request-aware admission in coordination with the existing VRAM management PRs.
Credits and limitations
AI-assisted source investigation and synthetic modeling using ChatGPT.
Only public repository source and invented test data were used.
No proprietary game files, executable files, shader dumps, console SDK material or gameplay captures are included.
The Python model and its 11 tests were executed successfully.
The investigation does not include a compiled Rust patch, native D3D12 validation, physical VRAM measurements or gameplay benchmarks.
The model does not simulate physical residency, concurrent allocation execution, proactive block growth, or every mandatory allocation and budget override path.
No FPS improvement, VRAM reduction or visual correction is claimed.
</html>## SummaryWhile investigating memory management on NVIDIA GPUs with limited VRAM, I identified a mismatch between the texture pool's reported reusable capacity and the capacity that its allocator can actually reuse for a particular request.
The current accounting may include:
This capacity is subtracted from reported local video memory usage when evaluating texture admission.
Consequently, the automatic admission policy may allow additional texture preparation even when the allocator cannot reuse existing memory and must attempt another allocation.
This is particularly relevant to 8–12 GiB GPUs, where the available local memory budget can be substantially smaller than physical VRAM capacity.
The attached archive contains source references, an executable synthetic model, 11 regression tests and a matrix of 360 deterministic evaluations.
1. Affected revision
Repository:
avatarmanz/VIctory-7900XTXCommit:
c9c932cbcc38defd8f1683d62dd298187f565031Primary files:
crates/victory-gpu/src/pool.rscrates/victory-gpu/src/resource.rs2. Current pool accounting
[pool.rs:365–374](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/pool.rs#L365-L374)This calculates the difference between total allocated block capacity and the bytes counted as held by textures.
However, this difference is not necessarily equivalent to immediately allocatable capacity.
The allocator itself operates on contiguous, aligned free ranges within individual blocks.
3. Resting pieces are counted before they become reusable
When the final reference to a pooled texture is released, its piece is returned through the following sequence:
[pool.rs:450–465](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/pool.rs#L450-L465)However,
Pool::give()does not immediately restore that piece to the allocator's free ranges.The mandatory resting period is:
Only after the deadline is reached can
Pool::reclaim()restore the piece to the block's free ranges.See
[pool.rs:315–340](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/pool.rs#L315-L340).Therefore:
The resting period should remain intact. The issue is the accounting credit applied before the capacity becomes reusable.
4. Synthetic 8 GiB GPU counterexample
Consider the following invented memory state:
Assume:
The existing automatic admission policy subtracts
texture_room()from reported usage.See
[resource.rs:1725–1754](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/resource.rs#L1725-L1754).With the default 90% threshold:
The current policy admits the request because adjusted usage is below the threshold.
However:
Reported usage already exceeds the automatic admission threshold.
If a new eligible 32 MiB texture request reaches the allocator before the resting pieces are reclaimed, it cannot reuse those pieces.
It must either obtain another block, fail allocation, or proceed through an applicable allocation fallback.
This demonstrates a mismatch between the accounting credit and allocator eligibility.
It does not establish that the driver will necessarily refuse the allocation or that a device failure will occur.
5. Fragmentation is a separate problem
Even counting only genuinely free ranges is insufficient to determine whether a particular texture fits.
Consider one 64 MiB block:
Total free capacity is 32 MiB.
The largest contiguous free range is only 16 MiB.
A texture requiring a contiguous 32 MiB placement cannot use this block despite its reported free capacity.
Repeating this arrangement across 32 blocks produces 1 GiB of aggregate free capacity without any existing range that can accommodate a 32 MiB allocation.
Alignment constraints can also prevent an allocation from fitting into a range whose byte count would otherwise be sufficient.
The allocator correctly checks individual aligned ranges in
Ranges::take().The admission policy does not receive equivalent request-specific information.
6. Allocation reservations in progress
There is another accounting interval during pooled texture creation.
See
[pool.rs:668–725](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/pool.rs#L668-L725).The sequence is approximately:
take_ripe().CreatePlacedResource().HELDafter successful creation.Between steps 1 and 4, the reserved range is no longer available to another allocation but is not yet represented in
HELD.A concurrent accounting query may therefore credit capacity that has already been reserved.
On placement failure, the piece is returned through the resting mechanism rather than immediately becoming free.
This is a source-level accounting observation. The attached model does not reproduce a native multithreaded D3D12 execution.
7. Requests that cannot reuse pooled capacity
Some resource descriptions cannot use the texture pool.
The existing allocator also imposes limits on individual pooled allocation sizes.
See
[pool.rs:224–275](https://github.com/avatarmanz/VIctory-7900XTX/blob/c9c932cb/crates/victory-gpu/src/pool.rs#L224-L275).A committed texture cannot consume an existing free piece from this pool.
Consequently, subtracting the entire pool credit when deciding whether such a request should proceed may not represent its incremental memory requirement.
The same consideration applies when a pooled placement fails and the creation path falls back to a committed allocation.
An existing compatible pooled range also does not necessarily imply zero additional physical residency cost.
8. Asset-free differential validation
The attached Python model compares the current accounting formula with reusable free ranges and an illustrative request-aware allocation growth gate.
The matrix contains:
Total: 360 deterministic evaluations.
These are separate, potentially overlapping categories.
All 11 Python tests passed.
The tests cover:
The inputs are deliberately constructed counterexamples, not samples from gameplay or estimates of real-world failure frequency.
9. Suggested correction
I suggest separating diagnostic capacity accounting from actual allocation admission.
A. Distinguish the pool's memory states
Maintain or derive separate values for:
This would make it possible to identify how much pool memory is genuinely reusable and how much is temporarily unavailable.
B. Consider the requested allocation
Where practical, determine whether an existing block can accommodate the requested size and alignment before relying on pool capacity as an admission credit.
A total free-byte count alone cannot establish this.
C. Gate incremental allocations separately
If no compatible range exists, consider evaluating the incremental memory cost of:
take_ripe()may allocate a spare block even after finding a compatible existing range. Therefore, successful reuse and proactive growth should be considered separately.D. Preserve safety and existing policy semantics
Any production correction should preserve:
In particular, avoid calling a memory-budget helper that recursively acquires the texture pool mutex while that mutex is already held.
A production solution should also account for concurrent reservations and stale DXGI budget samples.
The attached growth gate is an illustrative model, not a proposed drop-in production implementation.
10. Proposed native CPU-only regression
A useful first step would be to add tests directly to the existing
pool.rstest module using the genericPool<B>implementation.The existing tests already use synthetic pool blocks and controlled timestamps without requiring GPU allocations.
Suggested regression sequence:
Pool<u32>.Pool::give()path.Additional controls should cover:
The test should exercise the actual allocator and accounting implementation rather than only reproducing their formulas.
No title files, proprietary shaders or physical GPU memory exhaustion are necessary for the initial regression.
11. Relationship to existing VRAM work
I inspected the following related PR revisions.
#119 — Adaptive spare-block retention
Revision:
d39a0b5185cc73bf85ee8ac2d6ca884c9290ae90This proposal reduces empty block retention according to remaining DXGI headroom.
It retains the existing
texture_room()calculation.#205 — Host RAM reduction
Revision:
5a26c94b59cb4d6539a8b2d989177a5d6d2b71abThis proposal introduces idle memory trimming and additional reclamation policies.
It also retains the existing
texture_room()calculation.#212 — Fence-safe LRU eviction and adaptive mip clamping
Revision:
1e710c4bbeb03ce24bd3f2398621c0cb1c572702This proposal introduces texture eviction and budget-aware mip clamping.
It continues using the pool credit when evaluating automatic texture admission, idle texture retention and adaptive mip policy.
The accounting issue may therefore also affect those decisions.
I suggest coordinating any production correction with these contributors rather than creating another independent eviction architecture.
The duplicate search was limited to selected issues, PRs and source paths.
12. Relevance to NVIDIA GPUs with 8 GiB of VRAM
On memory-constrained GPUs, even a small number of temporarily unavailable 64 MiB blocks can materially affect the difference between reported usage and the adjusted admission calculation.
The proposed direction complements:
The objective is not to reduce texture quality unnecessarily or to reclaim memory that may still be in use.
The objective is to make admission decisions more accurately reflect existing allocation opportunities and the incremental cost of new allocations.
Attachment
avatar_pool_room_audit.zipContents:
README.mdmodel.pytest_model.pymatrix.csvresults.txtReproduction:
No external Python dependencies are required.
Requested verification
Could an independent contributor validate the resting-capacity counterexample using the existing generic
Pool<B>test infrastructure?If reproduced, I suggest first establishing a regression for allocator availability and then evaluating request-aware admission in coordination with the existing VRAM management PRs.
Credits and limitations
avatar_pool_room_audit.zip
Only public repository source and invented test data were used.
No proprietary game files, executable files, shader dumps, console SDK material or gameplay captures are included.
The Python model and its 11 tests were executed successfully.
The investigation does not include a compiled Rust patch, native D3D12 validation, physical VRAM measurements or gameplay benchmarks.
The model does not simulate physical residency, concurrent allocation execution, proactive block growth, or every mandatory allocation and budget override path.
No FPS improvement, VRAM reduction or visual correction is claimed.