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

Open
github-bot wants to merge 3 commits from github-bot/gh-1013 into main AGit
Owner

@⁠Diegobecker07 on GitHub · 2026-11-24 16:49 UTC · original
Diegobecker07:old-9924-bcpack-parallel → main · +276 −9 · 2 files · 3 commits · open

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)
**@⁠Diegobecker07** on GitHub · 2026-11-24 16:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1013) `Diegobecker07:old-9924-bcpack-parallel` → `main` · +276 −9 · 2 files · 3 commits · open Claimed in the coordination issue as: OLD-9924 ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)) 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)
On top of tedin7's change, for the follow-up pass (ttpf_assets.complete_pool):

- Each worker reads its own pool's manifest (follow_pool), so the build no
  longer parses every pool's catalog before the pass, holds them all at once
  or pickles one to each worker.
- The largest pools start first, so the longest one doesn't run alone at
  the end. Log lines still come in pool order once the pass is done.
- Progress ticks as each pool finishes. After a failure the pools not
  started yet are dropped and the earliest failure in list order is raised.
- The budget is the stage's: --jobs, or its share when the assets stage
  runs beside the shaders stage; at most 61 workers on Windows
  (ProcessPoolExecutor's limit).

The archive and pool exports run one at a time again, each with the whole
budget: one rpf9dump ttpf export already keeps about 3/4 of 24 cores busy
and peaked at 8.2 GiB here, so side-by-side exports would add memory for
little time.
The pass ran the largest source pools first, but a pool's file size says little about its follow-up time: on the
retail package 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 ~250 and takes 280-400 s. Started 34th of 52, it ran alone for the last five minutes.

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 completeness check before the
exports and the one after each export. Only the number is kept; the worker reads its manifest again.

Over the 52 pools measured, the pixel count ranks the serial times with Spearman 0.82 (source size 0.44). On a
replay of the pass with 12 workers it brings the pass from 927 s to 624 s, the time of the slowest pool alone; the
output is byte-identical to the serial build's.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:33:33 +00:00
Author
Owner

@⁠Diegobecker07 on GitHub · 2026-11-25 13:13 UTC · original

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** on GitHub · 2026-11-25 13:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1013#issuecomment-7163469935) 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.
Author
Owner

@⁠Diegobecker07 on GitHub · 2026-11-25 18:16 UTC · original

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.

**@⁠Diegobecker07** on GitHub · 2026-11-25 18:16 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1013#issuecomment-7170675844) 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.
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/1013/head:github-bot/gh-1013'
git switch 'github-bot/gh-1013'

Merge

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