Memory: a whole coherent window in a title's first run (#284) #632
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!632
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-632"
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?
@grahamster2 on GitHub · 2026-11-24 02:42 UTC · original
grahamster2:uma-first-run-window→main· +125 −18 · 3 files · 2 commits · openOn a title's first run there is no
cache/uma_coherent.txtyet, so the coherent window was 512 MB and the title's GPU heaps went elsewhere for the whole run. #284 measured the retail title's menus at ~12 fps on the first run and 30 from the second, on an oldermain. This follows Kalmarv's plan in #284. On Windows, with nouma_coherent.txtand the 17 GB of commit free that a learned size already needs, the first run always gets one whole window (4095 MB). Under Wine the first run keeps 512 MB: xstraok's Proton runs (https://github.com/ivall/xcl/issues/284#issuecomment-7117584344) show the 4095 MB window leaving the retail title black, with 7 s of upload in its first 16 sparse submits, where 512 MB drew the menus. In every other case the window stays at 512 MB as today. The first run writes 0 to the file straight away, and what the title then asks for replaces it as before, so a title that asks for nothing is back to 512 MB from its second run.XCL_COHERENT_MBstill decides the size when it is set. Learned sizes andXCL_COHERENT_MBare clamped to the per-layout cap (max_coherent_bytes), so on 8 and 16 window layouts they can exceed 4095 MB; on the default 4-window layout the cap is one window.Part of #284. It fixes the first run on Windows. Under Wine the learned size (4095 MB for the retail title from its second run) is left as on
main, and that is still the black-screen case in xstraok's data.Rebase note: rebased onto main
b49be18(head560240a).cargo test -p xcl --libgives 1312 passed, 0 failed, 27 ignored on this head. The Regression run (xcl-smoke) blocks below are from the previous head (b6fe9a4against main0829441) and will be redone on this head before review. The workspace test counts and the retail-title smoke runs below are older still and also predate this rebase.What is in it
crates/xcl/src/gpu/uma.rs: the sizing is now a pure function,coherent_size(learned: Option<usize>, free: usize, env_mb: Option<usize>, wine: bool, cap: usize). Wine is detected withutil::under_wine()(ntdll'swine_get_version), as elsewhere in the code base. A newlearned_bytesreads the file: only a missing file in a title's run counts as a first run. A file that cannot be read or parsed counts as 0, so it can't give a whole window on every run. Without a boot record (unit tests) there is no first run.coherent_hint_for(windows)(withcoherent_hint()as the 4-window wrapper) writes 0 on a first run and logs the size it chose, and the 4-window fallback after a failed 8/16-window reservation reuses that hint cut to its own cap (for_layout) instead of reading the 0 back.note_coherent_needuses the same write helper. Both functions have unit tests.crates/xcl/tests/e2e.rs: the two runs of the test title setXCL_COHERENT_MB=512. Each starts from a new data folder, so without it they would now commit the whole window, which Kalmarv measured in #284 at +3.6 GB of commit and working set and about +1 s per run. With it they run as they do onmain.crates/xcl/src/hle/kernelx.rs: a comment on the window size now mentions the first run.Tested
cargo test --workspace -- --test-threads=4on 819a605 (before the rebase): 686 passed, 0 failed, 41 ignored. An earlier full run on an older base had one failure,e2e::test_title_runs_and_game_folder_is_untouched("the test title did not run to the end", with the 512 MB window), while another process was using the GPU. Two reruns ofcargo test -p xcl --test e2eand every full run since have passed.SKIPPED:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)gpu::uma::tests::coherent_window_is_whole_in_the_first_run_then_what_the_title_asked_forcovers no file with enough commit and with too little, learned 0, learned 1 GB with enough and with too little commit, learned 4.8 GB (capped), and the override. Under Wine it covers no file, too little commit, a learned value and the override.gpu::uma::tests::only_a_missing_coherent_file_is_a_first_runcovers a missing file, a missing file with no title, an unreadable file, a valid value, 0, garbage and an empty file.9ce2070before the rebase (-Gameis a junction to the title's folder, so the blocks show a neutral title name). Each first run used a new emptyXCL_DATA_ROOT,XCL_COHERENT_MBwas unset, and no other XCL process was running during any of the runs:mainfirst run: 512 MB window, 879 frames. Presents per 2 s:0 25 29 61 20 1 1 1 40 41 48 43 37 48 36 10 33 11 11 13 33 51 ….0 6 59 60 34 54 35 0 49 60 60 60 …, steady at 60 (30 fps) from 18 s on.0 13 50 60 37 54 22 34 60 60 ….mainvaries between runs: an earlier cleanmainfirst run of the same commit gave 1278 frames and 15606 MB of peak commit, and two earlier clean runs of this PR (first run, then learned) gave 1587 and 1602 frames. In everymainrun the stretch from about 8 s on has long drops (1 to 21 presents per 2 s, i.e. 0.5 to 10 fps). With the whole window there is one dip at about 12 to 16 s and then a steady 30 fps. I have not checked what is on screen during that stretch (it may be the intro video).main), so it is within the 125 % rule. Frames were 177 % ofmainin the first-run pair above and 124 % in the earlier pair. In the regression run below, made onb6fe9a4against main0829441without emptying the data folder, frames are 100 % ofmain(1638 against 1631) and peak commit 103 % (15493 MB against 14975 MB).Regression run
main(0829441), data folder as it was, not emptied:This PR (
b6fe9a4), same data folder state:Not tested
PAGE_GRAPHICS_*commit leaves 0 in the file, so the second run gets 512 MB and only the third gets the learned size. That is no worse thanmain, but the first-run gain is lost.uma_coherent.txtstill holds the largest total seen and never goes down. That is as onmain, and the 0 is written only on the first run.HANDOFF.mdline ~1798 says the window size comes from the last run; it now has a first-run exception (not edited here, per CONTRIBUTING)AI use
@eizispark on GitHub · 2026-11-24 02:51 UTC · original
Hardware check of
819a6057d92b5d4654ea059b2cefc0b68e1c2051(verified clean merge withmain18c105a): pass.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profilecargo test --workspace -- --test-threads=4:686 passed, 0 failed, 41 ignored(GPU tests skipped on this adapter:none)gpu::uma::tests(coherent_window_is_whole_in_the_first_run_then_what_the_title_asked_for,only_a_missing_coherent_file_is_a_first_run) ande2e: passed; fresh empty data directory smoke run below selected the 4095 MB first-run coherent window as expectedRegression run
Both runs below used a fresh empty data directory (first run, no prior
uma_coherent.txt,XCL_COHERENT_MBunset):main(9ce2070):PR (
819a605):Not tested
AI use
scripts/smoke.ps1harness on this machine and formatted this report.@MesshM on GitHub · 2026-11-24 02:55 UTC · original
Test run of
819a6057d92b5d4654ea059b2cefc0b68e1c2051on AMD RDNA4; the PR was tested on NVIDIA only. I merged it onto currentmain18c105alocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 691 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 651 passed, 0 failed, 21 ignoredSKIPPED;coherent_window_is_whole_in_the_first_run_then_what_the_title_asked_forandonly_a_missing_coherent_file_is_a_first_runpass.Review: Only a missing file (
NotFound, with a title) counts as a first run; an unreadable or unparsable file counts as 0, and without a title nothing is learned or written, so unit tests do not touchuma_coherent.txt. Writing 0 at once means a first run that crashes before it learns anything leaves the second run at 512 MB, as today. Under Wine the first run stays at 512 MB, per the Proton results in #284. I found nothing to change.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@JoaoPauluu on GitHub · 2026-11-24 03:42 UTC · original
Test report: #632 under Wine (Linux, NVIDIA): the Wine branch on a first run
The PR's Wine branch (
coherent_size(…, wine = true)) had only been covered by its unit tests; the other reports are Windows runs. On Linux it does what the description says: a first run under Wine keeps 512 MB. The unit tests pass under Wine and there is no regression in the game runs.Setup
experimental-11.0-20261112(wine-11.0), vkd3d-proton v3.1 + the patch from #257, DXVK from Proton, DXC 1.9.2609,DXVK_CONFIG="dxgi.hideNvidiaGpu = False"x86_64-pc-windows-gnu(mingw-w64-gcc 16.2.0); release builds for the runs, debug for the tests819a605and its basemain9ce2070scripts/linux/smoke.shfrom #257 (XCL_NETWORK=0,XCL_COHERENT_MBunset). Each build got a new emptyXCL_DATA_ROOT(nouma_coherent.txtbefore its first run), then a second run in the same folder.Unit tests (under Wine,
--test-threads=1, filtergpu::uma::tests): 9 passed, 0 failed. That includescoherent_window_is_whole_in_the_first_run_then_what_the_title_asked_forandonly_a_missing_coherent_file_is_a_first_run.Runs
9ce2070, 1st819a605, 1stUMA: the title's first run under Wine: the coherent window stays at 512 MB819a605, 2ndUMA: 13328 MB of commit free, under 17408 MB: the title's GPU heaps stay outside unified memory …9ce2070, 2ndUMA: 13491 MB of commit free, under 17408 MB: …cache/uma_coherent.txtholds4804771840on both builds (the title asked for 3934 MB → "a window of up to 4095 MB from the next run").(These are the two first runs.
peak commit: 0 MBis XCL reading 0 MB committed under Wine, see #257, so the 125 % commit comparison says nothing here.)Not tested
AI use: Claude Code (Claude Opus 5.5) built both commits, ran everything above on the machine above and wrote this report. The blocks and log lines are pasted from those runs. The account owner asked for test reports to be posted while they were away and has not reviewed this one.
@raylitebull on GitHub · 2026-11-24 10:39 UTC · original
Code/CI review only (not independently runtime-tested by me): clean merge with both checks green (
Build and test+PR description). Cleanly allocates a full coherent UMA window on a title's first run (#284). Recommend merging, @ivall.@DavidM1911 on GitHub · 2026-11-25 12:43 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.@grahamster2 on GitHub · 2026-11-25 12:51 UTC · original · edited 2026-11-25 12:53 UTC
Rebased onto main
1a0bbe3(new head90bbaf5).One conflict, in crates/xcl/src/gpu/uma.rs (the coherent window sizing). Main had turned coherent_hint into coherent_hint_for(windows) with a per-layout cap. I kept that function and moved the PR's first-run logic into it: coherent_size now takes the cap, so the override and a learned size are clamped to the layout's cap instead of one window, and the first run still gets one whole window. coherent_hint() stays as the 4-window wrapper, and the note_coherent_need log line uses the layout cap. I added three test lines for the larger cap.
cargo test -p xcl --lib: 1183 passed, 0 failed, 26 ignored. Not run against the retail title.
Follow-up commit
b6fe9a4: the 4-window fallback after a failed 8/16-window reservation keeps a first run's whole window, plus log and doc fixes. Lib tests: 1184 passed, 0 failed.@DavidM1911 on GitHub · 2026-11-26 03:00 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.b6fe9a4a4eto560240a3b1@grahamster2 on GitHub · 2026-11-26 09:07 UTC · original
rebased onto main
b49be18(head560240a)cargo test -p xcl --lib: 1312 passed, 0 failed, 27 ignored. The e2e test target compiles (cargo check); it was not run.
smoke rerun pending
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.