instance_lists: count grass and prop records in bulk (OLD-10049) #1161

Open
github-bot wants to merge 2 commits from github-bot/gh-1161 into main AGit
Owner

@⁠sodove on GitHub · 2026-11-24 19:25 UTC · original
sodove:perf/bulk-instance-counts-10049 → main · +225 −31 · 3 files · 2 commits · open

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

Depends on: none.

What changed

Carries forward tedin7's commit from draft #315 onto 6293c1c4f, retaining the original author. tools/instance_lists.py counts grass byte fields in bulk and unpacks prop matrices in batches while scanning map resources.

The second commit fixes two differences from the record-by-record implementation that showed up during the port. A complete final prop matrix can lack some or all of its trailing record padding. The draft raised struct.error in that case. The second difference was numerical: changing how the squared axis lengths were summed flipped the handedness count for a synthetic singular matrix on CPython 3.12. The port now preserves the original rounding for axis lengths and dot products. Regression tests cover both cases.

Measurements

Windows 11 x64, Ryzen 5 9600X, CPython 3.12.10. Each synthetic list contained 65,535 instances. The table gives median elapsed time over eight paired runs with alternating order, excluding fixture creation. All count dictionaries matched the parent. Every pair favored the PR.

Input Parent PR Speedup
Grass, clustered near-upright normals 58.09 ms 4.62 ms 12.59×
Grass, uniformly distributed normal bytes 56.59 ms 14.40 ms 3.93×
Props, mixed matrices 474.56 ms 150.39 ms 3.16×

These measurements cover the instance-counting functions used by the offline analysis tool.

Tested

  • Compared complete count dictionaries against 6293c1c4f across 12,075 additional synthetic combinations of buffer length, record stride and member offset.
  • test_instance_lists.py and test_instance_lists_schema_gap.py: 22 tests passed on each of CPython 3.10 and 3.12. The carried-over grass speed test failed on the parent, and the new matrix cases reproduced both regressions before the second commit.
  • Full semantic suite: 6,168 tests in 470 files, zero failed files. The docs link tests, text line-ending tests and game-data check on all three changed paths passed.
  • #717 touches the same tool. A local merge with its head 0cbc40239 applied cleanly. All 83 tests across test_instance_lists, test_instance_lists_schema_gap, test_world_interior_names and test_world_lights_paths passed together.

GPUs tested: n/a (CPU-only). Only synthetic inputs were used.

AI-assisted: yes (OpenAI Codex).

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • Only source, synthetic tests and documentation.
  • No translator rules changed.
**@⁠sodove** on GitHub · 2026-11-24 19:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1161) `sodove:perf/bulk-instance-counts-10049` → `main` · +225 −31 · 3 files · 2 commits · open Claimed in the coordination issue as: OLD-10049 ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)). Depends on: none. ### What changed Carries forward tedin7's commit from draft #315 onto `6293c1c4f`, retaining the original author. `tools/instance_lists.py` counts grass byte fields in bulk and unpacks prop matrices in batches while scanning map resources. The second commit fixes two differences from the record-by-record implementation that showed up during the port. A complete final prop matrix can lack some or all of its trailing record padding. The draft raised `struct.error` in that case. The second difference was numerical: changing how the squared axis lengths were summed flipped the handedness count for a synthetic singular matrix on CPython 3.12. The port now preserves the original rounding for axis lengths and dot products. Regression tests cover both cases. ### Measurements Windows 11 x64, Ryzen 5 9600X, CPython 3.12.10. Each synthetic list contained 65,535 instances. The table gives median elapsed time over eight paired runs with alternating order, excluding fixture creation. All count dictionaries matched the parent. Every pair favored the PR. | Input | Parent | PR | Speedup | |---|---:|---:|---:| | Grass, clustered near-upright normals | 58.09 ms | 4.62 ms | 12.59× | | Grass, uniformly distributed normal bytes | 56.59 ms | 14.40 ms | 3.93× | | Props, mixed matrices | 474.56 ms | 150.39 ms | 3.16× | These measurements cover the instance-counting functions used by the offline analysis tool. ### Tested - Compared complete count dictionaries against `6293c1c4f` across 12,075 additional synthetic combinations of buffer length, record stride and member offset. - `test_instance_lists.py` and `test_instance_lists_schema_gap.py`: 22 tests passed on each of CPython 3.10 and 3.12. The carried-over grass speed test failed on the parent, and the new matrix cases reproduced both regressions before the second commit. - Full semantic suite: 6,168 tests in 470 files, zero failed files. The docs link tests, text line-ending tests and game-data check on all three changed paths passed. - #717 touches the same tool. A local merge with its head `0cbc40239` applied cleanly. All 83 tests across `test_instance_lists`, `test_instance_lists_schema_gap`, `test_world_interior_names` and `test_world_lights_paths` passed together. GPUs tested: n/a (CPU-only). Only synthetic inputs were used. AI-assisted: yes (OpenAI Codex). ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] Only source, synthetic tests and documentation. - [x] No translator rules changed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:40:55 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 19:26 UTC · original · approved these changes

Reviewed and verified. Impressive performance optimization in tools/instance_lists.py (OLD-10049) bulk-counting grass records and batch-unpacking prop matrices (3.16x - 12.59x speedup). Correctly handles partial trailing padding and preserves exact matrix handedness rounding. Validated against 12,075 synthetic combinations in test_instance_lists.py (22/22 PASS). 100% clean-room.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 19:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1161#pullrequestreview-6045895960) · **approved these changes** Reviewed and verified. Impressive performance optimization in `tools/instance_lists.py` (OLD-10049) bulk-counting grass records and batch-unpacking prop matrices (3.16x - 12.59x speedup). Correctly handles partial trailing padding and preserves exact matrix handedness rounding. Validated against 12,075 synthetic combinations in `test_instance_lists.py` (22/22 PASS). 100% clean-room.
Author
Owner

@⁠madhyn on GitHub · 2026-11-24 19:28 UTC · original

Verified d69a50c24 on Arch Linux (Python 3.14):

  • python3 -m unittest tests/test_instance_lists.py: 20 tests passed (0.768 s)

AI-assisted: yes

**@⁠madhyn** on GitHub · 2026-11-24 19:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1161#issuecomment-7142158052) Verified `d69a50c24` on Arch Linux (Python 3.14): - `python3 -m unittest tests/test_instance_lists.py`: **20 tests passed** (0.768 s) AI-assisted: yes
Author
Owner

@⁠Deedlyy on GitHub · 2026-11-24 20:11 UTC · original

Recommendation: [MERGE]

Reasoning: Carries #315: instance_lists counts grass bytes and unpacks prop matrices in bulk, plus a second commit restoring two behaviours the draft changed (missing trailing padding, etc.). Tool change with a 146-line parity test. Verified by madhyn (20 tests). CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 3/10

**@⁠Deedlyy** on GitHub · 2026-11-24 20:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1161#issuecomment-7143175805) **Recommendation:** [MERGE] **Reasoning:** Carries #315: `instance_lists` counts grass bytes and unpacks prop matrices in bulk, plus a second commit restoring two behaviours the draft changed (missing trailing padding, etc.). Tool change with a 146-line parity test. Verified by madhyn (20 tests). CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 3/10
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/1161/head:github-bot/gh-1161'
git switch 'github-bot/gh-1161'

Merge

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