vkback: cache GTT room state and pace refused_slots recovery with hysteresis #188
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/vktory6--VKtory!188
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-188"
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?
@deuxque on GitHub · 2026-12-02 06:25 UTC · original
deuxque:pr/gtt-refused-slot-recovery→main· +239 −32 · 4 files · 1 commits · openProblem
On 8 GB cards (#103 RX 6650 XT 8 GB), GPU-written targets (~4.0 GB) plus
umemtitleVRAM (~3.0 GB) keep VRAM above its 50% line (~4,087 MiB on an 8,176 MiB budget) for the
entire session. Even after #111 fixed GTT free-arena accounting, three defects in
residency.rs/srclife.rsremained:refused_slots(greenfield/vkback/src/residency.rs:111-120):refused_slotswas only drained when VRAM transitionedfalse -> true. On 8 GB cardswhere VRAM stays over its line, slots refused during a transient GTT spike (48k-56k in
#103 post-#111) stayed cached in
slot_cachewith null (black) descriptors forever evenafter
let_go_idlefreed GTT space and new textures spilled cleanly toPlace::Gtt.over_line()on every GTT spill (greenfield/vkback/src/srclife.rs:101):room_for_textures()cached only VRAM room for 100 ms; everytexture_place()callpast the VRAM line fell through to uncached
over_line()(2xvkGetPhysicalDeviceMemoryProperties2plus arena scans), costing 26 ms of 28 ms (93%) of placed image creation in #103 (
d1d6f39).residency.rs:105-122):Reopening at
0bytes without deadband and draining all ofrefused_slotsinside asingle 100 ms cached-open window let a large refusal backlog immediately push the heap
back over its line.
Change
VulkanBackend::room_at: (Instant, bool)with a pure, Vulkan-freeresidency::RoomGate(initialized open withchecked_at: None) caching(vram_open, gtt_open)for 100 ms (invalidated bylet_go_idle).-2%resume hysteresis (next_open: closes atover >= 0, reopens onceover <= -(budget / 50)and< 0, matching the-2%quiet threshold oflet_go_fromand handling
budget == 0safely).refused_slotsrecovery on fresh probes only (REFUSED_DRAIN_BATCH = 64per100 ms TTL when either VRAM or GTT is open), keeping the cache valid for the TTL so
retried allocations settle before the next probe and
texture_place()does not regressto per-call
over_line()queries while draining.texture_room()inarena.rs::take_retry_slotswhen!self.refused_slots.is_empty()so an existing backlog keeps draining even when no new textures are being created.
room_for_textures()returning VRAM-only room (vram_open) for existingcallers (
lib.rs:3291).over_line()reserve math,umemallocation, orUMEM_MEMREPORTformatting.Measurements & Tests
greenfield/vkback/src/residency.rs, no GPU required):vram_permanently_over_gtt_recovers_drains_refused_slots: VRAM at +5 GiB, GTT dropsto
-3%-> returnsPlace::Gttand drains 64 slots (previously 0 drained).hysteresis_blocks_oscillation_between_zero_and_minus_two_pct: verifies-1%staysclosed,
-2%reopens,-1%stays open,0closes, andbudget == 0safety.ttl_paced_bounded_drain_no_burst_and_stops_on_pressure: 200 refused slots drain64 -> 0 (within TTL) -> 64 -> 0 (when both heaps >= 0)with 3 total probes.gtt_spill_uses_cached_line_within_ttl: 10 consecutive GTT-spill placements within100 ms invoke 1 probe (down from 10);
invalidate()triggers probe #2.vram_room_semantics_preserved:vram_open == false && gtt_open == truekeepsVRAM room
falsewhile placing inPlace::Gtt.cargo test --manifest-path greenfield/Cargo.toml --workspace --no-fail-fast:250 passed, 6 ignored, 0 failed.
cargo clippy --manifest-path greenfield/Cargo.toml -p vkback --all-targets -- -D warnings:0 warnings.
cargo test --manifest-path greenfield/Cargo.toml -p vkback --test policy:6 passed, 0 failed (
lib.rsunchanged at 4,250 non-test lines).tools/build.sh: exit 0 (42 s warm cache).AI use
Model: Gemini 4 Neon, human-directed scope and design review. All unit, clippy, policy,
and build checks ran on an isolated Linux / RDNA 2 host without modifying the 4 GiB VRAM
floor or
over_line()math. On-card full-title testing on an 8 GB GPU (confirmingpost-#111 black-texture recovery and
texture_placeframe-time reduction in #103) remainspending.
Refs #103 #111
@copilot-pull-request-reviewer[bot] on GitHub · 2026-12-02 06:25 UTC · original · reviewed
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
@vktory6 on GitHub · 2026-12-02 15:28 UTC · original
Thanks, one cached (vram, gtt) room check is the right structure: it removes the 26 of 28 ms
over_linecost from #103. Two fixes:next_opencomputes the GTT hysteresis margin from the VRAM budget, becauseover_lineonly returnsv.heap_budget.let_go_from's threshold. The pacing keeps refused slots black for longer, so either justify it with a run on an 8 GB card or drop it.#191 fixes the same black textures more simply. Once this lands, #191 shrinks to its object-texture spill and sweep invalidation.
@deuxque on GitHub · 2026-12-02 18:29 UTC · original
over_line()now returns aRoomSamplecarrying bothvram_budgetandgtt_budgetsoRoomGate::apply_probe(andlet_go_idle) passes each heap its own budget tonext_open/let_go_from, covered by a unit test with distinct 8,176 MiB VRAM and 16,384 MiB GTT budgets (e549981).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.