Repository navigation
fix(overlay): reclaim spare GPU pools and runtime caches while resting - #1933
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1875
Root cause
window::Host(crates/rune/src/window/state/rest.rs,crates/rune/src/window/host/lifecycle.rs),OverlayCorehad noReststate machine and never calledRenderer::give_back,TextSystem::rest,ImageAtlas::rest, orRewind::rest.El::cachetextures (up to 64 MiB), unused backdrops/blur pyramids, oversized staging chunks, and stale text/image/rewind caches indefinitely while idle.Changes
stateDiagram-v2 [*] --> Rested Rested --> Drawing: Drew (!prewarm) Drawing --> Drawing: Drew (postpones deadline) Drawing --> Idle: Woke (now >= due) / GiveBackUnused Drawing --> Rested: Unseen (hide/occluded) / GiveBackAll + Retire Idle --> Rested: Unseen (hide/occluded) / GiveBackAll + Retire Idle --> Drawing: Drewwindow::state::rest(Rest,RestEvent,RestEffect,step,low_memory,REST_AFTER,PRESSED_AFTER) topub(crate)and re-exported them fromcrates/rune/src/window.rs.RestintoOverlayCore(crates/rune/src/overlay.rs,overlay/draw.rs,overlay/any_host.rs,overlay/input.rs,overlay/lifetime.rs):OverlayFrame::settlerecordsRestEvent::Drewwhen!prewarm.OverlayCore::wake_deadlinechainsself.rest.deadline()(one-shot; clears toNoneinRest::IdleandRest::Rested, so idle overlays wake zero times and draw zero frames).OverlayCore::wake_duestepsRestEvent::Wokeafterpresence_dueand beforeretire.poll_due.OverlayCore::stop_drawing(whenrelease != Release::Now) and macOSOverlayCore::occluded(true)stepRestEvent::Unseen;park()andRelease::Nowresetself.rest = Rest::Rested.OverlayCore::give_backmirrorswindow::Host::give_back, polling once non-blocking only when!all && renderer.has_oversized_uploads_in_flight(), and onallcallingself.retire.retire_now(&gpu, now)plusrenderer.trim_uploads()instead of blockingwait_indefinitely()on shared GPU devices.crates/rune/src/overlay/rest_tests.rscovering one-shot idle rest with zero wakes/frames, 100+ alternating keyed opacity-transition swaps reclaiming both spare layer targets (spare_layers() == 0, HALtextures-2) afterREST_AFTER, andUnseenreclaiming live scratch targets.Verification
cargo test -p rune --lib --features rune/test-gpu-counters overlay::(81 passed),window::(168 passed), and confirmed all 3 new tests fail before wiringRest.cargo test -p rune --lib overlay::(101 passed, covering macOSoccluded(true)rest path).cargo check -p rune -p rune-kit --tests.cargo check -p rune --no-default-features --target wasm32-unknown-unknown.scripts/file-size.sh(0 errors).