Repository navigation
d3d12: cache GPU tile spans apart from single pages (#666) - #667
Draft
JeffreyBytes wants to merge 1 commit into
Draft
JeffreyBytes wants to merge 1 commit into
JeffreyBytes wants to merge 1 commit into
Conversation
Since 106120c a host that substitutes section imports backs queue page mappings with private memory, and gpu_tile imports many pages one at a time. Those single-page pieces stay live while a GpuTile holds them, and they shared one PageCache with the cluster windows of shared_window. Once 4,096 pieces were live the cache stopped indexing new keys, so a new window was imported again for every page in it. On an RX 6700 XT (RADV) ProjectScarlett reached 18 GiB of GTT within a minute of the setup screens, and the next submission failed with "Not enough memory for command submission" and VK_ERROR_DEVICE_LOST. Single pages and spans now have separate caches with their own bounds. Opening an uncached piece no longer holds the cache lock. ProjectScarlett on the same card: before, 655 windows took 4,599 imports and the device was lost at 170-194 s. After, adapter system memory peaks at 4.4 GiB and the title runs 444 s with no device loss, until the known main-thread watchdog (brcly#215).
2 of 3 tasks
|
Tested 2898c90 on an RX 9070 XT (RADV from Mesa 26.3.1, kernel 7.3.5, GE-Proton), packaged profile. I started a new game from the intro, under the same conditions as a run on 106120c just before it.
The runaway is gone on this card, so this looks like it fixes #666 here. The watchdog afterwards seems to be a separate problem, filed as #669. Every userptr import is walked by amdgpu on each CS, at about 8.4 ms per GiB. With #667, GTT still grew from 1.4 to 4.3 GiB after the new game started. The median CS time went from 13 to 56 ms, and the frame rate fell to 1–1.7 fps, after which the title's 30 s watchdog fired. That matches the exit 5 you saw after your local fix. |
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.
Caution
Needs a run on Nvidia hardware prior to merge.
Summary
Fixes #666.
Since 106120c, RADV backs queue page mappings with private memory, and
gpu_tileimports a lot of pages one at a time. Those single-page pieces stay live while a GpuTile holds them, and they shared thepiecesPageCache with the cluster windows fromshared_window. Once 4,096 were live the cache stopped indexing new keys, so every page in a new window imported the whole window again. On my RX 6700 XT, ProjectScarlett hit 18 GiB of GTT a minute after the setup screens and then lost the device (Not enough memory for command submission).This keeps single pages and spans in separate caches (
PieceCaches), each with the existing bound. It also releases the cache lock before opening a piece that has no cache key, as the old code did.DrArroway found this first, on an RX 6900 XT, and their local
fix10stack adds a separatecluster_piecescache for the same reason (#533 comment). This PR is the same split, so credit to them. Their stack also limitsshared_window()toMEM_MAPPEDpages and holds whole private cluster windows. Neither is in this PR, which only splits the cache.The single-page cache can still fill, but in practice that hardly matters. With a trace on top of this branch, the title opened 14,499 single-page pieces for 14,241 distinct pages, so at most 258 were opened again, and that count includes pages reopened after their last holder let go. About 13,000 single-page heaps (plus about 1,000 cluster heaps) are live at once, each a buffer on every submit. I measured the queue thread's kernel time and found no cost from them: it was already 40-45% of a core before any single-page pieces existed, and it didn't rise as they grew from 1,000 to 11,000.
Tested
GPU, driver and backend: RX 6700 XT (
1002:73df), RADV / Mesa 26.3.1, GE-Proton11-15,section-import=substitutedThe
Evidence:linetuxbox.py checkprints last, one per card (it names the commit it tested; run it on this pull request's head):Commands run and their results:
The new test is a unit test on the cache, not a Lanes scenario: reproducing it in Lanes would need more than 4,096 live single-page queue mappings.