feat(gpu): observe physical-page access and rank eligible VRAM promotions #303

Open
github-bot wants to merge 12 commits from github-bot/gh-303 into main AGit
Owner

@⁠tommiehansen on GitHub · 2026-12-03 09:51 UTC · original
tommiehansen:perf/t02-observe-page-access → main · +993 −33 · 7 files · 12 commits · open

Standard benchmark — 2026-12-05

Reproducible CI result · head 0d36619b720a · Linux hosted CPU-only, Standard, four ABBA blocks (8 runs per arm).

Workload Baseline (ms) Candidate (ms) Time change Verification
Promotion ranking shadow 0.008 0.018 +106.17% Identical; regression
VRAM pressure budget 0.002 0.002 −0.00% Identical; no significant difference

Same head; VICTORY_POOL_ACCESS_RANK=0 → 1. Ranking overhead is roughly 10 µs on this synthetic workload; benefit from physical residency decisions remains unmeasured. Migration workloads unsupported.

Negative values indicate reduced CPU time. Synthetic workloads, not gameplay FPS.


What this does

Observe physical-page access and rank eligible VRAM promotions.

Checks

  • Off-by-default and main parity: Ranking opt-in with shadow mode; diagnostics opt-in. Default ranking retains original order; prove full default-path parity.
  • Docs move with code: settings documentation is present; F1 menu exposure is deferred until the upstream menu reorganization is incorporated. The experimental switch remains available via the command line.
  • No unrelated cleanup: Observation and ranking form one measured residency experiment; upstream scope review remains welcome.
  • A test must exercise the change: tied_weights_preserve_contiguous_runs_without_splitting, seven portable production tests previously passed; final-head rerun and explicit fail-before pending.
  • Queue checked on 2026-12-04: #356 complementary cap policy; #398/#392/#522 overlap residency/UMA; fork #4/#5 are separate external follow-ups.
  • Run cargo xtask policy on the final revision; no new game assets or build output intended.

Verified

Current review head: 5ae52b37add8cdd52e3a0fdc965dd23d92c232ac. Existing measurements and commands are retained below at their original revisions. No fresh compile, policy or hardware test is claimed by this metadata review.

Cost

Ranking has CPU cost; prior trace changed scores but not selected set, drift high. No live promotion-return/FPS benefit proven.


Detailed implementation and historical validation

Problem

GPU heat alone does not distinguish an allocation the CPU repeatedly accesses from a hot page that can stay on the card. These pages can compete for scarce promotion slots and trigger repeated movement and readback stalls.

Implementation and correctness

  • Track observed CPU touches, mapped read attempts, completed GPU-assisted readbacks and existing GPU heat hints by physical pool generation. Diagnostics report the four observation cohorts. Aliases share the same pool record. These hints describe instrumented accesses and never prove GPU-only ownership.
  • Optionally lower the promotion weight of an already-eligible hot page after a recent CPU touch or readback. The penalty decays and resets with the physical pool instance. It matters only when promotion slots are scarce. Existing strikes, retirement, visibility and required copies remain authoritative.
  • Shadow mode logs which pages the alternative ranking would select or defer while preserving the original decisions.

Source and dependencies

The ranking extends this PR's physical-pool instrumentation and incorporates the one-commit follow-up reviewed in fork PR #1. ReVIctory's allocation observations motivate measuring how the CPU uses allocations. Their results describe a different Windows implementation. This PR can land independently of the adaptive VRAM-budget experiment and does not require the RayQuery stack.

Source and workload Reported observation or result Relevance
Issue #14, RX 9070 9,628 MB in RAM / 2,279 MB in VRAM; low GPU occupancy Memory placement is a plausible contributor to dependent-load latency.
#165, RX 9060 XT 114,609 / 124,585 promoted pages (~92%) immediately pulled back on CPU touch when all pools could move Demonstrates the cost of promoting frequently CPU-accessed pages.
#255, settled-page policy Mean copy time 6.3 → 1.0 ms (−84.1%); worst 5 s window 35.3 → 6.6 ms Existing strike policy reduces repeated migration; FPS stayed around 26.
ReVIctory memory classification, Windows implementation 956 / 971 MB (98.5%) of observed Heap 0/2 bytes classified as non-readback Shows why CPU access intent is useful when authoritative information exists.
Same ReVIctory implementation, Mode 2 Copy-back 8.8 → 0.5 ms (−94.3%); GPU compare passes 42–44 → 1 Motivates access-aware policy, not a prediction for this PR.

These are separate external reports. ReVIctory uses explicit allocation classification and readback elimination; this PR does neither. It changes only ranking among already eligible pages when promotion capacity is scarce, without assuming that unobserved accesses cannot occur.

Comparison with the existing approach

Behavior Original policy Optional ranking in this PR
Promotion eligibility and retirement Existing rules Unchanged
Recent CPU touches/readbacks Existing safety and strike mechanisms Additional decaying ranking penalty
Unknown CPU access No new evidence Baseline ranking weight
Physical alias/reuse Existing mapping rules Observations scoped to physical pool instance
Required copies and visibility Preserved Preserved
Evaluation without movement changes Baseline Shadow comparison

Why this should be merged

The observation layer makes the memory-placement hypothesis testable, and the optional ranking can be compared without changing decisions in shadow mode. It complements rather than replaces #255's strike policy and is independently selectable from the budget controller. Start with shadow data and promotion/return rates before enabling ranking in production.

Validation

Previously passed standard and diagnostics Windows-target checks for victory-gpu. The extracted portable observation test checked that repeated aliases do not count a physical page twice. The portable ranking test covered aging, repeated observations and saturating weights. The combined Phase 2 branch also passed 293 portable shader tests, with two ignored, and both Windows-target modes. These results were reused for this publication update.

Limits and testing

Hardware benchmarking was unavailable. Please compare the same RT-enabled route on RX 9060 XT 16 GB at native 1080p and RX 9070 XT at native 1440p with frame generation disabled. Track quick returns, readback bytes, GPU-hot resident bytes, policy cost and P99. Observed-access coverage, behavior under alias remapping and net frame-time impact remain unverified.

Use VICTORY_POOL_ACCESS=1 in a diagnostics build to report observation cohorts. Use VICTORY_POOL_ACCESS_RANK=shadow to compare proposed rankings or 1 to apply them. Unset the ranking switch to use the original order.

Pass 2B — ranking cost versus residency outcomes

The earlier CPU comparison measures the histogram rewrite against the previous ranking implementation. This comparison measures the cost of enabling CPU-access weighting at the same revision, 719a6e1.

CPU fixture, 8,192 candidates and 2,048 slots Weighting off Weighting on Paired change (95% CI)
Build promotion runs 10.875 µs 18.646 µs +67.14% (+53.37% to +82.16%)
Selected pages 2,048 2,048 0 swaps

Apple M5, Standard profile, four interleaved A/B/B/A blocks. Baseline drift was −16.2%, so treat the magnitude as fixture-specific. CPU access lowered 5,462 scores without changing the selected set on this trace. The revised fixture checks both selected sets against a sort-based oracle and hashes complete run identities. Seven portable production tests passed, including a separate contested example where recent CPU access does change the chosen pages. The fixture times production run selection, excluding physical migration, telemetry and shadow outcome tracking.

RX 6700 XT community results used an older revision, RT off and a locally lowered title cap. They also showed little change in selection despite a substantial wait queue. When the live set fills the title cap, physical headroom is sufficient, and ordinary cold retirement frees nothing, the promotion limit can be zero. Reordering candidates cannot create a slot. Lucalocastro’s title-cap experiment addresses that separate condition by retiring a bounded number of residents and rechecking the budget on the next wave. It should be evaluated separately for quick returns, migration volume and P99, especially as workload and RT pressure change. Lucalocastro’s shadow outcome tracking is already included as c20157c.

./tools/benchmark-suite/run compare 719a6e19b2ad3aa17fd8dd76c8aaedce15b5478c 719a6e19b2ad3aa17fd8dd76c8aaedce15b5478c \
  --cpu-only --suite residency --profile standard --blocks 4 \
  --base-env VICTORY_POOL_ACCESS_RANK=0 --cand-env VICTORY_POOL_ACCESS_RANK=1 \
  --out local/benchmarks/pass2b-303-ranking-verified

Final-head CI update

At 5ae52b37add8cdd52e3a0fdc965dd23d92c232ac, Windows MSVC cargo check --locked -p victory-gpu --all-targets --features diagnostics and 7 targeted tests (residency_ranking::tests) passed, with zero test failures (audit). The upstream merge snapshot also passed asset policy; with the independent repository-wide policy fix #528 applied, all four switch tests pass (verification). No dependency on #528 for runtime behavior. Hardware/gameplay verification and any remaining checklist items are still open for review. Ready for review does not imply those are completed.

Queue refresh — 2026-12-05

Merged upstream main b581f7e0a8086158953a64068ba29305d5450d68 into the existing branch without rewriting history. New head: 3c37855f09d97ba752c115110f4702dfc18d0efa. The follow-up in the fork remains separate; live promotion outcomes still need the planned hardware run.

Fresh pinned CI audit is the verification record for this revision; previous tests apply to the previously stated heads. #528 remains a separate policy prerequisite, not a runtime dependency. No new gameplay or GPU timing claim.

Review follow-up

Commit 0d36619 fixes the missing residency metadata at both demotion call sites. Windows-target Cargo check with diagnostics and tests enabled passed locally using a check-only allocator shim. Native execution is tracked on the fork’s audit/pr303-diagnostics workflow.

**@⁠tommiehansen** on GitHub · 2026-12-03 09:51 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/303) `tommiehansen:perf/t02-observe-page-access` → `main` · +993 −33 · 7 files · 12 commits · open ## Standard benchmark — 2026-12-05 [Reproducible CI result](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47503640056/job/145622974529) · head `0d36619b720a` · Linux hosted CPU-only, Standard, four ABBA blocks (8 runs per arm). | Workload | Baseline (ms) | Candidate (ms) | Time change | Verification | |---|---:|---:|---:|---| | Promotion ranking shadow | 0.008 | 0.018 | +106.17% | Identical; regression | | VRAM pressure budget | 0.002 | 0.002 | −0.00% | Identical; no significant difference | Same head; `VICTORY_POOL_ACCESS_RANK=0` → `1`. Ranking overhead is roughly 10 µs on this synthetic workload; benefit from physical residency decisions remains unmeasured. Migration workloads unsupported. Negative values indicate reduced CPU time. Synthetic workloads, not gameplay FPS. --- ## What this does Observe physical-page access and rank eligible VRAM promotions. ## Checks - [ ] Off-by-default and main parity: Ranking opt-in with shadow mode; diagnostics opt-in. Default ranking retains original order; prove full default-path parity. - [ ] Docs move with code: settings documentation is present; F1 menu exposure is deferred until the upstream menu reorganization is incorporated. The experimental switch remains available via the command line. - [ ] No unrelated cleanup: Observation and ranking form one measured residency experiment; upstream scope review remains welcome. - [ ] A test must exercise the change: `tied_weights_preserve_contiguous_runs_without_splitting`, seven portable production tests previously passed; final-head rerun and explicit fail-before pending. - [x] Queue checked on 2026-12-04: #356 complementary cap policy; #398/#392/#522 overlap residency/UMA; fork #4/#5 are separate external follow-ups. - [ ] Run `cargo xtask policy` on the final revision; no new game assets or build output intended. ## Verified Current review head: `5ae52b37add8cdd52e3a0fdc965dd23d92c232ac`. Existing measurements and commands are retained below at their original revisions. No fresh compile, policy or hardware test is claimed by this metadata review. ## Cost Ranking has CPU cost; prior trace changed scores but not selected set, drift high. No live promotion-return/FPS benefit proven. --- ## Detailed implementation and historical validation ## Problem GPU heat alone does not distinguish an allocation the CPU repeatedly accesses from a hot page that can stay on the card. These pages can compete for scarce promotion slots and trigger repeated movement and readback stalls. ## Implementation and correctness - Track observed CPU touches, mapped read attempts, completed GPU-assisted readbacks and existing GPU heat hints by physical pool generation. Diagnostics report the four observation cohorts. Aliases share the same pool record. These hints describe instrumented accesses and never prove GPU-only ownership. - Optionally lower the promotion weight of an already-eligible hot page after a recent CPU touch or readback. The penalty decays and resets with the physical pool instance. It matters only when promotion slots are scarce. Existing strikes, retirement, visibility and required copies remain authoritative. - Shadow mode logs which pages the alternative ranking would select or defer while preserving the original decisions. ## Source and dependencies The ranking extends this PR's physical-pool instrumentation and incorporates the one-commit follow-up reviewed in [fork PR #1](https://github.com/tommiehansen/VIctory-xmem/pull/1). [ReVIctory's allocation observations](https://github.com/ReTerryDavis/ReVIctory/blob/631b2ed4/docs/surgical-recomp.md) motivate measuring how the CPU uses allocations. Their results describe a different Windows implementation. This PR can land independently of the adaptive VRAM-budget experiment and does not require the RayQuery stack. ## Evidence from related implementations | Source and workload | Reported observation or result | Relevance | |---|---|---| | [Issue #14](https://git.gtahub.st/github/lobomfz--VIctory-xmem/issues/14), RX 9070 | 9,628 MB in RAM / 2,279 MB in VRAM; low GPU occupancy | Memory placement is a plausible contributor to dependent-load latency. | | [#165](https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/165), RX 9060 XT | 114,609 / 124,585 promoted pages (~92%) immediately pulled back on CPU touch when all pools could move | Demonstrates the cost of promoting frequently CPU-accessed pages. | | [#255](https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/255), settled-page policy | Mean copy time 6.3 → 1.0 ms (**−84.1%**); worst 5 s window 35.3 → 6.6 ms | Existing strike policy reduces repeated migration; FPS stayed around 26. | | [ReVIctory memory classification](https://github.com/ReTerryDavis/ReVIctory/blob/631b2ed4/docs/surgical-recomp.md), Windows implementation | 956 / 971 MB (98.5%) of observed Heap 0/2 bytes classified as non-readback | Shows why CPU access intent is useful when authoritative information exists. | | Same ReVIctory implementation, Mode 2 | Copy-back 8.8 → 0.5 ms (**−94.3%**); GPU compare passes 42–44 → 1 | Motivates access-aware policy, not a prediction for this PR. | These are separate external reports. ReVIctory uses explicit allocation classification and readback elimination; this PR does neither. It changes only ranking among already eligible pages when promotion capacity is scarce, without assuming that unobserved accesses cannot occur. ## Comparison with the existing approach | Behavior | Original policy | Optional ranking in this PR | |---|---|---| | Promotion eligibility and retirement | Existing rules | Unchanged | | Recent CPU touches/readbacks | Existing safety and strike mechanisms | Additional decaying ranking penalty | | Unknown CPU access | No new evidence | Baseline ranking weight | | Physical alias/reuse | Existing mapping rules | Observations scoped to physical pool instance | | Required copies and visibility | Preserved | Preserved | | Evaluation without movement changes | Baseline | Shadow comparison | ## Why this should be merged The observation layer makes the memory-placement hypothesis testable, and the optional ranking can be compared without changing decisions in shadow mode. It complements rather than replaces #255's strike policy and is independently selectable from the budget controller. Start with shadow data and promotion/return rates before enabling ranking in production. ## Validation Previously passed standard and diagnostics Windows-target checks for `victory-gpu`. The extracted portable observation test checked that repeated aliases do not count a physical page twice. The portable ranking test covered aging, repeated observations and saturating weights. The combined Phase 2 branch also passed 293 portable shader tests, with two ignored, and both Windows-target modes. These results were reused for this publication update. ## Limits and testing Hardware benchmarking was unavailable. Please compare the same RT-enabled route on RX 9060 XT 16 GB at native 1080p and RX 9070 XT at native 1440p with frame generation disabled. Track quick returns, readback bytes, GPU-hot resident bytes, policy cost and P99. Observed-access coverage, behavior under alias remapping and net frame-time impact remain unverified. Use `VICTORY_POOL_ACCESS=1` in a diagnostics build to report observation cohorts. Use `VICTORY_POOL_ACCESS_RANK=shadow` to compare proposed rankings or `1` to apply them. Unset the ranking switch to use the original order. ### Pass 2B — ranking cost versus residency outcomes The [earlier CPU comparison](https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/303) measures the histogram rewrite against the previous ranking implementation. This comparison measures the cost of enabling CPU-access weighting at the same revision, `719a6e1`. | CPU fixture, 8,192 candidates and 2,048 slots | Weighting off | Weighting on | Paired change (95% CI) | |---|---:|---:|---:| | Build promotion runs | 10.875 µs | 18.646 µs | +67.14% (+53.37% to +82.16%) | | Selected pages | 2,048 | 2,048 | 0 swaps | Apple M5, Standard profile, four interleaved A/B/B/A blocks. Baseline drift was −16.2%, so treat the magnitude as fixture-specific. CPU access lowered 5,462 scores without changing the selected set on this trace. The revised fixture checks both selected sets against a sort-based oracle and hashes complete run identities. Seven portable production tests passed, including a separate contested example where recent CPU access does change the chosen pages. The fixture times production run selection, excluding physical migration, telemetry and shadow outcome tracking. [RX 6700 XT community results](https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/303) used an older revision, RT off and a locally lowered title cap. They also showed little change in selection despite a substantial wait queue. When the live set fills the title cap, physical headroom is sufficient, and ordinary cold retirement frees nothing, the promotion limit can be zero. Reordering candidates cannot create a slot. [Lucalocastro’s title-cap experiment](https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/303) addresses that separate condition by retiring a bounded number of residents and rechecking the budget on the next wave. It should be evaluated separately for quick returns, migration volume and P99, especially as workload and RT pressure change. Lucalocastro’s shadow outcome tracking is already included as `c20157c`. ```sh ./tools/benchmark-suite/run compare 719a6e19b2ad3aa17fd8dd76c8aaedce15b5478c 719a6e19b2ad3aa17fd8dd76c8aaedce15b5478c \ --cpu-only --suite residency --profile standard --blocks 4 \ --base-env VICTORY_POOL_ACCESS_RANK=0 --cand-env VICTORY_POOL_ACCESS_RANK=1 \ --out local/benchmarks/pass2b-303-ranking-verified ``` ### Final-head CI update At `5ae52b37add8cdd52e3a0fdc965dd23d92c232ac`, Windows MSVC `cargo check --locked -p victory-gpu --all-targets --features diagnostics` and 7 targeted tests (residency_ranking::tests) passed, with zero test failures ([audit](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47438443784)). The upstream merge snapshot also passed asset policy; with the independent repository-wide policy fix #528 applied, all four switch tests pass ([verification](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47440075807)). No dependency on #528 for runtime behavior. Hardware/gameplay verification and any remaining checklist items are still open for review. Ready for review does not imply those are completed. ### Queue refresh — 2026-12-05 Merged upstream main `b581f7e0a8086158953a64068ba29305d5450d68` into the existing branch without rewriting history. New head: `3c37855f09d97ba752c115110f4702dfc18d0efa`. The follow-up in the fork remains separate; live promotion outcomes still need the planned hardware run. [Fresh pinned CI audit](https://github.com/tommiehansen/VIctory-xmem/actions/runs/47466412636) is the verification record for this revision; previous tests apply to the previously stated heads. #528 remains a separate policy prerequisite, not a runtime dependency. No new gameplay or GPU timing claim. ### Review follow-up Commit 0d36619 fixes the missing residency metadata at both demotion call sites. Windows-target Cargo check with diagnostics and tests enabled passed locally using a check-only allocator shim. Native execution is tracked on the fork’s audit/pr303-diagnostics workflow.
Record observed CPU accesses and existing GPU heat hints against the physical page index. Aliases contribute to the same entry. Pool generations keep reused indices separate, and diagnostics distinguish unobserved, CPU-only, GPU-hint-only and mixed pages.

Keep the counters diagnostic-only and off by default. No residency decision uses the observations. Uninstrumented accesses may exist in any cohort.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 09:53:10 +00:00
github-bot changed title from um: observe CPU and GPU hints by physical pool generation to residency: observe physical-page access and rank eligible VRAM promotions 2026-12-03 11:04:00 +00:00
Age CPU touches and readback observations on the physical pool instance and rank only already eligible promotions when slots are scarce. Preserve retirement, strikes, writes, visibility and all copies. Give unobserved pages the baseline weight and make the experimental order opt-in.

Add a shadow comparison of selected pages and a deterministic test of decay, repeated observations and saturating weights. Standard and diagnostic Windows-target checks passed. Hardware measurements are pending.
Preserve every original production-code hunk and integrate the switch documentation alongside the newly added upstream settings. No behavior changes beyond the existing PR.
Preserve upstream migration cadence, indexed pool lookups and all-fit fast path. Keep the existing observation and ranking changes, and insert the ranking regression test alongside upstream's new tests.
Author
Owner

@⁠El-Biiscuit on GitHub · 2026-12-03 18:08 UTC · original

Hardware data from an RX 6700 XT 12 GB (gfx1031, resizable BAR), in case it helps.

Setup: this PR merged on 842767a (no conflicts), diagnostics build, VICTORY_POOL_ACCESS=1, VICTORY_LOG=info,victory_gpu::um::residency=debug. Built-in benchmark mode (VICTORY_BENCH=nort: Series X, FSR 4 Quality 1440p → 3840x2160), 4 min per run with the last 3 min measured (MangoHud). The scene is a city save on foot with the camera turning for the whole run (VICTORY_KEYS). Order A B B A, same save restored before each run.

  • A = VICTORY_POOL_ACCESS_RANK=shadow
  • B = VICTORY_POOL_ACCESS_RANK=1

On this card 842767a gives the title card_mb_for_title=1024.

Observation cohorts (last report of each run, all four runs look the same):

pool (generation) pages CPU only GPU hint only both unobserved
15 (5) 99,776 ~83,000 ~1,500 ~4,500 ~10,500
7 (4) 2,960 ~285 ~440 ~1,430 ~805
1 (1) 35,184 0–160 ~4,080 3–4 ~31,000
5 (6) 11,360 4 5,449 0 5,907

98 % of the CPU-touched pages are in one pool, and almost all of them are CPU-only. The pools the GPU uses are barely touched by the CPU.

Movement:

  • About 7,500 pages moved up per run.
  • 458–554 went down on a CPU touch, of which only 14–34 within two seconds of promotion.
  • 0 down for room, 0 pages wait for room.

Shadow ranking:

  • Run 1: 25 logged passes; the ranking would have changed 2 of them (3 pages promoted, 3 deferred).
  • Run 4: 23 passes, no change.
  • Median plan_us about 100 µs.

Frame times (2 runs per arm, so only indicative):

A (shadow) B (rank=1)
median frame time 89.6 ms [88.7–90.5] 87.8 ms [87.1–88.4]
p99 284 ms 257 ms

Since the ranking changes almost nothing here, I would not attribute this difference to the PR. Run-to-run variation between sessions on this scene is about the same size.

Reading: in this scene promotion room is never short, and quick returns are rare after the strike policy (#255), so the ranking has nothing to act on. I have not tested a case where room is actually scarce, for example a larger VICTORY_CARD_KEPT_MB or a heavier scene. I can run one if you tell me which setting you want.

**@⁠El-Biiscuit** on GitHub · 2026-12-03 18:08 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/303#issuecomment-7387666628) Hardware data from an RX 6700 XT 12 GB (gfx1031, resizable BAR), in case it helps. **Setup:** this PR merged on `842767a` (no conflicts), diagnostics build, `VICTORY_POOL_ACCESS=1`, `VICTORY_LOG=info,victory_gpu::um::residency=debug`. Built-in benchmark mode (`VICTORY_BENCH=nort`: Series X, FSR 4 Quality 1440p → 3840x2160), 4 min per run with the last 3 min measured (MangoHud). The scene is a city save on foot with the camera turning for the whole run (`VICTORY_KEYS`). Order A B B A, same save restored before each run. - **A** = `VICTORY_POOL_ACCESS_RANK=shadow` - **B** = `VICTORY_POOL_ACCESS_RANK=1` On this card `842767a` gives the title `card_mb_for_title=1024`. **Observation cohorts** (last report of each run, all four runs look the same): | pool (generation) | pages | CPU only | GPU hint only | both | unobserved | |---|---|---|---|---|---| | 15 (5) | 99,776 | ~83,000 | ~1,500 | ~4,500 | ~10,500 | | 7 (4) | 2,960 | ~285 | ~440 | ~1,430 | ~805 | | 1 (1) | 35,184 | 0–160 | ~4,080 | 3–4 | ~31,000 | | 5 (6) | 11,360 | 4 | 5,449 | 0 | 5,907 | 98 % of the CPU-touched pages are in one pool, and almost all of them are CPU-only. The pools the GPU uses are barely touched by the CPU. **Movement:** - About 7,500 pages moved up per run. - 458–554 went down on a CPU touch, of which only 14–34 within two seconds of promotion. - `0 down for room`, `0 pages wait for room`. **Shadow ranking:** - Run 1: 25 logged passes; the ranking would have changed 2 of them (3 pages promoted, 3 deferred). - Run 4: 23 passes, no change. - Median `plan_us` about 100 µs. **Frame times** (2 runs per arm, so only indicative): | | A (shadow) | B (rank=1) | |---|---|---| | median frame time | 89.6 ms [88.7–90.5] | 87.8 ms [87.1–88.4] | | p99 | 284 ms | 257 ms | Since the ranking changes almost nothing here, I would not attribute this difference to the PR. Run-to-run variation between sessions on this scene is about the same size. **Reading:** in this scene promotion room is never short, and quick returns are rare after the strike policy (#255), so the ranking has nothing to act on. I have not tested a case where room is actually scarce, for example a larger `VICTORY_CARD_KEPT_MB` or a heavier scene. I can run one if you tell me which setting you want.
Author
Owner

@⁠tommiehansen on GitHub · 2026-12-03 18:22 UTC · original

Thanks for the detailed testing, @⁠El-Biiscuit!

Could you repeat the same A/B/B/A test with a higher VICTORY_CARD_KEPT_MB, aiming to reduce the reported card_mb_for_title from 1024 to around 512 MB? The goal is to see whether the optimization helps when VRAM space is limited (pages wait for room above zero).

RT would also be interesting if it runs well on your card, but keeping RT off is absolutely fine.

**@⁠tommiehansen** on GitHub · 2026-12-03 18:22 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/303#issuecomment-7388035487) Thanks for the detailed testing, @⁠El-Biiscuit! Could you repeat the same A/B/B/A test with a higher `VICTORY_CARD_KEPT_MB`, aiming to reduce the reported `card_mb_for_title` from 1024 to around 512 MB? The goal is to see whether the optimization helps when VRAM space is limited (`pages wait for room` above zero). RT would also be interesting if it runs well on your card, but keeping RT off is absolutely fine.
Author
Owner

@⁠lucalocastro on GitHub · 2026-12-03 18:36 UTC · original

@⁠El-Biiscuit, thanks for posting the four RX 6700 XT runs and flagging how rarely the ranking changed a decision. Would you be willing to try draft PR #4 on the same card with a scene that puts VRAM under pressure? RT off is fine. The draft build (f0f259b) uses a fixed reserve, so the best check is whether the log actually shows pages wait for room above zero.

  • Shadow run: Could you paste the final page ranking outcomes line with deferred_quick, deferred_promoted, kept_quick and kept_promoted, plus card_mb_for_title and the waiting count? That lets us compare how often pages in each group returned to RAM within two seconds. A zero count is worth reporting too.
  • Frame times: On the same build, save and route, could you repeat your four MangoHud runs in off/on/on/off order (VICTORY_POOL_ACCESS_RANK=0/1/1/0) and share the median and P99 in milliseconds for each run? That would let us compare the effect with the variation between repeats.

The tester guide has the exact commands. If you only have time for the shadow run, those counters alone would already help. Thanks!

**@⁠lucalocastro** on GitHub · 2026-12-03 18:36 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/303#issuecomment-7388391685) @⁠El-Biiscuit, thanks for posting the four RX 6700 XT runs and flagging how rarely the ranking changed a decision. Would you be willing to try [draft PR #4](https://github.com/tommiehansen/VIctory-xmem/pull/4) on the same card with a scene that puts VRAM under pressure? RT off is fine. The draft build (`f0f259b`) uses a fixed reserve, so the best check is whether the log actually shows `pages wait for room` above zero. - **Shadow run:** Could you paste the final `page ranking outcomes` line with `deferred_quick`, `deferred_promoted`, `kept_quick` and `kept_promoted`, plus `card_mb_for_title` and the waiting count? That lets us compare how often pages in each group returned to RAM within two seconds. A zero count is worth reporting too. - **Frame times:** On the same build, save and route, could you repeat your four MangoHud runs in off/on/on/off order (`VICTORY_POOL_ACCESS_RANK=0/1/1/0`) and share the median and P99 in milliseconds **for each run**? That would let us compare the effect with the variation between repeats. The [tester guide has the exact commands](https://github.com/lucalocastro/VIctory-xmem/blob/f0f259ba61dfe1cfe7f8c1e295e18ad77174f298/docs/DIAGNOSTICS.md#test-cpu-aware-ram-to-vram-promotion). If you only have time for the shadow run, those counters alone would already help. Thanks!
Author
Owner

@⁠El-Biiscuit on GitHub · 2026-12-03 19:40 UTC · original

@⁠tommiehansen Here is the 512 MB run, plus a correction to my earlier comment.

Correction. "0 pages wait for room" came from the last residency report of each run only. The full series shows that room was short for a while at 1024 MB too. In all four runs, from about 30 s to about 2 min 30 s into the run, 1,900–3,150 pages were waiting and promotions stalled at ~2,970. After that the queue emptied. Most of the shadow passes I reported happened in that phase, and the ranking would still have changed only 3 pages.

512 MB. VICTORY_CARD_KEPT_MB doesn't exist on main or on this branch (it comes from #267). The title room also has a 1 GiB floor, CARD_FOR_TITLE_AT_LEAST. So I built this PR (21ab7ed on 842767a, diagnostics build) with that one constant lowered to 512 << 20. The logs show card_mb_for_title=512 in every run.

Same harness as before: VICTORY_POOL_ACCESS=1, city save on foot with the camera turning, 4 min per run, last 3 min measured, RT off. Order A B B A A B B A; all 8 runs valid, 0 kernel faults.

  • A = VICTORY_POOL_ACCESS_RANK=shadow
  • B = VICTORY_POOL_ACCESS_RANK=1
A (shadow) B (rank=1)
peak pages waiting for room 5,118–5,247 5,173–5,351
down for room 0 0
promotions per run 6,016–6,159 5,963–6,155
shadow passes evaluated (passes where ranking changes something) 26–43 (0–1) –
pages it would swap per run 0–1 –
demoted on CPU touch within 2 s 1, 4, 1, 3 4, 6, 26, 11
median frame time, median of 4 runs [range] 92.8 ms [91.3–97.7] 91.4 ms [89.4–93.0]
p99, median of 4 runs [range] 276.1 ms [229.6–348.5] 263.1 ms [249.9–309.2]

Per run (A, B, B, A, A, B, B, A):

  • median ms: 97.7, 93.0, 90.6, 92.0, 91.3, 92.1, 89.4, 93.6
  • p99 ms: 348.5, 252.4, 249.9, 293.4, 258.9, 309.2, 273.7, 229.6

At 512 MB the title room fills about 30 s in (~368 MB of paged title memory on the card). From then until the end of the run, 4,300–5,350 pages wait, and promotions almost stop: run 2 went from 6,132 to 6,142 over the last 3 min. Nothing frees room for them: 0 down for room and only 56–244 cold demotions per run. So the ranking rarely has a slot to hand out. When room is this short, the bottleneck seems to be that no on-card page gets evicted, not the order of the candidates. Frame times are the same within run-to-run variation.

One thing I can't explain. With ranking on, quick returns (demoted on CPU touch within 2 s) were higher in both scarce-room tests:

  • 512 MB: A 1–4, B 4–26.
  • VICTORY_PAGE_MOVE_MB=4 at 1024 MB: A 7–12, B 10–21. That follow-up run has the same harness, and B's peak queue there was ~2,900–3,000 pages.

The shadow arm says the ranking changes almost no decision, so I'm not attributing this to the PR. The numbers are small, but you may know whether RANK=1 does anything beyond reordering.

RT: not tried on this card yet.

@⁠lucalocastro Thanks. I'll look at the tester guide for your draft and come back if I can run the shadow counters on this setup.

**@⁠El-Biiscuit** on GitHub · 2026-12-03 19:40 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/303#issuecomment-7390057240) @⁠tommiehansen Here is the 512 MB run, plus a correction to my earlier comment. **Correction.** "`0 pages wait for room`" came from the **last** residency report of each run only. The full series shows that room was short for a while at 1024 MB too. In all four runs, from about 30 s to about 2 min 30 s into the run, 1,900–3,150 pages were waiting and promotions stalled at ~2,970. After that the queue emptied. Most of the shadow passes I reported happened in that phase, and the ranking would still have changed only 3 pages. **512 MB.** `VICTORY_CARD_KEPT_MB` doesn't exist on main or on this branch (it comes from #267). The title room also has a 1 GiB floor, `CARD_FOR_TITLE_AT_LEAST`. So I built this PR (`21ab7ed` on `842767a`, diagnostics build) with that one constant lowered to `512 << 20`. The logs show `card_mb_for_title=512` in every run. Same harness as before: `VICTORY_POOL_ACCESS=1`, city save on foot with the camera turning, 4 min per run, last 3 min measured, RT off. Order A B B A A B B A; all 8 runs valid, 0 kernel faults. - **A** = `VICTORY_POOL_ACCESS_RANK=shadow` - **B** = `VICTORY_POOL_ACCESS_RANK=1` | | A (shadow) | B (rank=1) | |---|---|---| | peak pages waiting for room | 5,118–5,247 | 5,173–5,351 | | `down for room` | 0 | 0 | | promotions per run | 6,016–6,159 | 5,963–6,155 | | shadow passes evaluated (passes where ranking changes something) | 26–43 (0–1) | – | | pages it would swap per run | 0–1 | – | | demoted on CPU touch within 2 s | 1, 4, 1, 3 | 4, 6, 26, 11 | | median frame time, median of 4 runs [range] | 92.8 ms [91.3–97.7] | 91.4 ms [89.4–93.0] | | p99, median of 4 runs [range] | 276.1 ms [229.6–348.5] | 263.1 ms [249.9–309.2] | Per run (A, B, B, A, A, B, B, A): - median ms: 97.7, 93.0, 90.6, 92.0, 91.3, 92.1, 89.4, 93.6 - p99 ms: 348.5, 252.4, 249.9, 293.4, 258.9, 309.2, 273.7, 229.6 At 512 MB the title room fills about 30 s in (~368 MB of paged title memory on the card). From then until the end of the run, 4,300–5,350 pages wait, and promotions almost stop: run 2 went from 6,132 to 6,142 over the last 3 min. Nothing frees room for them: `0 down for room` and only 56–244 cold demotions per run. So the ranking rarely has a slot to hand out. When room is this short, the bottleneck seems to be that no on-card page gets evicted, not the order of the candidates. Frame times are the same within run-to-run variation. **One thing I can't explain.** With ranking on, quick returns (demoted on CPU touch within 2 s) were higher in both scarce-room tests: - 512 MB: A 1–4, B 4–26. - `VICTORY_PAGE_MOVE_MB=4` at 1024 MB: A 7–12, B 10–21. That follow-up run has the same harness, and B's peak queue there was ~2,900–3,000 pages. The shadow arm says the ranking changes almost no decision, so I'm not attributing this to the PR. The numbers are small, but you may know whether `RANK=1` does anything beyond reordering. RT: not tried on this card yet. @⁠lucalocastro Thanks. I'll look at the tester guide for your draft and come back if I can run the shadow counters on this setup.
Author
Owner

@⁠tommiehansen on GitHub · 2026-12-03 19:43 UTC · original

CPU Ranking & Shadow-Mode Overhead Optimization (3905d33)

Extracted the pure-Rust ranking, selection, run-coalescing, and shadow-diff logic into crates/victory-gpu/src/um/residency_ranking.rs and wired it into crates/victory-gpu/src/um/residency.rs without altering VICTORY_POOL_ACCESS / VICTORY_POOL_ACCESS_RANK behavior or duplicating Fork PR #4's outcome tracking (shadow.rs remains separate pending hardware feedback).

Technical changes

  • Linear 256-bucket histogram selection (select_runs, select_ranked_runs): Replaces sort_unstable_by + Vec<Move> shadow clone with a single-pass u8 weight histogram + sortedness check (skipping the (id, index) sort when candidates arrive ordered from active()), and preserves (id, index) locality on tied cutoff weights to coalesce adjacent pages cleanly.
  • Zero-allocation shadow diff (diff_run_counts): Replaces the two temporary BTreeSet<(usize, usize)> allocations with an O(R1 + R2) two-pointer sorted interval sweep while keeping original / ranked run lists intact for downstream instrumentation.
  • Pool-cached lookup & CPU-touch fast path: Caches the pool's last_cpu slice across contiguous candidates in tick() instead of repeating by_id(m.id) per page, and adds an unlocked last[index] < now check in Paged::note_cpu_access before scanning page views.
  • All-fit / zero-capacity fast paths: Skips last_cpu lookups completely when moves.len() <= limit or limit == 0.

macOS ARM64 CPU Benchmark Results (rustc -O, A/B/B/A 8-block median, direct production residency_ranking.rs)

Scenario Previous PR #303 Updated (3905d33) Delta
Contested shadow (N=8192, limit=512) 94.224 us 29.945 us -68.22%
Contested on (N=8192, limit=512) 47.566 us 23.502 us -50.59%
Contiguous spans on (N=8192, limit=512) 43.394 us (45 runs) 27.679 us (43 runs) -36.21% (-4.4% um.place runs)
All-fit fast path (N=256, limit=512) 4.845 us 0.991 us -79.54%
Migration-budget pressure (N=4096, limit=64) 40.880 us 12.782 us -68.73%

Verification & Reproduction

  • Native unit & differential tests (macOS ARM64):
    rustc --edition 2024 --test crates/victory-gpu/src/um/residency_ranking.rs -o /tmp/test_ranking && /tmp/test_ranking (7 passed, 0 failed, including a 256-case randomized differential check verifying diff_run_counts matches BTreeSet::difference exactly).
  • Windows cross-target check:
    cargo check -p victory-gpu --lib --target x86_64-pc-windows-msvc --features blake3/pure and --features blake3/pure,diagnostics (0 errors, 0 warnings, using the check-only libmimalloc-sys shim), plus cargo --offline xtask policy --staged (3 files ok).
  • Known limitations: All timings and unit tests above were measured on macOS ARM64 (Apple M5 CPU-only). Live Windows/RADV execution, VICTORY_POOL_ACCESS_RANK=1 / shadow telemetry under real gameplay, and AMD GPU FPS / frame-time validation require external AMD hardware testing.
**@⁠tommiehansen** on GitHub · 2026-12-03 19:43 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/303#issuecomment-7390133260) ### CPU Ranking & Shadow-Mode Overhead Optimization (`3905d33`) Extracted the pure-Rust ranking, selection, run-coalescing, and shadow-diff logic into `crates/victory-gpu/src/um/residency_ranking.rs` and wired it into `crates/victory-gpu/src/um/residency.rs` without altering `VICTORY_POOL_ACCESS` / `VICTORY_POOL_ACCESS_RANK` behavior or duplicating Fork PR #4's outcome tracking (`shadow.rs` remains separate pending hardware feedback). #### Technical changes - **Linear 256-bucket histogram selection (`select_runs`, `select_ranked_runs`):** Replaces `sort_unstable_by` + `Vec<Move>` shadow clone with a single-pass `u8` weight histogram + sortedness check (skipping the `(id, index)` sort when candidates arrive ordered from `active()`), and preserves `(id, index)` locality on tied cutoff weights to coalesce adjacent pages cleanly. - **Zero-allocation shadow diff (`diff_run_counts`):** Replaces the two temporary `BTreeSet<(usize, usize)>` allocations with an `O(R1 + R2)` two-pointer sorted interval sweep while keeping `original` / `ranked` run lists intact for downstream instrumentation. - **Pool-cached lookup & CPU-touch fast path:** Caches the pool's `last_cpu` slice across contiguous candidates in `tick()` instead of repeating `by_id(m.id)` per page, and adds an unlocked `last[index] < now` check in `Paged::note_cpu_access` before scanning page views. - **All-fit / zero-capacity fast paths:** Skips `last_cpu` lookups completely when `moves.len() <= limit` or `limit == 0`. #### macOS ARM64 CPU Benchmark Results (`rustc -O`, A/B/B/A 8-block median, direct production `residency_ranking.rs`) | Scenario | Previous PR #303 | Updated (`3905d33`) | Delta | | --- | ---: | ---: | ---: | | Contested shadow (`N=8192`, `limit=512`) | 94.224 us | 29.945 us | **-68.22%** | | Contested on (`N=8192`, `limit=512`) | 47.566 us | 23.502 us | **-50.59%** | | Contiguous spans on (`N=8192`, `limit=512`) | 43.394 us (45 runs) | 27.679 us (43 runs) | **-36.21%** (-4.4% `um.place` runs) | | All-fit fast path (`N=256`, `limit=512`) | 4.845 us | 0.991 us | **-79.54%** | | Migration-budget pressure (`N=4096`, `limit=64`) | 40.880 us | 12.782 us | **-68.73%** | #### Verification & Reproduction - **Native unit & differential tests (macOS ARM64):** `rustc --edition 2024 --test crates/victory-gpu/src/um/residency_ranking.rs -o /tmp/test_ranking && /tmp/test_ranking` (7 passed, 0 failed, including a 256-case randomized differential check verifying `diff_run_counts` matches `BTreeSet::difference` exactly). - **Windows cross-target check:** `cargo check -p victory-gpu --lib --target x86_64-pc-windows-msvc --features blake3/pure` and `--features blake3/pure,diagnostics` (0 errors, 0 warnings, using the check-only `libmimalloc-sys` shim), plus `cargo --offline xtask policy --staged` (3 files ok). - **Known limitations:** All timings and unit tests above were measured on macOS ARM64 (Apple M5 CPU-only). Live Windows/RADV execution, `VICTORY_POOL_ACCESS_RANK=1` / `shadow` telemetry under real gameplay, and AMD GPU FPS / frame-time validation require external AMD hardware testing.
Follow successful baseline moves through the two-second CPU return window. Report retained and deferred cohorts and document matched off/on runs for testers.
Author
Owner

@⁠tommiehansen on GitHub · 2026-12-03 20:06 UTC · original

Thank you for the thorough 512 MB and VICTORY_PAGE_MOVE_MB=4 RX 6700 XT runs, @⁠El-Biiscuit, and thank you to @⁠lucalocastro for the outcome-tracking work in Fork PR #4. Here is what crates/victory-gpu/src/um/residency.rs shows for each point in your report, along with the integrated shadow-outcome update (719a6e1):

1. Why promotion capacity stays exhausted at 512 MB (0 down for room, ~5,200 waiting)

  • In tick(), pressed = free < LOW || live > room remains false whenever live == room and physical free >= LOW (384 MiB), so DOWN_ROOM never runs to evict warm on-card pages.
  • Meanwhile space = room.saturating_sub(live) drops to 0, leaving DOWN_COLD as the only source of room—and DOWN_COLD only demotes pages whose GPU age >= COLD (150 busy ticks, ~30+ seconds without GPU hits). While turning the camera in the city scene, only 56–244 pages go cold per run, so most stays near 0 once the title pool fills.
  • We are intentionally not adding speculative eviction policy changes to #303 without evidence; #303 only reorders up when limit = most.min(remaining) > 0 && up.len() > limit.

2. Why ranking changes only 0–1 pages in those runs

  • Besides limit == 0 gating when room is full, non-write-combined CPU-touched pages are already filtered before up by touched_by_processor and PROBATION/SETTLED strikes, while ~98% of CPU-touched pages sit in pool 15 rather than the hot GPU-sampled pools.

3. About quick returns (A: 1–4 vs B: 4–26 at 512 MB; A: 7–12 vs B: 10–21 at MOVE_MB=4)

  • Verified that VICTORY_POOL_ACCESS_RANK=1 has no side effects anywhere outside m.weight reordering before runs(up, limit) (whereas shadow computes ranked on a side path).
  • On the earlier 21ab7ed build, runs() used sort_unstable_by(|a, b| b.weight.cmp(&a.weight)), whose quicksort tie-breaking across equal-weight warm pages can select different tied pages even when only a few candidates change weight. Commit 3905d33 replaces this with deterministic histogram bucket selection preserving (id, index) order so untouched tied weights stay invariant.
  • Also note that a single 16-page contiguous um.place run returning on a CPU touch accounts for +16 out of ~6,000 promotions (~0.27%).

4. Fork PR #4 Outcome Tracking Integrated (c20157c, 71492b0, 719a6e1)

  • Cherry-picked @⁠lucalocastro's commits (f0f259b and 746e29e, preserving original authorship) directly onto perf/t02-observe-page-access, adapting shadow.rs in 719a6e1 to classify outcomes via runs_contain_page (O(log R) binary search over sorted runs, avoiding BTreeSet allocation per contested pass).
  • Running VICTORY_POOL_ACCESS_RANK=shadow on #303 now logs page ranking outcomes (kept_promoted, kept_quick, deferred_promoted, deferred_quick) with 0 new xtask -- switches errors and clean Windows x86_64-pc-windows-msvc standard + diagnostics builds.
**@⁠tommiehansen** on GitHub · 2026-12-03 20:06 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/303#issuecomment-7390740393) Thank you for the thorough 512 MB and `VICTORY_PAGE_MOVE_MB=4` RX 6700 XT runs, @⁠El-Biiscuit, and thank you to @⁠lucalocastro for the outcome-tracking work in Fork PR #4. Here is what `crates/victory-gpu/src/um/residency.rs` shows for each point in your report, along with the integrated shadow-outcome update (`719a6e1`): ### 1. Why promotion capacity stays exhausted at 512 MB (`0 down for room`, ~5,200 waiting) - In `tick()`, `pressed = free < LOW || live > room` remains `false` whenever `live == room` and physical `free >= LOW` (`384 MiB`), so `DOWN_ROOM` never runs to evict warm on-card pages. - Meanwhile `space = room.saturating_sub(live)` drops to `0`, leaving `DOWN_COLD` as the only source of room—and `DOWN_COLD` only demotes pages whose GPU `age >= COLD` (`150` busy ticks, ~30+ seconds without GPU hits). While turning the camera in the city scene, only 56–244 pages go cold per run, so `most` stays near `0` once the title pool fills. - We are intentionally **not** adding speculative eviction policy changes to #303 without evidence; `#303` only reorders `up` when `limit = most.min(remaining) > 0 && up.len() > limit`. ### 2. Why ranking changes only 0–1 pages in those runs - Besides `limit == 0` gating when room is full, non-write-combined CPU-touched pages are already filtered before `up` by `touched_by_processor` and `PROBATION`/`SETTLED` strikes, while ~98% of CPU-touched pages sit in pool 15 rather than the hot GPU-sampled pools. ### 3. About quick returns (`A: 1–4` vs `B: 4–26` at 512 MB; `A: 7–12` vs `B: 10–21` at `MOVE_MB=4`) - Verified that `VICTORY_POOL_ACCESS_RANK=1` has no side effects anywhere outside `m.weight` reordering before `runs(up, limit)` (whereas `shadow` computes `ranked` on a side path). - On the earlier `21ab7ed` build, `runs()` used `sort_unstable_by(|a, b| b.weight.cmp(&a.weight))`, whose quicksort tie-breaking across equal-weight warm pages can select different tied pages even when only a few candidates change weight. Commit `3905d33` replaces this with deterministic histogram bucket selection preserving `(id, index)` order so untouched tied weights stay invariant. - Also note that a single 16-page contiguous `um.place` run returning on a CPU touch accounts for +16 out of ~6,000 promotions (~0.27%). ### 4. Fork PR #4 Outcome Tracking Integrated (`c20157c`, `71492b0`, `719a6e1`) - Cherry-picked @⁠lucalocastro's commits (`f0f259b` and `746e29e`, preserving original authorship) directly onto `perf/t02-observe-page-access`, adapting `shadow.rs` in `719a6e1` to classify outcomes via `runs_contain_page` (`O(log R)` binary search over sorted runs, avoiding `BTreeSet` allocation per contested pass). - Running `VICTORY_POOL_ACCESS_RANK=shadow` on #303 now logs `page ranking outcomes` (`kept_promoted`, `kept_quick`, `deferred_promoted`, `deferred_quick`) with 0 new `xtask -- switches` errors and clean Windows `x86_64-pc-windows-msvc` standard + `diagnostics` builds.
Author
Owner

@⁠lucalocastro on GitHub · 2026-12-03 20:07 UTC · original

@⁠tommiehansen, thanks for integrating the shadow outcome tracking. I have a question about a separate experiment prompted by El-Biiscuit’s 512 MiB run. In run 2, only ten more pages were promoted in the final three minutes, with thousands still waiting.

Looking at 3905d33, I found one condition that could explain that plateau: at the title cap, a hot page can have no promotion slot even while the device has ample free VRAM. If no resident page meets the ordinary cold threshold, the queue can persist. I'd be interested to hear whether that matches your reading of the trace.

I tried a local, opt-in prototype. Under those conditions, it can demote up to 16 previously used pages (1 MiB) that have gone at least 16 busy ticks without a GPU heat hint. The next pass rechecks the budget before promoting anything. In a synthetic replay with 5,000 fixed requests and enough eligible residents, it served 3,600 requests in 450 passes versus zero with the option off. With only 64 eligible residents, it served 64. The driver responses were simulated; the effect on RX 6700 XT frame times is still open.

Are you already working on eviction at the title cap, or would a separate draft PR for this experiment be useful? Happy to coordinate with whatever you have planned.

**@⁠lucalocastro** on GitHub · 2026-12-03 20:07 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/303#issuecomment-7390746843) @⁠tommiehansen, thanks for integrating the shadow outcome tracking. I have a question about a separate experiment prompted by [El-Biiscuit’s 512 MiB run](https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/303). In run 2, only ten more pages were promoted in the final three minutes, with thousands still waiting. Looking at `3905d33`, I found one condition that could explain that plateau: at the title cap, a hot page can have no promotion slot even while the device has ample free VRAM. If no resident page meets the ordinary cold threshold, the queue can persist. I'd be interested to hear whether that matches your reading of the trace. I tried a local, opt-in prototype. Under those conditions, it can demote up to 16 previously used pages (1 MiB) that have gone at least 16 busy ticks without a GPU heat hint. The next pass rechecks the budget before promoting anything. In a synthetic replay with 5,000 fixed requests and enough eligible residents, it served 3,600 requests in 450 passes versus zero with the option off. With only 64 eligible residents, it served 64. The driver responses were simulated; the effect on RX 6700 XT frame times is still open. Are you already working on eviction at the title cap, or would a separate draft PR for this experiment be useful? Happy to coordinate with whatever you have planned.
Author
Owner

@⁠tommiehansen on GitHub · 2026-12-04 00:03 UTC · original

Thanks @⁠lucalocastro — your diagnosis matches what residency.rs shows under tight card/promotion headroom: when promotion room stays saturated and quick returns recycle within the same pool budget, page ranking alone plateaus and can slightly shift churn toward those quick returns.

I agree with keeping title-cap / eviction policy experiments separate from #303 so each change stays isolated and measurable. Happy to review or run companion checks alongside your draft PR (and see how it interacts with #356 once ready).

**@⁠tommiehansen** on GitHub · 2026-12-04 00:03 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/303#issuecomment-7396326608) Thanks @⁠lucalocastro — your diagnosis matches what `residency.rs` shows under tight card/promotion headroom: when promotion room stays saturated and quick returns recycle within the same pool budget, page ranking alone plateaus and can slightly shift churn toward those quick returns. I agree with keeping title-cap / eviction policy experiments separate from #303 so each change stays isolated and measurable. Happy to review or run companion checks alongside your draft PR (and see how it interacts with #356 once ready).
Author
Owner

@⁠lucalocastro on GitHub · 2026-12-04 00:16 UTC · original

Thanks, @⁠tommiehansen! I opened draft PR #398 to test the eviction change separately, as you suggested. In the local replay it freed slots for waiting pages. The open question is whether the extra transfers reduce stutter on the RX 6700 XT.

The draft proposes eight runs of the same city scene at the same 512 MiB title budget, alternating exchange off and on in ABBAABBA order. We'd compare P99 frame time and frames over 200 ms per minute alongside promotions and quick returns. Does that look like a fair first test before we look at the interaction with #356?

**@⁠lucalocastro** on GitHub · 2026-12-04 00:16 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/303#issuecomment-7396593843) Thanks, @⁠tommiehansen! I opened [draft PR #398](https://git.gtahub.st/github/lobomfz--VIctory-xmem/pulls/398) to test the eviction change separately, as you suggested. In the local replay it freed slots for waiting pages. The open question is whether the extra transfers reduce stutter on the RX 6700 XT. The draft proposes eight runs of the same city scene at the same 512 MiB title budget, alternating exchange off and on in ABBAABBA order. We'd compare P99 frame time and frames over 200 ms per minute alongside promotions and quick returns. Does that look like a fair first test before we look at the interaction with #356?
Author
Owner

@⁠tommiehansen on GitHub · 2026-12-04 00:57 UTC · original

@⁠lucalocastro Yes, that looks like a sensible first experiment. Keeping the title budget fixed at 512 MiB and using the same binary with an ABBAABBA sequence should isolate the exchange policy nicely.

I'd also track migration volume and time alongside successful promotions, quick returns and refused moves. A shorter waiting queue is useful, but the important question is whether the newly promoted pages remain useful long enough to justify the additional transfers.

If the results show improved P99 and fewer long frames without excessive churn, I'd suggest a follow-up at the normal title budget with RT enabled.

We could then evaluate the interaction with #303 and #356 separately. I think these three approaches are complementary: better page selection, adaptive capacity, and controlled replacement when capacity is saturated.

Thanks for pursuing this independently!

**@⁠tommiehansen** on GitHub · 2026-12-04 00:57 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/303#issuecomment-7397337541) @⁠lucalocastro Yes, that looks like a sensible first experiment. Keeping the title budget fixed at 512 MiB and using the same binary with an ABBAABBA sequence should isolate the exchange policy nicely. I'd also track migration volume and time alongside successful promotions, quick returns and refused moves. A shorter waiting queue is useful, but the important question is whether the newly promoted pages remain useful long enough to justify the additional transfers. If the results show improved P99 and fewer long frames without excessive churn, I'd suggest a follow-up at the normal title budget with RT enabled. We could then evaluate the interaction with #303 and #356 separately. I think these three approaches are complementary: better page selection, adaptive capacity, and controlled replacement when capacity is saturated. Thanks for pursuing this independently!
Author
Owner

@⁠Luxuride on GitHub · 2026-12-04 12:09 UTC · original

The best-engineered thing in this batch, and also 988 lines of machinery for a hypothesis nobody has measured yet.

What I verified:

  • With both of your switches unset, the only runtime work is crates/victory-gpu/src/pull.rs:431 → observe_pull, which returns immediately. So nobody gets faster until someone runs the A/B in docs/DIAGNOSTICS.md:75-135 and reports back. That is a fine thing to land — if you are the someone.
  • docs/DIAGNOSTICS.md:75 says "This experimental branch builds on …/pull/303" — inside the PR that is 303. Self-reference; point at the branch it was cut from, or say "this branch".
  • crates/victory-gpu/src/um/residency_ranking.rs:22-33: the penalty ladder (4/2/1 heat for a CPU touch within 1 s / 2.5 s / 5 s) is invented, not fitted. Fine for an experiment, but the docs read like it is a result. Say in the PR that these are the numbers the shadow mode exists to test.
  • VICTORY_POOL_ACCESS and VICTORY_POOL_ACCESS_RANK are in docs/SETTINGS.md but not in run.conf.default, where VICTORY_LATE_FENCE and VICTORY_BAKE_SOURCES_ONLY both live.

To make it landable: rebase (56 behind), add the two switches to run.conf.default, and bring one number — how many of the pages both policies would promote come back to RAM within 2 s, from the shadow mode. Then it is an On or Off decision instead of a review.

The ranking module itself is the right shape: top-k over 256 buckets, run coalescing, allocation-free symmetric difference, differential and property tests, and a shadow mode that reports instead of guessing.

**@⁠Luxuride** on GitHub · 2026-12-04 12:09 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/303#issuecomment-7411053779) The best-engineered thing in this batch, and also 988 lines of machinery for a hypothesis nobody has measured yet. What I verified: - With both of your switches unset, the only runtime work is `crates/victory-gpu/src/pull.rs:431` → `observe_pull`, which returns immediately. So nobody gets faster until someone runs the A/B in `docs/DIAGNOSTICS.md:75-135` and reports back. That is a fine thing to land — if you are the someone. - `docs/DIAGNOSTICS.md:75` says "This experimental branch builds on …/pull/303" — inside the PR that *is* 303. Self-reference; point at the branch it was cut from, or say "this branch". - `crates/victory-gpu/src/um/residency_ranking.rs:22-33`: the penalty ladder (4/2/1 heat for a CPU touch within 1 s / 2.5 s / 5 s) is invented, not fitted. Fine for an experiment, but the docs read like it is a result. Say in the PR that these are the numbers the shadow mode exists to test. - `VICTORY_POOL_ACCESS` and `VICTORY_POOL_ACCESS_RANK` are in `docs/SETTINGS.md` but not in `run.conf.default`, where `VICTORY_LATE_FENCE` and `VICTORY_BAKE_SOURCES_ONLY` both live. To make it landable: rebase (56 behind), add the two switches to `run.conf.default`, and bring one number — how many of the pages both policies would promote come back to RAM within 2 s, from the shadow mode. Then it is an On or Off decision instead of a review. The ranking module itself is the right shape: top-k over 256 buckets, run coalescing, allocation-free symmetric difference, differential and property tests, and a shadow mode that reports instead of guessing.
Author
Owner

@⁠lucalocastro on GitHub · 2026-12-04 12:25 UTC · original

@⁠Luxuride @⁠tommiehansen I opened a follow-up against the #303 branch for the two menu switches and the test guide. The 4/2/1 penalties and their time windows are trial values. The shadow run is intended to test whether those values identify promotions that return to RAM quickly. I also prepared a squashed rebase on upstream main at 0fd7614 on my fork.

I’m away for work for the next one to two weeks and don’t have access to my test machine. When I’m back, I’ll run shadow mode and report how many pages selected by both policies returned to RAM on a CPU touch within two seconds (kept_quick out of kept_promoted, plus the percentage if there’s a sample). I’ll run the A/B comparison on the same save and build for frame timing.

**@⁠lucalocastro** on GitHub · 2026-12-04 12:25 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/303#issuecomment-7411411579) @⁠Luxuride @⁠tommiehansen I opened [a follow-up against the #303 branch](https://github.com/tommiehansen/VIctory-xmem/pull/5) for the two menu switches and the test guide. The 4/2/1 penalties and their time windows are trial values. The shadow run is intended to test whether those values identify promotions that return to RAM quickly. I also prepared a [squashed rebase on upstream main at `0fd7614`](https://github.com/lucalocastro/VIctory-xmem/commit/29de42604d08c261f9692847e65d4c1e50b8c322) on my fork. I’m away for work for the next one to two weeks and don’t have access to my test machine. When I’m back, I’ll run shadow mode and report how many pages selected by both policies returned to RAM on a CPU touch within two seconds (`kept_quick` out of `kept_promoted`, plus the percentage if there’s a sample). I’ll run the A/B comparison on the same save and build for frame timing.
github-bot changed title from residency: observe physical-page access and rank eligible VRAM promotions to feat(gpu): observe physical-page access and rank eligible VRAM promotions 2026-12-04 22:20:05 +00:00
Both demotion paths now give returned() the existing page note to classify the same promotion origin. Keep the relaxed load on touched pages and preserve the early-return sampling test.
Author
Owner

@⁠tommiehansen on GitHub · 2026-12-05 10:21 UTC · original

Thanks for the residency feedback and hardware experiments. 0d36619 fixes missing residency metadata at both demotion call sites; MSVC compilation and 17 targeted tests passed. The new Standard CPU result records roughly 10 µs extra ranking cost per synthetic sample. The menu/documentation feedback and hardware benefit are still open.

**@⁠tommiehansen** on GitHub · 2026-12-05 10:21 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/303#issuecomment-7436385792) Thanks for the residency feedback and hardware experiments. [0d36619](https://github.com/tommiehansen/VIctory-xmem/commit/0d36619b720ad447f8bb8d40e2656945695cb0a9) fixes missing residency metadata at both demotion call sites; MSVC compilation and 17 targeted tests passed. The new Standard CPU result records roughly 10 µs extra ranking cost per synthetic sample. The menu/documentation feedback and hardware benefit are still open.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/303/head:github-bot/gh-303'
git switch 'github-bot/gh-303'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-303'
git switch 'github-bot/gh-303'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-303'
git switch 'github-bot/gh-303'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-303'
git switch 'main'
git merge --squash 'github-bot/gh-303'
git switch 'main'
git merge --ff-only 'github-bot/gh-303'
git switch 'main'
git merge 'github-bot/gh-303'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.