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

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

📋 Pull Request Information

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

Base: main ← Head: perf/bulk-instance-counts-10049


📝 Commits (2)

  • f6691db perf: read grass and prop instance lists in bulk in instance_lists
  • d69a50c Keep prop counts stable at matrix and buffer boundaries

📊 Changes

3 files changed (+225 additions, -31 deletions)

View changed files

📝 docs/world.md (+4 -1)
📝 tests/test_instance_lists.py (+146 -0)
📝 tools/instance_lists.py (+75 -30)

📄 Description

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.

🔄 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/1161 **Author:** [@sodove](https://github.com/sodove) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `perf/bulk-instance-counts-10049` --- ### 📝 Commits (2) - [`f6691db`](https://github.com/ubiquitarianism/leonida/commit/f6691db3e24624199516444b867ea45030ae371f) perf: read grass and prop instance lists in bulk in instance_lists - [`d69a50c`](https://github.com/ubiquitarianism/leonida/commit/d69a50c240583ee37000cf4a75cda810cd1791a7) Keep prop counts stable at matrix and buffer boundaries ### 📊 Changes **3 files changed** (+225 additions, -31 deletions) <details> <summary>View changed files</summary> 📝 `docs/world.md` (+4 -1) 📝 `tests/test_instance_lists.py` (+146 -0) 📝 `tools/instance_lists.py` (+75 -30) </details> ### 📄 Description Claimed in the coordination issue as: OLD-10049 ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7141827094)). 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. --- <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#1194
No description provided.