d3d12: replay recorded pipelines on several threads #579

Closed
NathansDomainSolutions wants to merge 2 commits from upstream-pr/579 into main
NathansDomainSolutions commented 2026-11-30 07:45:45 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NathansDomainSolutions on 2026-11-30T07:45:45Z.


After a translator change, preparation replays every recorded pipeline so the driver compiles it before launch. On my prefix that is 23,142 records (5,101 rebuilt, 2,646 reused, 15,395 replayed as recorded). The replay guest created them on one thread: my 16-core machine sat at 1 busy core for the whole replay. On top of that, preparation stops the replay after a fixed 3600 s, so a full warmup never finishes and the rest is compiled in-game, where it costs memory and minutes per program.

Change

  • pso_replay_guest.cpp: replays on TUXBOX_REPLAY_THREADS threads (default half the cores, 2 to 8, never more than there are records). Each thread has the 64 MiB stack a compile needs and takes the next record from an atomic counter. Totals are merged under a lock, and the first exception stops the other threads and is rethrown after they're joined. The receipt names the thread count. D3D12 pipeline creation is free-threaded, and order doesn't matter to the cache.
  • pipeline_prep.py: the replay's limit is 4 h by default (TUXBOX_REPLAY_TIMEOUT). It guards against a record that hangs the driver, not against a long warmup.
  • docs/ENVIRONMENT.md: both variables.

Checks: build.py d3d12 builds with /W4 /WX, and the Python tests pass (758, OK). A 1-thread vs 8-thread A/B on a 48-record subset (driver caches off) is running on my RTX 4070. I'll post the numbers here.

This contribution was written by an AI agent (Claude Opus 5.5) operating under my supervision. I am accountable for it and will respond to review.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5561159887 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/579). Originally posted by [NathansDomainSolutions](https://github.com/NathansDomainSolutions) on 2026-11-30T07:45:45Z. --- After a translator change, preparation replays every recorded pipeline so the driver compiles it before launch. On my prefix that is 23,142 records (5,101 rebuilt, 2,646 reused, 15,395 replayed as recorded). The replay guest created them **on one thread**: my 16-core machine sat at 1 busy core for the whole replay. On top of that, preparation stops the replay after a fixed **3600 s**, so a full warmup never finishes and the rest is compiled in-game, where it costs memory and minutes per program. **Change** - `pso_replay_guest.cpp`: replays on `TUXBOX_REPLAY_THREADS` threads (default half the cores, 2 to 8, never more than there are records). Each thread has the 64 MiB stack a compile needs and takes the next record from an atomic counter. Totals are merged under a lock, and the first exception stops the other threads and is rethrown after they're joined. The receipt names the thread count. D3D12 pipeline creation is free-threaded, and order doesn't matter to the cache. - `pipeline_prep.py`: the replay's limit is 4 h by default (`TUXBOX_REPLAY_TIMEOUT`). It guards against a record that hangs the driver, not against a long warmup. - `docs/ENVIRONMENT.md`: both variables. **Checks:** `build.py d3d12` builds with `/W4 /WX`, and the Python tests pass (758, OK). A 1-thread vs 8-thread A/B on a 48-record subset (driver caches off) is running on my RTX 4070. I'll post the numbers here. This contribution was written by an AI agent (Claude Opus 5.5) operating under my supervision. I am accountable for it and will respond to review. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
NathansDomainSolutions commented 2026-11-30 08:06:00 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NathansDomainSolutions on 2026-11-30T08:06:00Z.


Full replay on my prefix (RTX 4070, GE-Proton11-14, 16 cores): threads=8 records=23142 compute=1856 graphics=4303 failed=16983 driver_ms=8612524, which finished in about 18 min wall. 8,612 s of driver time on one thread is about 2.4 h, more than twice the old 3600 s limit, so that warmup could never complete before.

Separately, 16,983 of the 23,142 records fail to create, with this branch and on one thread alike (my 48-record sample failed the same share). That looks like a recorded-stream or translation mismatch worth its own issue. I'll look into it.

<!-- greyfinch-sync:brcly/TuxBox:comment:7272480552 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/579#issuecomment-7272480552). Originally posted by [NathansDomainSolutions](https://github.com/NathansDomainSolutions) on 2026-11-30T08:06:00Z. --- Full replay on my prefix (RTX 4070, GE-Proton11-14, 16 cores): `threads=8 records=23142 compute=1856 graphics=4303 failed=16983 driver_ms=8612524`, which finished in **about 18 min wall**. 8,612 s of driver time on one thread is about 2.4 h, more than twice the old 3600 s limit, so that warmup could never complete before. Separately, 16,983 of the 23,142 records fail to create, with this branch and on one thread alike (my 48-record sample failed the same share). That looks like a recorded-stream or translation mismatch worth its own issue. I'll look into it.
brcly commented 2026-11-30 09:47:49 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T09:47:49Z.


Merged into main as 1471df19 (squashed and credited to you). Thanks. Your full-replay numbers (about 18 min on 8 threads, against 2.4 h of driver time that the one-hour limit cut off) are what decided it. It builds here, and the threading code is sound: each thread keeps its own totals and a shared counter hands out the records.

Two small follow-ups, for whenever you're next in there:

  • With TUXBOX_REPLAY_TRACE set, the trace comment's promise that "the last name printed is the one that did it" no longer holds once several threads print. Forcing one thread while tracing would bring it back.
  • Four hours is a long time for a launch to wait on a record that hangs the driver. A per-record limit would guard that case better than the overall one.

A separate issue for the 16,983 records that fail to create would be very welcome.

<!-- greyfinch-sync:brcly/TuxBox:comment:7274697905 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/579#issuecomment-7274697905). Originally posted by [brcly](https://github.com/brcly) on 2026-11-30T09:47:49Z. --- Merged into main as 1471df19 (squashed and credited to you). Thanks. Your full-replay numbers (about 18 min on 8 threads, against 2.4 h of driver time that the one-hour limit cut off) are what decided it. It builds here, and the threading code is sound: each thread keeps its own totals and a shared counter hands out the records. Two small follow-ups, for whenever you're next in there: - With `TUXBOX_REPLAY_TRACE` set, the `trace` comment's promise that "the last name printed is the one that did it" no longer holds once several threads print. Forcing one thread while tracing would bring it back. - Four hours is a long time for a launch to wait on a record that hangs the driver. A per-record limit would guard that case better than the overall one. A separate issue for the 16,983 records that fail to create would be very welcome.

Pull request closed

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!579
No description provided.