Texture store: at most 8 textures wait for its thread (the copies piled up unbounded; #227) #288

Open
github-bot wants to merge 1 commit from github-bot/gh-288 into main AGit
Owner

@⁠sharan104 on GitHub · 2026-11-26 14:31 UTC · original
sharan104:fix/texstore-bounded-queue → main · +51 −4 · 1 files · 1 commits · open

Refs #227 (one of the items it lists as open to anyone).

texstore::keep sends a full copy of each texture's memory (tiled.to_vec()) over an unbounded mpsc::channel to the single "texture store" thread, which digests, detiles and writes each one. When textures arrive faster than that thread keeps up (streaming in a new area), the copies pile up in the channel with no limit: whole texture memories, held until the thread reaches them.

Fix:

  • A sync_channel of WAITING (8) jobs, filled with try_send.
  • A texture that finds the queue full is taken back out of seen, so it's stored the next time it's read whole. The store loses nothing; it just catches up later.
  • If the store's thread is gone (the channel is disconnected), the texture stays in seen and isn't copied again on every read.

Test: textures_wait_for_the_store_in_bounds queues 13 textures into a channel nobody drains. Only the first 8 wait, and the other 5 are no longer in seen. With the receiver dropped, a texture stays seen. The test fails without the seen removal and passed 10 runs out of 10.

Results:

  • cargo test -p victory-gpu --locked passes, with and without --all-features.
  • Clippy adds nothing beyond main's existing watch.rs lint, which #241 fixes.

This touches different lines of texstore.rs from #283, which adds the asset-policy check to the store's folder. The two merge independently.

🤖 Generated with Claude Code

**@⁠sharan104** on GitHub · 2026-11-26 14:31 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/288) `sharan104:fix/texstore-bounded-queue` → `main` · +51 −4 · 1 files · 1 commits · open Refs #227 (one of the items it lists as open to anyone). `texstore::keep` sends a full copy of each texture's memory (`tiled.to_vec()`) over an **unbounded** `mpsc::channel` to the single "texture store" thread, which digests, detiles and writes each one. When textures arrive faster than that thread keeps up (streaming in a new area), the copies pile up in the channel with no limit: whole texture memories, held until the thread reaches them. **Fix:** - A `sync_channel` of `WAITING` (8) jobs, filled with `try_send`. - A texture that finds the queue full is taken back out of `seen`, so it's stored the next time it's read whole. The store loses nothing; it just catches up later. - If the store's thread is gone (the channel is disconnected), the texture stays in `seen` and isn't copied again on every read. **Test:** `textures_wait_for_the_store_in_bounds` queues 13 textures into a channel nobody drains. Only the first 8 wait, and the other 5 are no longer in `seen`. With the receiver dropped, a texture stays seen. The test fails without the `seen` removal and passed 10 runs out of 10. **Results:** - `cargo test -p victory-gpu --locked` passes, with and without `--all-features`. - Clippy adds nothing beyond main's existing `watch.rs` lint, which #241 fixes. This touches different lines of `texstore.rs` from #283, which adds the asset-policy check to the store's folder. The two merge independently. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
keep() hands the store's thread a copy of a texture's whole memory over
an unbounded channel. When textures were read whole faster than that one
thread could digest, detile and write them (a level loading), the copies
piled up with no limit, beside the 4 GiB the store already keeps.

The channel now holds 8 at most and keep() does not wait: a texture that
finds it full is dropped and taken out of the seen set again, so it is
kept the next time it is read whole. If the thread is gone, it stays
seen, so it is not copied again and again for nothing. The test fills
the queue past its bound; without taking a refused texture out of the
seen set it fails, with it it passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:34:15 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/288/head:github-bot/gh-288'
git switch 'github-bot/gh-288'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-288'
git switch 'github-bot/gh-288'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-288'
git switch 'github-bot/gh-288'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-288'
git switch 'main'
git merge --squash 'github-bot/gh-288'
git switch 'main'
git merge --ff-only 'github-bot/gh-288'
git switch 'main'
git merge 'github-bot/gh-288'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.