resource: a placed texture is made outside the table's lock #530

Closed
github-bot wants to merge 1 commit from github-bot/gh-530 into main AGit
Owner

@⁠cerealfordinner on GitHub · 2026-12-04 23:06 UTC · original
cerealfordinner:upstream-pr-placed-texture-outside-lock → main · +21 −3 · 1 files · 1 commits · closed without merging

Texture lookup takes the lock only to look; texture creation happens under a separate MAKING lock, cutting lock contention on the draw path. Small, self-contained fix.

**@⁠cerealfordinner** on GitHub · 2026-12-04 23:06 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/530) `cerealfordinner:upstream-pr-placed-texture-outside-lock` → `main` · +21 −3 · 1 files · 1 commits · closed without merging Texture lookup takes the lock only to look; texture creation happens under a separate MAKING lock, cutting lock contention on the draw path. Small, self-contained fix.
`texture_at` held PLACED_TEXTURES while it made the resource for a texture
placed in title memory. The list threads look textures up in that table
for their draws all the time, so while one made a texture the others
waited: in a timeline of a busy scene ~40% of the list calls of 5 ms or
more was waiting on locks, this one the most (texture_at, texture_at_made,
and lookups without a stack, on the same lock).

A lookup now takes the lock only to look. A thread that has to make a
texture takes the `MAKING` lock, looks again, makes it without the table's
lock and then puts it in the table, so makers take turns and none makes a
texture another just made (a twin would take the first one's place in
`TARGETS_AT`, and be let go after it).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bg4XQaVExsGA3ocyAed39H
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 23:10:38 +00:00
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-05 00:59 UTC · original

For reviewers, this is the same change as f84b643 in #355, line for line (same commit author too), just on its own. I went through that commit on native Windows when re-checking #355. The second lookup under MAKING stops a double make, and the insert, the placed flag and Placed::retain all happen before PLACED_TEXTURES is let go, so the trim thread can't drop a fresh entry. The 8 threads by 48 keys texture_at test ended with one resource per key. So nothing new to add on the code. It's mostly a question of whether it lands here or with #355, since whichever goes second will conflict in resource.rs.

AI-assisted: yes

**@⁠Kal0s-design** on GitHub · 2026-12-05 00:59 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/530#issuecomment-7428835011) For reviewers, this is the same change as f84b643 in #355, line for line (same commit author too), just on its own. I went through that commit on native Windows when re-checking #355. The second lookup under `MAKING` stops a double make, and the insert, the `placed` flag and `Placed::retain` all happen before `PLACED_TEXTURES` is let go, so the trim thread can't drop a fresh entry. The 8 threads by 48 keys `texture_at` test ended with one resource per key. So nothing new to add on the code. It's mostly a question of whether it lands here or with #355, since whichever goes second will conflict in resource.rs. AI-assisted: yes
github-bot closed this pull request 2026-12-05 19:22:11 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.