Pressure MemoryPo #3683
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?
Imported from ivall/xcl. Originally posted by willvixtor on 2026-12-02T09:09:22Z.
Pressure MemoryPolicy::classify(
const SegmentTelemetry& s,
Pressure previous
) const
{
if (s.budgetBytes == 0)
return Pressure::Unknown;
}
// Regression: Critical must not clear at 95% or 94%.
t.local.usageBytes = 990;
auto critical99 = p.evaluate(t);
CHECK(critical99.localPressure == Pressure::Critical);
CHECK(critical99.requestFenceSafeEviction);
t.local.usageBytes = 950;
auto critical95 = p.evaluate(t);
CHECK(critical95.localPressure == Pressure::Critical);
CHECK(critical95.requestFenceSafeEviction);
t.local.usageBytes = 940;
auto critical94 = p.evaluate(t);
CHECK(critical94.localPressure == Pressure::Critical);
// At 93%, leave Critical and enter High.
t.local.usageBytes = 930;
auto high93 = p.evaluate(t);
CHECK(high93.localPressure == Pressure::High);
CHECK(!high93.requestFenceSafeEviction);
// At 86%, leave High and enter Watch.
t.local.usageBytes = 860;
auto watch86 = p.evaluate(t);
CHECK(watch86.localPressure == Pressure::Watch);
// At 76%, leave Watch and return to Normal.
t.local.usageBytes = 760;
auto normal76 = p.evaluate(t);
CHECK(normal76.localPressure == Pressure::Normal);
auto decision = ChooseMip(assetDemand, memoryPressure);
// 1. Check whether the requested mip is already resident.
if (!texture.IsMipResident(decision.targetMip))
{
// 2. Do not exceed the upload budget for this frame.
if (uploadQueue.CanAccept(texture.GetMipUploadSize(
decision.targetMip)))
{
// 3. Queue upload without blocking the render thread.
uploadQueue.Enqueue(texture, decision.targetMip);
}
}
// 4. Keep the old resident mip until the GPU copy fence completes.
// 5. Publish the new mip only after successful completion.
// 6. Retire old resources only after their last-use fence.
Comprehensive Implementation Proposal — GTA VI PC Memory Management, GPU Optimization and World Streaming
Thank you for reviewing the memory-management proposal.
The source-level corrections and regression tests have already been provided. I would like to expand the scope of the proposal and outline the full range of improvements that could be implemented in XCL.
The objective is not simply to monitor GPU memory. It is to develop an adaptive memory-management and resource-streaming system capable of handling demanding world-loading scenarios, especially on GPUs with 8 GB, 12 GB and 16 GB of dedicated VRAM, as well as systems using shared memory.
Implement a centralized memory-pressure controller that continuously evaluates:
The controller should dynamically adjust memory-management behavior according to actual hardware conditions.
Memory pressure should trigger graduated responses instead of waiting for allocation failures.
Texture streaming should become fully integrated with the memory-pressure controller.
Possible improvements include:
The goal is to maintain visual quality while avoiding unnecessary VRAM consumption.
Instead of reacting only after memory pressure occurs, XCL could implement predictive resource streaming.
Potential inputs:
This could allow the engine to prepare high-priority assets before they become visible while avoiding unnecessary preloading.
Predictive streaming should be conservative and automatically reduce its workload when memory pressure increases.
Implement a resource eviction manager that identifies resources according to:
Prefer releasing obsolete, reloadable and low-priority resources.
Never release resources that are still being used by in-flight GPU operations.
All eviction operations must respect GPU fences and resource lifetime rules.
World loading can generate substantial upload activity.
Introduce a scheduler that:
This could help prevent large asset transfers from creating noticeable frame-time spikes.
Investigate whether world-loading stalls originate from:
These systems should be measured independently.
Where supported by the engine architecture, consider parallel asset decompression, background resource preparation, asynchronous shader compilation and non-blocking upload scheduling.
Do not assume every loading stall is caused by VRAM pressure.
Create hardware profiles based on actual available memory budgets rather than fixed GPU model names.
For example:
8 GB VRAM
12 GB VRAM
16 GB VRAM
These should be dynamic policies, not hardcoded assumptions.
The system must also account for operating-system GPU reservations, other applications and changing DXGI budgets.
Ensure correct behavior across:
Do not assume that shared memory provides the same performance as dedicated VRAM.
Memory budgets and usage must be evaluated independently, and the engine must avoid excessive transfers between CPU and GPU memory.
Develop a dedicated diagnostic mode that captures events around world-loading stalls.
Record:
This would make it possible to identify the actual bottleneck instead of guessing.
Consider integrating memory pressure with selected rendering-quality parameters.
Potential candidates include:
Quality reductions should be gradual, reversible and restricted to resources that can safely tolerate them.
Avoid changing unrelated rendering settings without evidence that they contribute to the problem.
Test at least three configurations:
Test multiple VRAM capacities and different hardware configurations.
Perform repeated cold-load and warm-load tests using identical routes, settings, drivers and game builds.
Measure:
The implementation should only be considered successful when measurable improvements are reproducible without visual corruption, instability or increased loading times.
Phase 1 — Correctness
Phase 2 — Diagnostics
Phase 3 — Streaming
Phase 4 — Predictive Optimization
Phase 5 — Hardware Scaling
Phase 6 — Performance Validation
Final Objective
The broader objective is to investigate whether XCL can benefit from a unified, adaptive GPU memory and world-streaming architecture.
Rather than relying on static memory limits or waiting for allocation failures, the engine could continuously evaluate available resources, prioritize important assets, schedule transfers intelligently and respond to memory pressure before it becomes a critical problem.
This proposal is intended to give contributors several independently testable implementation paths.
Not every feature needs to be implemented simultaneously. The highest priority should be correctness, diagnostics and reproducible evidence, followed by streaming integration and predictive optimization.
I believe this approach deserves technical evaluation before the entire proposal is dismissed.
The ultimate goal is to make XCL more stable, scalable and efficient across a wider range of PC hardware, particularly GPUs with limited dedicated VRAM.
Originalmente postado por @willvixtor em https://github.com/xcl-dev/xcl/issues/3596#issuecomment-7335040605