batch_glb: allow independent texture decodes to overlap #1752

Merged
leonida/mandy
kirigayakazima merged 1 commit from codex/batch-glb-per-texture-decode into main 2026-11-28 23:50:28 +00:00

Pull request successfully merged and closed

kirigayakazima commented 2026-11-25 11:14:33 +00:00

Claimed in the coordination issue as: BATCH-GLB-PER-TEXTURE-DECODE

What and why

TextureCache held its single registry lock while reading PNGs and decoding DDS files. Workers handling unrelated textures had to wait for each other. Each path and requested size now has its own lock and result. Callers sharing a key reuse the decode, including an ordinary decode failure. If the loader raises an unexpected exception, the next request can retry.

Tested

A two-worker barrier timed out on the baseline and completed on the branch. A second regression verified retries and two decode sizes for one path. The existing test still verifies exactly one DDS decode when two workers request the same broken texture.

  • python -I tests/test_batch_glb.py passed all 18 tests on this branch (Windows, Python 3.14.7).
  • git diff --check and the repository game-data scan of all changed paths passed.
  • The five independent changes were also merged locally. Both affected test files passed together (50 tests) and the three character-model consumer suites passed (28 tests). The shared base at bcaa13da passed 6,287 semantic tests across 488 files.

GPUs tested: N/A (CPU-only asset tooling).
AI-assisted: Yes.

Checklist

  • Based on current upstream main.
  • One topic.
  • Only synthetic test fixtures. No game data, keys or decryption.
  • Translator contract table: N/A.
Claimed in the coordination issue as: [BATCH-GLB-PER-TEXTURE-DECODE](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7160621714) ### What and why TextureCache held its single registry lock while reading PNGs and decoding DDS files. Workers handling unrelated textures had to wait for each other. Each path and requested size now has its own lock and result. Callers sharing a key reuse the decode, including an ordinary decode failure. If the loader raises an unexpected exception, the next request can retry. ### Tested A two-worker barrier timed out on the baseline and completed on the branch. A second regression verified retries and two decode sizes for one path. The existing test still verifies exactly one DDS decode when two workers request the same broken texture. - `python -I tests/test_batch_glb.py` passed all 18 tests on this branch (Windows, Python 3.14.7). - `git diff --check` and the repository game-data scan of all changed paths passed. - The five independent changes were also merged locally. Both affected test files passed together (50 tests) and the three character-model consumer suites passed (28 tests). The shared base at `bcaa13da` passed 6,287 semantic tests across 488 files. GPUs tested: N/A (CPU-only asset tooling). AI-assisted: Yes. ### Checklist - [x] Based on current upstream main. - [x] One topic. - [x] Only synthetic test fixtures. No game data, keys or decryption. - Translator contract table: N/A.
lixonik reviewed 2026-11-25 11:20:00 +00:00
lixonik left a comment
No description provided.
Independent check at "417b78bb". Windows: all 18 batch tests passed. In a separate 12-worker probe, 18 simultaneous requests for three cache keys caused exactly three loader calls. Two different keys reached the loader concurrently. An ordinary decode failure was cached, two requested sizes got separate results, and an unexpected exception allowed a retry. AI-assisted review and CPU-only testing with synthetic inputs.
zmasi commented 2026-11-28 11:38:21 +00:00

#1752 | head 417b78bb6272afdcf3ca3a78e52edb827e201566 (merged cleanly with main 4a54aedcb) | python -I tests/test_batch_glb.py | red on main: FAILED (failures=1, errors=1) (BrokenBarrierError under single-lock TextureCache and cached decode ignoring max_size) | green on PR+main: 18 tests OK | Windows 11, Python 3.12.10 | AI-assisted: yes

Audited _TextureEntry and TextureCache.get_or_load in tools/batch_glb.py (keying cache entries by (path, max_size) with per-entry locking so distinct texture decodes overlap across worker threads, concurrent loads of the same key deduplicate, and unhandled exceptions leave entry.result unset for retry). Also verified clean merges (0 conflicts) and combined execution with both #1750 (20 tests OK) and #1751 (19 tests OK), plus tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), and scripts/check_no_game_data.py.

#1752 | head 417b78bb6272afdcf3ca3a78e52edb827e201566 (merged cleanly with main 4a54aedcb) | `python -I tests/test_batch_glb.py` | red on main: `FAILED (failures=1, errors=1)` (`BrokenBarrierError` under single-lock `TextureCache` and cached decode ignoring `max_size`) | green on PR+main: `18 tests OK` | Windows 11, Python 3.12.10 | AI-assisted: yes Audited `_TextureEntry` and `TextureCache.get_or_load` in `tools/batch_glb.py` (keying cache entries by `(path, max_size)` with per-entry locking so distinct texture decodes overlap across worker threads, concurrent loads of the same key deduplicate, and unhandled exceptions leave `entry.result` unset for retry). Also verified clean merges (`0` conflicts) and combined execution with both #1750 (`20 tests OK`) and #1751 (`19 tests OK`), plus `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), and `scripts/check_no_game_data.py`.
TheGeogeo commented 2026-11-28 23:38:28 +00:00

Tested 417b78bb6 merged (no commit) with main aa918e5d9: Python 3.12.4, Windows 11 10.0.26300, CPU only. check_no_game_data.py is clean.

  • Green: tests/test_batch_glb.py, 19 tests pass.
  • Red: with tools/batch_glb.py back to main, 1 failure and 1 error ((b'full', '') != (b'small', '')).
  • Merges cleanly with #2253, which changes the same tool (git merge-tree). I did not run the two together.

No blocker from my side.

AI-assisted (Claude Code).

Tested `417b78bb6` merged (no commit) with `main` `aa918e5d9`: Python 3.12.4, Windows 11 10.0.26300, CPU only. `check_no_game_data.py` is clean. - Green: `tests/test_batch_glb.py`, 19 tests pass. - Red: with `tools/batch_glb.py` back to `main`, 1 failure and 1 error (`(b'full', '') != (b'small', '')`). - Merges cleanly with #2253, which changes the same tool (`git merge-tree`). I did not run the two together. No blocker from my side. AI-assisted (Claude Code).
MoonEyes commented 2026-11-28 23:50:30 +00:00

Merged after TheGeogeo's red/green check (check) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto main ff9948f65 without conflict, and its test file(s) (tests/test_batch_glb.py) pass there. Earlier today the same tests failed on main without the PR (red/green) and a bundle with other open PRs showed no new failures. check_no_game_data.py is clean. Windows 11, Python 3.14; no GPU needed for these tests.

AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.

Merged after **TheGeogeo**'s red/green check ([check](https://github.com/ProjectLeonida/mandy/pull/1752#issuecomment-7247565788)) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto `main` ff9948f65 without conflict, and its test file(s) (`tests/test_batch_glb.py`) pass there. Earlier today the same tests failed on `main` without the PR (red/green) and a bundle with other open PRs showed no new failures. `check_no_game_data.py` is clean. Windows 11, Python 3.14; no GPU needed for these tests. _AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes._
Sign in to join this conversation.
No description provided.