Repository navigation
Conversation
…pies let go to tell refaults, budgets with hysteresis, idle rules) and a deterministic benchmark replaying rules against made-up loads or traces (cargo run -p victory-tiers --release --example tiers_bench)
…or in 8 of the last 44 s waits 10 s before it is let go, and one made again within 30 s of its last let-go waits 20, 40, then 60 s, where the PC's idle time alone gave 2-5 s and windows in use were let go and made again seconds later; with memory to spare nothing changes
…e line every thread of a hot copy writes; the policy module and IdleRule's floor described as they work; tests for a reader behind the newest note, notes from the past ignored, many threads on the same seconds, the cut keeping warm spares and freeing a tied group, limits not known, and block_covering in the crate itself
…ooks every second), the line's words as it counts; the windows' steps looked up under one hold of the lock a sweep; the books forget past their window when windows are made too, so they empty and take no lock again
…ry emulation) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Sharing a
|
|
Ran the crate's own tooling independently (Linux, via WSL) and read through the diff. One bug, and a limitation of the benchmark worth knowing about before using it to settle the other open memory PRs.
Consequence: The benchmark can't fairly evaluate the other open memory PRs it names in "Checked for overlap." Tried using The reason: The other two named PRs don't fit the rule-comparison abstraction either, for different reasons. #1562 changes block layout and placement (16/8 MiB size-segregated pools against None of this is a problem with the PR as written, since it never claims to have run these comparisons itself, just that the tool could. Worth knowing before anyone takes a Tested: |
The problem
The Xbox Series X has one pool of memory that the CPU and the GPU share. A game writes a buffer with the CPU and the GPU reads it a moment later, from the same bytes, at no cost.
A PC has two pools: system RAM, and the graphics card's own memory. Its GPU reads its own memory fast and system RAM slowly, over PCIe. So VIctory keeps copies of the console's memory, and each copy lives in one of several places:
Every copy costs something wherever it lives:
Today, every kind of copy decides this on its own. Textures, buffer copies, windows of memory, staging, send buffers and scratch each have a separate rule: their own idea of "idle", their own thresholds, their own reaction to memory pressure. We counted over a dozen independent idle rules and as many separate "are we under pressure?" switches. None of them knows how often a copy is actually used, and none can tell whether dropping a copy was a mistake.
One example of what that costs. VIctory copies memory outside buffers in "windows" (6 MiB each). When the PC runs short of memory, the window rule shortens its idle time to 2–5 seconds. A window that a game reads in bursts goes idle for a few seconds between them. It is dropped, then rebuilt moments later: a new buffer, a wait for it to become resident, and a full copy. In one play log with the system nearly out of commit, a third of all windows dropped came back within 30 seconds, and three in four did in the worst stretch, about 7.6 seconds later on average. The memory freed came straight back, and each rebuild was a small stall.
What this PR does
It gives VIctory a shared foundation for deciding where copies live, modelled on how storage systems tier data: keep what is used close to the compute, push out what is not, and decide from measured use rather than per-feature guesses. It then uses that foundation to fix the window problem above.
1. A small, reusable crate:
victory-tiers. It has no Direct3D, no game code and no OS calls, so other forks and other emulators of shared-memory consoles can use it. It provides:2. The window fix (
victory-gpu). Under memory pressure, a window is no longer dropped just because it sat idle for 2–5 seconds:With memory to spare nothing changes, and the idle time is never made shorter than today's. A log line next to the frame-rate line says how many windows were kept and how many still came back.
Why it matters beyond windows
The window fix is the first user. The point is that these decisions can now be made in one place, from the same measurements, and checked before they ship. The benchmark already shows this on its own scenarios:
Both are made-up loads, not play. They show the kind of question the benchmark answers in seconds, without a play session. This PR changes neither the card nor the spare pools.
What to expect
How it was tested
Unit tests:
cargo test -p victory-tiers --locked: 33 passed, including checks that replays are deterministic and that notes from many threads on the same seconds count once;cargo test -p victory-gpu --lib --locked -- tiers:: shadow::: 76 passed.cargo test -p victory-gpu --lib --locked: all pass but tests outside this PR that also fail or flake without it:shader_cache::tests::every_switch_of_the_translator_is_in_the_keyfails the same way on untouched41adb551;watch::tests::a_late_fault_leaves_the_guard_taken_sinceandhost::card_steps::tests::shared_scratch_eliminates_flight_settle_end_to_endeach failed once in a full parallel run, and pass alone, with and without this PR.Clippy:
cargo clippy -p victory-tiers --all-targets --locked -- -D warningsis clean. Nothing new in the victory-gpu lines touched. The workspace-D warningsrun stops invictory-shaderon41adb551, before this change.Benchmark for the window rule (
cargo run -p victory-tiers --release --example tiers_bench, made-up load: 900 windows, memory pressure rising over 5 minutes):The same load with plenty of memory gives identical results for both. Almost all of the gain comes from the "came back soon" part; the "in use" part adds little.
Not yet verified: a play session on this branch. The play figures in "The problem" come from a fork build running the same rule.
Checked for overlap
Searched open PRs at
41adb551for "tier", "idle window", "windows let go", "commit pressure", "spare", "memory bench", "unified memory", "eviction".memguard.host/membench.rs(existing) measures what the real GPU layer holds over synthetic frames.victory-tierscompares decision rules on modelled loads. They complement each other.