mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:50:53 +01:00
[PR #315] instance_lists: count grass and prop instances in bulk (9x / 3.6x, same output) #366
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#366
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/315
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:old-pr/10049📝 Commits (1)
24ac126perf: read grass and prop instance lists in bulk in instance_lists📊 Changes
3 files changed (+212 additions, -31 deletions)
View changed files
📝
docs/world.md(+5 -1)📝
tests/test_instance_lists.py(+132 -0)📝
tools/instance_lists.py(+75 -30)📄 Description
Original description (mentions and
#Nreferences are disabled; the numbers refer to the old repository):@ItsNotRexed: an exe PR, as you asked.What
tools/instance_lists.pycounts prop and grass instances (hundreds of millions over the full corpus) one record at a time in Python. This reads them in bulk instead:bytes.count/max.Struct.iter_unpackpass, with local counters instead of eight dict updates per instance.break.Output is identical.
tools/world_build.pyandtools/sandbox_scene.pydo not read these lists (they take entity placements), so I left them alone;docs/world.mdsays so and gives the numbers.Why
A list holds at most 65,535 instances (u16 count), so memory was never the problem: one resource plus its joined streams. Time was: the full corpus is about 225 M grass and 26 M prop instances at roughly 1.4 us and 12 us each in Python.
Tested
Synthetic bytes only, no game file.
tests/test_instance_lists.py: grass and prop counts equal a record-by-record oracle on seeded random data, including NaN/zero matrices and buffers cut mid-list (5 + 3 cases); a speed test needs bulk at least 4x faster than the oracle on near-upright grass normals.instance_lists.pythe speed test fails (bulk 0.0915 s vs 0.0719 s); with the change all 19 tests pass, andtests/test_instance_lists_schema_gap.pystill passes.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.