Repository navigation
d3d12: look up cached shaders without scanning the cache directory - #165
Merged
Merged
Conversation
Wine matches file names without regard to case, so opening a name that is absent reads the whole directory to look for another spelling of it. Every program request asked for several absent names: its session reply (twice), the cache's .sha256 or .unsupported file, and the destination of the rename that published a copy of a cached program to the session directory. With 39,463 files in the ProjectScarlett cache and 13,812 copies in the session directory, the loader threads spent most of their time in those scans: up to 80% busy each, three quarters of it in the kernel, with almost no disk reads. In user space perf showed utf8_mbstowcs, hash_short_file_name and readdir64. List both directories once and open only names they hold. Use the cache's own file instead of a session copy. A translation the host adds after the listing still works: it is requested, and the host answers from its cache. Measured on our tree, an older main with the same change, one run each: from leaving the first screen to the start of streaming, 3 min 45 s became 1 min 16 s, and kernel time over the busy part fell from about 360% to 170% of a core. The second run also had a larger Mesa shader cache limit and the first run's driver cache, so not all of the difference need be this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Under Wine, opening a file that is not there reads the whole directory, because names match without regard to case. Each program request asked for several absent names: its session reply (twice), the cache's
.sha256or.unsupportedfile, and the destination of the rename that published a copy of a cached program to the session directory.With 39,463 files in the ProjectScarlett cache and 13,812 copies in the session directory, the loader threads were up to 80% busy, three quarters of it in the kernel, with almost no disk reads.
perfshowedutf8_mbstowcs,hash_short_file_nameandreaddir64in Wine.This lists both directories once and opens only names they hold. It reads the cache's own file instead of a session copy. A translation the host adds after the listing still works: it is requested, and the host answers from its cache.
Measured on ProjectScarlett (RX 9060 XT, RADV, Proton Experimental), one run each: from leaving the first screen to the start of streaming, 3 min 45 s became 1 min 16 s. Kernel time over the busy part fell from about 360% to 170% of a core. Those runs used our tree, an older main with the same change, not this branch. The second run also had a larger Mesa shader cache limit (12 GB) and the first run's driver cache, so not all of the difference need be this change.
Checks
The
verifysuites d3d12-exports, heaps, draw, mesh, tables, indirect and stream pass on this branch (on 529c52d); 283 Python tests run, 13 skipped, no failures;cargo checkfor the Windows target. In game, on our tree, 16 translations deleted from the cache just after launch were requested again and came back. The new unit test is compiled but not run here, since it needs the Windows target.🤖 Generated with Claude Code