Skip to content

launcher: profile host shader compilation stages and cache reuse - #238

Closed
Valdi320 wants to merge 5 commits into
brcly:mainfrom
Valdi320:work/shader-stage-profiling-20261126
Closed

Valdi320 wants to merge 5 commits into
brcly:mainfrom
Valdi320:work/shader-stage-profiling-20261126

Conversation

@Valdi320

Copy link
Copy Markdown
Contributor

Purpose

The startup work in docs/FOCUS.md needs evidence distinguishing xshader, DXC (including retries), DXV, cache lookup/lock/publish and driver-side compilation. Add opt-in aggregate host wall timings for preparation and runtime via TUXBOX_PROFILE_SHADERS=1; --profile-pipelines also enables the runtime summary unless overridden.

Count request outcomes, exact-source reuse, content-DXIL reuse, tool attempts, timeout/error outcomes, cumulative and maximum elapsed time. Concurrent durations are not CPU time. No shader hashes, title identifiers or raw error messages are included. Empty warm sessions are legitimate when the provider serves its cache directly. No compilation flags, timeouts, cache identities or translation semantics are changed. This does not yet measure per-stage memory or dxil-spirv separately from driver time.

Evidence

  • All six official code-check groups passed. New tests cover timeout fallback, refusal vs cached refusal vs transient failure, content-cache reuse, parallel isolation and opt-out.
  • Real xshader/DXC/DXV, eight synthetic requests, two workers: cold 7 published / 1 deliberate refusal in 98.3 ms; warm 7 cached / 1 cached refusal in 3.3 ms, no xshader or DXC calls. Synthetic numbers, not retail performance.
  • RTX 4080, GE-Proton11-14: 8/8 Lanes gates passed with rebuilt D3D12 provider at 3b8a220, unchanged Lanes fixture and current translator. Five runtime reports captured: seven newly published source entries reused identical DXIL; one warm session had zero requests. The local capture harness originally expected four reports, but all five saved reports and eight gate receipts were independently verified.
  • No retail data included.

Draft pending full check on this exact branch and AMD validation; actual ProjectScarlett cold/warm profiling and per-stage memory measurements remain to be done.

@Valdi320

Copy link
Copy Markdown
Contributor Author

Follow-up: host shader profiling now measures peak RSS for each CLI tool on Linux when GNU time is available. The independent wrapper avoids the parent's inherited high-water RSS and the sampling gaps of short-lived processes. Measurements are optional, timeouts terminate the process group, missing measurements stay null, and no title identifiers are emitted. Normal unprofiled execution is unchanged. The report does not include persistent DXC, aggregate simultaneous memory or driver/VRAM.

Validation:

  • 22/22 CLI invocations measured in a real cold run (seven synthetic source entries compiled, one deliberately refused). Warm run reused seven source entries and the refusal with no CLI invocations.
  • 15 runs of the same synthetic large compute shader, five each baseline/profiled/standalone GNU time: identical DXIL hashes; median 786.69 ms baseline vs 790.12 ms profiled (+0.44% in this run); peak RSS medians 73,256 KiB profiled vs 73,184 KiB reference.
  • 8/8 Lanes gates passed on RTX 4080 / GE-Proton11-14, five session reports, all seven xshader invocations measured. Reused the rebuilt provider and unchanged Lanes artifacts from the previous test.
  • All six code-check groups passed again with added tests covering parallel isolation, high-RSS parent, signal status, missing optional timer, failures and timeout descendant cleanup.

GNU time's rare exec failures for otherwise executable paths may be reported as retryable 126/127 rather than an OSError when profiling. No new refusal-cache classification. Remaining: real-title cold/warm capture, driver-side memory, full GPU check and AMD run.

@Valdi320

Copy link
Copy Markdown
Contributor Author

Follow-up to the real-workload measurements in #242. Thank you for the comparison; I agree the synthetic speedups are not evidence of noticeable title startup improvement.

Updated head: 94ea30b. The existing --profile-pipelines capture now also writes stage-summary.json with the host runtime compiler aggregate and the vkd3d-proton PSO events from the same run. It separates summed event durations from the union of observed time intervals and reports peak overlapping events (not worker count). Host and PSO totals can overlap and should not be added; PSO events are not exclusive driver compilation times. Missing sources are null, not zero. No shader identifiers or raw paths in the aggregate. Preparation remains a separate log aggregate.

Validation: six no-GPU groups and 8/8 Lanes gates passed on RTX 4080/GE-Proton11-14; unchanged runtime and fixture source checked. Two actual Lanes shader self-test launches also passed through Host.run_game with --profile-pipelines. First run, cold test prefix: xshader 4.267 ms, DXC 13.271 ms, DXV 4.458 ms, one host compilation (24.114 ms end-to-end), one vkd3d PSO event (4.160 ms). Second run: no host requests, two PSO events (4.546 ms). These are functionality checks, not a statistically meaningful cold/warm performance comparison or ProjectScarlett data.

The local older title log does not include the needed trace and I do not have your recorded 83-request corpus. If you have time, a cold/warm stage-summary.json and the preparation timing aggregate from your actual title run would be very useful; no raw retail files, shader inputs or private logs needed. This remains a draft pending AMD/full validation.

@Valdi320

Copy link
Copy Markdown
Contributor Author

Combined verification follow-up (not a merge request): https://github.com/Valdi320/TuxBox/tree/2a03732aef512504b6d32c3201380e439f8dc0b6. Integrated #238, #239, #249, #252, #254, #255, #256, #257, #259 and #261 on current main f0ffa49, resolved documentation and profiling/content-cache conflicts. Separate source and content lock timing so they are not double counted. Final six no-GPU groups passed, all 44 translator GPU controls (initial mask-ballots failure fixed by #264), 10 Lanes controls and all 19 isolated D3D12 regression controls on RTX 4080. Runtime rebuilt; unchanged Lanes/XMem fixture source equality verified before staging. Lanes executed before the final timing-label-only correction; final code tests and benchmark rerun.

With profiling enabled and a synthetic four-request forced-identical-HLSL benchmark, real DXC/DXV calls fell 4 to 1 each, three alternating runs per build, median child CPU 2.638 to 0.534s, elapsed 0.701 to 0.609s, all output hashes identical. Baseline #238 at 94ea30b; xshader stub deliberately supplies identical HLSL. This is not a retail speedup. Following the maintainer's real corpus feedback, no additional speculative Wave64 arithmetic optimization. Real title capture replay, AMD combined run, and the original device-loss/deadlock remain outstanding.

@Valdi320

Copy link
Copy Markdown
Contributor Author

Follow-up at 6a50b85: profile: classify out-of-order pipeline events conservatively. 393 tests, 27 skipped; both forward and reverse trace ordering pass, ambiguous hash associations remain unknown. Host tooling only; no new GPU or title performance claim.

@Valdi320

Copy link
Copy Markdown
Contributor Author

Deferred until actual cold/warm stage timings (including driver) are available, as requested by the maintainer. The profiling tools remain available for private experiments; this is the first deferred diagnostic item to reconsider when measurements exist. Closing this draft to make the review queue manageable, per the maintainer's request. The branch and history remain intact at 6a50b85; no branch deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant