make_game assets: BCPack follow-up pass in worker processes, costliest pool first (OLD-9924) #1013

Merged
Diegobecker07 merged 3 commits from upstream-pr/1013 into main 2026-11-29 00:55:23 +00:00
Diegobecker07 commented 2026-11-24 16:49:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Diegobecker07 on 2026-11-24T16:49:58Z.


Claimed in the coordination issue as: OLD-9924 (claim)

Carries over #192 (old pull request 9924 by tedin7), rebased on current main with tedin7's commit kept as the first
commit. Once this one is reviewed, #192 can be closed in its favour.

What and why

The assets stage's BCPack follow-up pass (ttpf_assets.complete_pool) decodes in pure Python, one texture pool
after another, so it keeps one core busy: on the machine below it took 78 min 30 s with the other 23 cores
idle. This branch runs it one pool per worker process.

From tedin7's commit: parallel_map(), the results and the log lines in pool order as from a serial run, and the
first failure in pool order being the one reported. On top of it:

  • Worker processes only. The pass is pure Python, so threads would share one core.
  • Each worker reads its own manifest (follow_pool(), through the same ttpf_manifest() check), so the main
    process neither holds every pool's catalog nor pickles one to each worker. A manifest that is not complete is the
    same single build error as before.
  • Costliest pools first. follow_cost() counts the pixels of the rows complete_pool() decodes (the rows
    ttpf_assets.candidate accepts; 0 for a pool the pass already stamped), from the manifests assets() reads
    anyway. The source file's size is a poor guide: the slowest pool (467 s alone) is a 0.79 GiB one with 1,038
    candidate rows, while each 2.5 GiB terrain pool has about 250 and takes 280-400 s. Over the 52 pools measured,
    the pixel count ranks the serial times with Spearman 0.82, the file size with 0.44.
  • Progress ticks as each pool finishes.
  • Budget: --jobs, or the stage's share of it when shaders run beside it; at most 61 workers on Windows
    (ProcessPoolExecutor's limit).
  • The rpf9dump exports stay one at a time, as on main: one texture-pool export already kept about 3/4 of 24
    cores busy and peaked at 8.2 GiB, so two side by side would compete for the same cores and double the memory.

Tested

Without the game:

  • tests/test_make_game_assets_pools.py, 16 tests. New or changed: exports run one at a time with the whole
    --jobs budget; the costliest pools follow first (file sizes in the opposite order, a stamped pool last, the same
    order on a resumed build); a follow-up reads its own manifest and reports a broken one; parallel_map() returns
    results in item order and raises the earliest failure in item order. Negative control: the new tests fail on
    tedin7's commit alone (2 failures, 3 errors), and the ordering test fails with the order by file size.
  • All 23 tests/test_make_game_*.py files, tests/test_text_write_line_endings.py, scripts/check_no_game_data.py
    on the changed files, python -m compileall -q make_game.py tools tests, make_game.py --help.

With the game (retail package 1.0.2.1; Windows 11 Pro, 24 logical cores, 48 GiB, output on an SSD):

  • Before: the serial pass of a full check,assets build on main at 21625bca8, timed from the manifests'
    stamps: 11:32:07 → 12:50:37, 78 min 30 s for all 57 pools.

  • After: before the pass reached them, a watcher saved the pre-pass manifests of 52 of the 57 pools (the other 5
    are small pack pools that finished within seconds of their export). The pass was then replayed on copies of
    those 52 folders, with this branch's parallel_map(follow_pool, ...) called as assets() calls it, 12 workers
    (the default --jobs on this machine), no build or other heavy work running:

    Order of the pools Wall time Peak RAM, all Python processes
    serial (main, live build, 57 pools) 78 min 30 s -
    largest source file first (this branch's second commit) 927 s (15.4 min) 1.86 GiB
    most pixels to decode first (this branch) 624 s (10.4 min) 1.96 GiB (0.27 GiB the largest worker)

    With the cost order the slowest pool starts first and ends last, at 625 s, so the pass now takes as long as that
    one pool does on a busy machine; going lower would mean splitting a pool across workers.

  • Output: for both replays, every manifest equals the serial build's (compared as parsed JSON) and all 735 BCPack
    DDS files it wrote are byte-identical (SHA-256), with the same file list in every pool folder.

GPUs tested: n/a (build-script change, no GPU code); the build machine has an NVIDIA GeForce RTX 5070 Ti, driver
621.24, Windows 11 Pro.

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5476512123 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1013). Originally posted by [Diegobecker07](https://github.com/Diegobecker07) on 2026-11-24T16:49:58Z. --- Claimed in the coordination issue as: OLD-9924 ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7134363306)) Carries over #192 (old pull request 9924 by tedin7), rebased on current `main` with tedin7's commit kept as the first commit. Once this one is reviewed, #192 can be closed in its favour. ### What and why The assets stage's BCPack follow-up pass (`ttpf_assets.complete_pool`) decodes in pure Python, one texture pool after another, so it keeps one core busy: on the machine below it took **78 min 30 s** with the other 23 cores idle. This branch runs it one pool per worker process. From tedin7's commit: `parallel_map()`, the results and the log lines in pool order as from a serial run, and the first failure in pool order being the one reported. On top of it: - **Worker processes only.** The pass is pure Python, so threads would share one core. - **Each worker reads its own manifest** (`follow_pool()`, through the same `ttpf_manifest()` check), so the main process neither holds every pool's catalog nor pickles one to each worker. A manifest that is not complete is the same single build error as before. - **Costliest pools first.** `follow_cost()` counts the pixels of the rows `complete_pool()` decodes (the rows `ttpf_assets.candidate` accepts; 0 for a pool the pass already stamped), from the manifests `assets()` reads anyway. The source file's size is a poor guide: the slowest pool (467 s alone) is a 0.79 GiB one with 1,038 candidate rows, while each 2.5 GiB terrain pool has about 250 and takes 280-400 s. Over the 52 pools measured, the pixel count ranks the serial times with Spearman 0.82, the file size with 0.44. - **Progress** ticks as each pool finishes. - **Budget:** `--jobs`, or the stage's share of it when shaders run beside it; at most 61 workers on Windows (`ProcessPoolExecutor`'s limit). - **The `rpf9dump` exports stay one at a time**, as on `main`: one texture-pool export already kept about 3/4 of 24 cores busy and peaked at 8.2 GiB, so two side by side would compete for the same cores and double the memory. ### Tested Without the game: - `tests/test_make_game_assets_pools.py`, 16 tests. New or changed: exports run one at a time with the whole `--jobs` budget; the costliest pools follow first (file sizes in the opposite order, a stamped pool last, the same order on a resumed build); a follow-up reads its own manifest and reports a broken one; `parallel_map()` returns results in item order and raises the earliest failure in item order. Negative control: the new tests fail on tedin7's commit alone (2 failures, 3 errors), and the ordering test fails with the order by file size. - All 23 `tests/test_make_game_*.py` files, `tests/test_text_write_line_endings.py`, `scripts/check_no_game_data.py` on the changed files, `python -m compileall -q make_game.py tools tests`, `make_game.py --help`. With the game (retail package 1.0.2.1; Windows 11 Pro, 24 logical cores, 48 GiB, output on an SSD): - **Before:** the serial pass of a full `check,assets` build on `main` at `21625bca8`, timed from the manifests' stamps: 11:32:07 → 12:50:37, **78 min 30 s** for all 57 pools. - **After:** before the pass reached them, a watcher saved the pre-pass manifests of 52 of the 57 pools (the other 5 are small pack pools that finished within seconds of their export). The pass was then replayed on copies of those 52 folders, with this branch's `parallel_map(follow_pool, ...)` called as `assets()` calls it, 12 workers (the default `--jobs` on this machine), no build or other heavy work running: | Order of the pools | Wall time | Peak RAM, all Python processes | |---|---|---| | serial (`main`, live build, 57 pools) | 78 min 30 s | - | | largest source file first (this branch's second commit) | 927 s (15.4 min) | 1.86 GiB | | most pixels to decode first (this branch) | **624 s (10.4 min)** | 1.96 GiB (0.27 GiB the largest worker) | With the cost order the slowest pool starts first and ends last, at 625 s, so the pass now takes as long as that one pool does on a busy machine; going lower would mean splitting a pool across workers. - **Output:** for both replays, every manifest equals the serial build's (compared as parsed JSON) and all 735 BCPack DDS files it wrote are byte-identical (SHA-256), with the same file list in every pool folder. GPUs tested: n/a (build-script change, no GPU code); the build machine has an NVIDIA GeForce RTX 5070 Ti, driver 621.24, Windows 11 Pro. AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change)
Diegobecker07 commented 2026-11-25 13:13:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Diegobecker07 on 2026-11-25T13:13:36Z.


Re-checked against current main (0d80bc5df). Main changed make_game.py in other places and the PR still merges cleanly, so I did not rebase it. On the merged tree, all 24 tests/test_make_game_*.py files pass, along with test_text_write_line_endings.py, compileall and make_game.py --help.

The three open PRs that touch make_game.py (#1013, #1378, #1407) also merge with each other without conflicts. The same tests pass with all three merged on main (27 files).

CI is waiting for workflow approval (first-time contributor).

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7163469935 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1013#issuecomment-7163469935). Originally posted by [Diegobecker07](https://github.com/Diegobecker07) on 2026-11-25T13:13:36Z. --- Re-checked against current main (0d80bc5df). Main changed `make_game.py` in other places and the PR still merges cleanly, so I did not rebase it. On the merged tree, all 24 `tests/test_make_game_*.py` files pass, along with `test_text_write_line_endings.py`, `compileall` and `make_game.py --help`. The three open PRs that touch `make_game.py` (#1013, #1378, #1407) also merge with each other without conflicts. The same tests pass with all three merged on main (27 files). CI is waiting for workflow approval (first-time contributor). AI-assisted.
Diegobecker07 commented 2026-11-25 18:16:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Diegobecker07 on 2026-11-25T18:16:08Z.


Rebased onto current main (b9320a118). The only conflict was the import block: main added import traceback next to the concurrent.futures line this PR extends. tedin7's commit keeps its author, and git range-diff shows changes to that import context only. The third commit is unchanged.

Re-verified on Windows 11 Pro (26300) with Python 3.14. On the rebased branch, all 24 tests/test_make_game_*.py files pass (16 tests in test_make_game_assets_pools.py), along with test_text_write_line_endings.py, test_dstorage_history.py, compileall and make_game.py --help. The three open PRs that touch make_game.py (#1013, #1378, #1407) still merge with each other without conflicts, and the same set passes with all three merged on main (26 files). The BCPack timings in the description were measured on the previous base and were not rerun.

CI for this push is waiting for workflow approval (first-time contributor).

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7170675844 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1013#issuecomment-7170675844). Originally posted by [Diegobecker07](https://github.com/Diegobecker07) on 2026-11-25T18:16:08Z. --- Rebased onto current main (b9320a118). The only conflict was the import block: main added `import traceback` next to the `concurrent.futures` line this PR extends. tedin7's commit keeps its author, and `git range-diff` shows changes to that import context only. The third commit is unchanged. Re-verified on Windows 11 Pro (26300) with Python 3.14. On the rebased branch, all 24 `tests/test_make_game_*.py` files pass (16 tests in `test_make_game_assets_pools.py`), along with `test_text_write_line_endings.py`, `test_dstorage_history.py`, `compileall` and `make_game.py --help`. The three open PRs that touch `make_game.py` (#1013, #1378, #1407) still merge with each other without conflicts, and the same set passes with all three merged on main (26 files). The BCPack timings in the description were measured on the previous base and were not rerun. CI for this push is waiting for workflow approval (first-time contributor). AI-assisted.
zmasi commented 2026-11-29 00:22:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T00:22:29Z.


Native Windows 11 spawn Multiprocessing Verification (b6b1fe75fc) — PASS

Diff-audited make_game.py (+84/-12) and tests/test_make_game_assets_pools.py (+186/-0) and verified Red -> Green merged onto origin/main (48bae6cad) on Windows 11 (10.0.26200, NTFS, Python 3.12.10 with -I, Windows spawn ProcessPoolExecutor).

Results

  • Red (origin/main 48bae6cad with PR's test_make_game_assets_pools.py): FAILED (failures=1, errors=4) (Ran 16 tests in 9.048s, rc=1 — pool follow-ups ran serially so follow_that_needs_company timed out waiting for a concurrent peer worker, and follow_pool / parallel_map / ExportFailed were absent).
  • Green (PR #1013 merged onto origin/main):
    • python -I tests/test_make_game_assets_pools.py: Ran 16 tests in 2.762s — OK (rc=0) on native Windows spawn worker processes, confirming clean pickling of module-level callables across ProcessPoolExecutor (os.name == "nt" 61-worker cap), concurrent multi-pool BCPack follow-ups logging deterministically in pool order, descending pixel-cost scheduling (stamped pools weighted 0), and earliest-in-pool-order failure reporting.
    • tests/test_ci_registration.py (18/18), tests/test_text_write_line_endings.py (3/3), and scripts/check_no_game_data.py: OK.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248067947 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1013#issuecomment-7248067947). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T00:22:29Z. --- ### Native Windows 11 `spawn` Multiprocessing Verification (`b6b1fe75fc`) — PASS Diff-audited `make_game.py` (`+84/-12`) and `tests/test_make_game_assets_pools.py` (`+186/-0`) and verified Red -> Green merged onto `origin/main` (`48bae6cad`) on Windows 11 (`10.0.26200`, NTFS, Python `3.12.10` with `-I`, Windows `spawn` `ProcessPoolExecutor`). #### Results - **Red (`origin/main` `48bae6cad` with PR's `test_make_game_assets_pools.py`)**: `FAILED (failures=1, errors=4)` (`Ran 16 tests in 9.048s`, `rc=1` — pool follow-ups ran serially so `follow_that_needs_company` timed out waiting for a concurrent peer worker, and `follow_pool` / `parallel_map` / `ExportFailed` were absent). - **Green (`PR #1013` merged onto `origin/main`)**: - `python -I tests/test_make_game_assets_pools.py`: **`Ran 16 tests in 2.762s — OK`** (`rc=0`) on native Windows `spawn` worker processes, confirming clean pickling of module-level callables across `ProcessPoolExecutor` (`os.name == "nt"` `61`-worker cap), concurrent multi-pool BCPack follow-ups logging deterministically in pool order, descending pixel-cost scheduling (`stamped` pools weighted `0`), and earliest-in-pool-order failure reporting. - `tests/test_ci_registration.py` (`18/18`), `tests/test_text_write_line_endings.py` (`3/3`), and `scripts/check_no_game_data.py`: **`OK`**. AI-assisted.
enlight3d commented 2026-11-29 00:43:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T00:43:41Z.


RUN of #1013 (red/green, python -I, no build, no game, no GPU)

Heads tested: PR head b6b1fe75fc03, current main 829530dbd019; merged = main + PR head, git merge --no-ff, local only (merged cleanly).

Commands, one process each, from the worktree root:
python -I tests/test_make_game_assets_pools.py
Related: every tests/test_make_game_*.py (25 other files) and every other test file that mentions make_game (30 files, e.g. test_ttpf_assets.py, test_progress_dashboard.py, test_shader_stage_resume.py, test_semantic_mutants.py, test_docs_cli_flags.py, test_text_write_line_endings.py, test_ci_registration.py; those that exist on the tested tree). Also python -I -m compileall -q make_game.py tools tests and python -I make_game.py --help.

  • Red (main's make_game.py with the PR's version of the test file): FAILED (failures=1, errors=4) of 16 tests. Four tests error because parallel_map and ExportFailed do not exist in main's make_game.py (AttributeError), and test_the_costliest_pools_follow_first fails its order assertion (main does not put the stamped pool last). This is a real red: the new and changed tests fail on main's code for the reason the PR fixes (the follow-up pass in worker processes, costliest pool first).
  • Green at PR head: test_make_game_assets_pools.py 16 ran, OK; compileall and --help exit 0. Of the 50 related files that exist at that head, all pass except test_tool_stdout_encoding.py (1 failure), which also fails on plain main.
  • Green merged into main: test_make_game_assets_pools.py 16 ran, OK; compileall and --help exit 0. Of 55 related files, 50 pass. The 5 failures are the same on plain main (same counts), so they are pre-existing and not caused by the PR: test_make_game_pipelines.py (failures=3), test_make_game_preflight.py (failures=1), test_docs_cli_flags.py (failures=1), test_progress_dashboard.py (failures=1), test_tool_stdout_encoding.py (failures=1).
  • The timing claims in the description (78 min to 10 min) need the game and were not checked.

Machine: Windows 11 Pro 10.0.26300, CPython 3.13.12, GPU not used.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248310158 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1013#issuecomment-7248310158). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-29T00:43:41Z. --- RUN of #1013 (red/green, `python -I`, no build, no game, no GPU) Heads tested: PR head `b6b1fe75fc03`, current main `829530dbd019`; merged = main + PR head, `git merge --no-ff`, local only (merged cleanly). Commands, one process each, from the worktree root: `python -I tests/test_make_game_assets_pools.py` Related: every `tests/test_make_game_*.py` (25 other files) and every other test file that mentions `make_game` (30 files, e.g. `test_ttpf_assets.py`, `test_progress_dashboard.py`, `test_shader_stage_resume.py`, `test_semantic_mutants.py`, `test_docs_cli_flags.py`, `test_text_write_line_endings.py`, `test_ci_registration.py`; those that exist on the tested tree). Also `python -I -m compileall -q make_game.py tools tests` and `python -I make_game.py --help`. - Red (main's `make_game.py` with the PR's version of the test file): `FAILED (failures=1, errors=4)` of 16 tests. Four tests error because `parallel_map` and `ExportFailed` do not exist in main's `make_game.py` (`AttributeError`), and `test_the_costliest_pools_follow_first` fails its order assertion (main does not put the stamped pool last). This is a real red: the new and changed tests fail on main's code for the reason the PR fixes (the follow-up pass in worker processes, costliest pool first). - Green at PR head: `test_make_game_assets_pools.py` 16 ran, OK; compileall and `--help` exit 0. Of the 50 related files that exist at that head, all pass except `test_tool_stdout_encoding.py` (1 failure), which also fails on plain main. - Green merged into main: `test_make_game_assets_pools.py` 16 ran, OK; compileall and `--help` exit 0. Of 55 related files, 50 pass. The 5 failures are the same on plain main (same counts), so they are pre-existing and not caused by the PR: `test_make_game_pipelines.py` (failures=3), `test_make_game_preflight.py` (failures=1), `test_docs_cli_flags.py` (failures=1), `test_progress_dashboard.py` (failures=1), `test_tool_stdout_encoding.py` (failures=1). - The timing claims in the description (78 min to 10 min) need the game and were not checked. Machine: Windows 11 Pro 10.0.26300, CPython 3.13.12, GPU not used.
MoonEyes commented 2026-11-29 00:55:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T00:55:25Z.


Merged after enlight3d's red/green check (check) (RTX 3090, driver 621.40, Windows 11) and a local re-check here. Merged after local re-verification: this PR merged onto main 57d3222bf without conflict, and its test file(s) (tests/test_make_game_assets_pools.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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248443911 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1013#issuecomment-7248443911). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T00:55:25Z. --- Merged after **enlight3d**'s red/green check ([check](https://github.com/ProjectLeonida/mandy/pull/1013#issuecomment-7248310158)) (RTX 3090, driver 621.40, Windows 11) and a local re-check here. Merged after local re-verification: this PR merged onto `main` 57d3222bf without conflict, and its test file(s) (`tests/test_make_game_assets_pools.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 reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1013
No description provided.