d3d12: look up cached shaders without scanning the cache directory #165

Merged
Jerkin42 merged 1 commit from upstream-pr/165 into main 2026-11-25 11:44:14 +00:00
Jerkin42 commented 2026-11-25 11:42:48 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Jerkin42 on 2026-11-25T11:42:48Z.


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 .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 were up to 80% busy, three quarters of it in the kernel, with almost no disk reads. perf showed utf8_mbstowcs, hash_short_file_name and readdir64 in 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 verify suites d3d12-exports, heaps, draw, mesh, tables, indirect and stream pass on this branch (on 529c52d); 283 Python tests run, 13 skipped, no failures; cargo check for 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

<!-- greyfinch-sync:brcly/TuxBox:issue:6603693743 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/165). Originally posted by [Jerkin42](https://github.com/Jerkin42) on 2026-11-25T11:42:48Z. --- ## 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 `.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 were up to 80% busy, three quarters of it in the kernel, with almost no disk reads. `perf` showed `utf8_mbstowcs`, `hash_short_file_name` and `readdir64` in 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 `verify` suites d3d12-exports, heaps, draw, mesh, tables, indirect and stream pass on this branch (on 529c52d); 283 Python tests run, 13 skipped, no failures; `cargo check` for 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](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
brcly/TuxBox!165
No description provided.