Skip to content

[upstream #1026] Shaders: move capture hashing off lock and offload xbox stats - #112

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1026
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1026

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Move shader validation, in-place FNV-1a hashing, and container classification outside the global STATE lock in gpu::shader::capture, and offload non-dump account_xbox FSSM decompression and RDNA2 instruction counting to a low-priority background worker flushed by shader::stats().

A retail title submits 200k+ shader blobs across parallel loading threads while >98% are duplicates of ~3.6k-19k unique shaders (e.g. 204,736 submissions for 3,579 unique shaders in the first 60 s, 15.67M RDNA2 instructions). Previously shader::capture held the global STATE mutex across readable(), heap-copying every duplicate into a Vec<u8>, fnv64(), and classify(), and then ran account_xbox() synchronously on the title's loading threads.

What is in it

  • crates/xcl/src/gpu/shader.rs: run readable() and fnv64() directly on the borrowed slice outside STATE, skip allocating Vec<u8> on duplicate hashes, avoid String allocations on existing stage/kind keys, classify unique blobs outside STATE, and offload non-dump account_xbox() to a low-priority xcl-shader-stats worker thread with a bounded flush in stats().
  • crates/xcl/src/gpu/shader.rs: unit tests covering concurrent multi-thread deduplication, deterministic worker flush on stats(), and unreadable-pointer rejection.

Tested

Regression run

main:

xcl-smoke v1
commit: 077ce40c3e371cf3df8c57985b1cc6b1db39e75a
gpu: NVIDIA GeForce RTX 5060 Ti
title: GTA6.Xbox.v1.0.2.1-CYBERLEEK
seconds: 60
exit: 0x0
frames shown: 500 (PresentX 500)
presents per 2 s (last 3): 60 62 60
device removals: 0
crashes: 0
peak commit: 8851 MB

PR:

xcl-smoke v1
commit: 870de7ddbcbbfe425c46eb5e574740ca2469b93b
gpu: NVIDIA GeForce RTX 5060 Ti
title: GTA6.Xbox.v1.0.2.1-CYBERLEEK
seconds: 60
exit: 0x0
frames shown: 694 (PresentX 694)
presents per 2 s (last 3): 57 60 60
device removals: 0
crashes: 0
peak commit: 8885 MB

Not tested

  • AMD / Intel GPUs and native wave64 tests (skipped on NVIDIA RTX 5060 Ti).
  • XCL_DUMP_SHADERS=1 disk dump path (behavior unchanged, not exercised during smoke run).
  • XCL_SAMPLE_* sample-data tests (environment variables unset).

AI use

  • Antigravity 2.0 (Gemini 4 Neon): diagnosed the contention/accounting overhead in shader::capture, wrote the implementation, unit tests, commit message, and PR description; all builds, tests, and smoke runs were executed on the hardware named above.

Mirror of xcl-dev#1026 (auto-synced, do not edit).

A retail title submits 200k+ shader blobs across parallel loading threads while >98% are duplicates of ~3.6k-19k unique shaders. Previously shader::capture held the global STATE mutex across readable(), heap-copying every duplicate into a Vec, fnv64(), and classify(), and then ran account_xbox() (FSSM decompression and RDNA2 disassembly) synchronously on the title's loading threads.

Validate readable(), hash the slice in place without copying duplicates, and classify unique blobs outside STATE. Offload non-dump account_xbox() to a low-priority worker thread (xcl-shader-stats) that stats() flushes with a bounded wait before reading STATE so report.json and e2e counts stay identical.

Assisted-by: Antigravity IDE (Gemini 4 Neon)
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#1026 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/1026 branch November 25, 2026 00:10
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.

2 participants