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

Open
opened 2026-11-26 20:19:55 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1013
Author: @Diegobecker07
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-9924-bcpack-parallel


📝 Commits (3)

  • fd19cb2 make_game: run asset exports and pool follow-ups on --jobs workers, results in order
  • 740445a make_game assets: BCPack follow-ups in worker processes, largest first
  • b6b1fe7 make_game assets: start the BCPack follow-ups with the most pixels to decode

📊 Changes

2 files changed (+276 additions, -9 deletions)

View changed files

📝 make_game.py (+90 -9)
📝 tests/test_make_game_assets_pools.py (+186 -0)

📄 Description

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)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1013 **Author:** [@Diegobecker07](https://github.com/Diegobecker07) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-9924-bcpack-parallel` --- ### 📝 Commits (3) - [`fd19cb2`](https://github.com/ubiquitarianism/leonida/commit/fd19cb2a7c051b65fbab759cb9d97eeab9a906be) make_game: run asset exports and pool follow-ups on --jobs workers, results in order - [`740445a`](https://github.com/ubiquitarianism/leonida/commit/740445ab622d3a50dc2cc17df61e535f7713825e) make_game assets: BCPack follow-ups in worker processes, largest first - [`b6b1fe7`](https://github.com/ubiquitarianism/leonida/commit/b6b1fe75fc0331fb93a73dc13752975e9cc13568) make_game assets: start the BCPack follow-ups with the most pixels to decode ### 📊 Changes **2 files changed** (+276 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `make_game.py` (+90 -9) 📝 `tests/test_make_game_assets_pools.py` (+186 -0) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1050
No description provided.