texture: SEEDS and HOST_WRITTEN behind a RwLock — asked of every texture read on every recording thread (3–5× cheaper under contention) #2226
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!2226
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@birdneststream on GitHub · 2026-11-29 10:44 UTC · original
birdneststream:seeds-host-written-rwlock→main· +18 −16 · 1 files · 1 commits · merged 2026-11-30 14:12 UTCSEEDSandHOST_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).@Lyrnc on GitHub · 2026-11-30 05:45 UTC · original
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).