Repository navigation
fix(victory-hle): eliminate dstorage ENQUEUED leak/desync, bound page history, and reuse capped scratch buffers - #401
Closed
Lewandox wants to merge 1 commit into
Conversation
…nd reuse scratch buffers
Collaborator
Author
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.
Summary
Fixes unbounded memory retention / FIFO desync and reduces per-request heap churn in DirectStorage (
third_party/victory/crates/victory-hle/src/modules/dstorage.rs):ENQUEUEDleak, FIFO desync, and global mutex contention:as_enqueuedpushed eachPAGE_DESTINATIONrequest's page-array snapshot into a globalENQUEUEDMutex<Option<HashMap<usize, VecDeque<Vec<usize>>>>>, andfilled()popped from it when the worker ran.close_lane) while requests were unsubmitted/queued, or ifexecute()failed beforeinto_destination()(e.g. invalid args, read failure, zlib error), those snapshots leaked forever and permanently shifted the FIFO queue for any future request reusing that page-array address (and parallel workers could even pop each other's snapshots out of order).enqueued_pages: Option<Vec<usize>>directly to eachCommand::Read/Lane::readsentry /Jobremoves the globalENQUEUEDmutex completely, guarantees zero leaks on close or early failure, and pairs every worker execution with its exact enqueue-time snapshot.LAST_RUN/SAME_RUNStracking memory:LAST_RUNandSAME_RUNSinto a singlePAGE_HISTORYmap (one lock + one lookup instead of two) and caps it atMAX_PAGE_HISTORY(4,096) entries so long sessions with churning page-array addresses cannot grow unboundedly.with_scratch, max 2 buffers, each capped at4 MiBon return) for file-read bounce buffers, compressed source reads, zlib+BCPack intermediate buffers, and non-consecutive physical-page staging buffers.VirtualAlloc/VirtualFreeTLB shootdowns during world streaming while dropping any oversized (>4 MiB) buffer immediately so idle workers never retain large RAM.PAGE_DESTINATIONrequest early drops its enqueue snapshot cleanly without corrupting subsequent requests on the same page-array address.PAGE_HISTORYstays strictly bounded atMAX_PAGE_HISTORYeven under heavy address churn.with_scratchcalls preserve independent buffers, reuse capacity up to the cap, and drop oversized buffers on return.Verification
cargo test -p victory-hle --lib modules::dstorage::testscargo xtask policyinsidethird_party/victory