texture: SEEDS and HOST_WRITTEN behind a RwLock — asked of every texture read on every recording thread (3–5× cheaper under contention) #2226
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2226"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by birdneststream on 2026-11-29T10:44:09Z.
SEEDSandHOST_WRITTENintexture.rsare asked of every texture read on every recording thread (seed_pendingper SRV,upload_from,host_wrote,is_host_written), and written only when a view is seeded, a texture is written by the host, or a resource is forgotten. Behind aMutex, every one of those reads serialises against every other thread's read.Measured under Wine (wine-staging 11.22, i9-13900KF), eight threads hashing a key in a 32-element set behind each lock, 200k lookups a thread, three runs:
Three to five times cheaper per lookup under contention, the same answers (writers still exclusive).
seed_pendingtakes the read first and only the write when the view really waits, so the usual "not waiting" costs one read.This lock per texture read came in with
e530c0034(11-28,UPLOAD_GUARDon by default), which is why I am pointing at it in #2129 as a candidate for the per-draw cost: with thousands of texture reads a frame across the recording threads, a globalMutexthere is on the per-draw path. No behaviour change; the GPU suite under Wine is at its usual baseline with it (913/6, the six known Wine/vkd3d ones).Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Lyrnc on 2026-11-30T05:45:47Z.
Measured this on an RTX 5080 + 9800X3D with a CPU micro-benchmark of the texture-read path (
per_read_lookups_bench, now in #3739). Values are ns per read, for main41adb551, this PR, and #3739, which builds on this PR:With realistic spacing, the RwLock alone lands within noise of main. There are two reasons:
HOST_WRITTEN_ATstays a mutex, and a read lock still writes the shared lock word. In 9 game runsSEEDSheld 0–1 views, so almost every lookup is a miss. #3739 keeps your commit as it is (author kept) and adds an atomic bit filter in front of the three tables, so a miss takes no lock. It also turnsHOST_WRITTEN_ATinto an RwLock.On the "2× slower per draw since .01" reports: in our logs that came from the compile-memory guard, not from these tables. Recording threads measured 3.6–4.5 µs a list call on .28.03, 15–128 µs on .29.01 with the guard on, and 3.7–4.8 µs with it off (#3347). These tables are worth about 1–5 % of recording time per draw.
AI use: Claude Code (Claude Opus 5.5).