Repository navigation
Conversation
…same results (PERF-RESTOFWORLD-JOIN) _u16/_u32/_u64 use precompiled structs and rely on struct.error for the bounds check. _validate_meshlet_buffer reads all cluster records in one unpack and tests each cluster's packed triangle words with one big-integer lane check; a cluster that fails it goes through the old per-word loop, which names the error. Parity tests compare the readers, the triangle check and the whole meshlet validation against an inline copy of the old code. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
leoleahy
left a comment
There was a problem hiding this comment.
Independent Windows 11 / Python 3.14.8 review of 8a753bc5 (synthetic inputs, CPU only, no game data).
Checks run
python -I tests/test_restofworld_model_join_fast.py: 5/5 OK on8a753bc5.python -I tests/test_restofworld_model_join.py: 9/9 OK on8a753bc5.- Negative control against parent
dde82f27'stools/restofworld_model_join.py: 2 errors (AttributeError: module 'restofworld_model_join' has no attribute '_triangles_in_range'). python -m compileall -q tools/restofworld_model_join.py tests/test_restofworld_model_join_fast.py,git diff --check dde82f27..8a753bc5, andgit merge-tree --write-tree upstream/main HEAD: all clean.
Code review notes
- Bounds and bit-arithmetic verified:
_validate_meshlet_bufferenforces0 < clusters <= 2048(fitting in 11-bitm11) andend_at <= ib_off + ib_bytes <= len(gfx_bytes)before unpackingrecordsand slicinggfx_bytes[at:at + c_tris * 4]. - In
_triangles_in_range,1 <= c_verts <= 128keeps each lane sum<= 127 + 127 = 254 < 256(no carry across lanes), bit 7 (m80) flags any index>= c_verts, and any failure delegates to_check_triangles_slowso error messages stay identical.
LGTM.
AI-assisted.
|
Windows, Python 3.13.7, synthetic inputs. Tested 8a753bc and compared with dde82f2. I compared _validate_meshlet_buffer to the PR fixture's reference implementation on 32 synthetic clusters of 64 vertices. Both returned identical results. Median milliseconds per call over seven batches of 100: at 4 triangles per cluster, reference 0.0488 and PR 0.0395. At 128 triangles per cluster, reference 0.3844 and PR 0.0876. All five focused parity tests passed on the PR. This times in-memory meshlet validation only. AI-assisted verification · GPT-6.2 Astra Medium |
|
Independent Intel Core i5-12400 benchmark for Leonida PR #7826 Intel Core i5-12400, Windows 11 25H2 (26220.9836), CPython 3.12.14 x64. End-to-end scan_rpf wall time, median of 40 samples per revision and fixture. Fixture | Drawables x clusters | Vertices / triangles per cluster | Baseline | Patch | Time reduction The sparse interquartile ranges overlapped (190.28–194.64 ms baseline and All 4, 100, and 300 expected drawables joined, respectively, with zero failed The existing model-join suite passed 9/9 on both revisions. The five new |
|
Tested 8a753bc on Windows 11, Python 3.15.2, NVIDIA RTX 4060 Ti (driver 621.24; CPU-only checks, no game files, no GPU/llvm-mc/MSVC used): pass. Ran the test files this PR adds or changes, from a clean checkout of the PR head: AI-assisted (Claude Code). |
AI-assisted (Claude Code). Claimed in #7694 (item PERF-RESTOFWORLD-JOIN). Depends on: none.
What changes
tools/restofworld_model_join.py:_u16/_u32/_u64use precompiledstruct.Structreaders; the bounds check is thestruct.errorthey raise (plusat < 0), sameJoinErrormessages._validate_meshlet_bufferreads all cluster records in oneunpack_from. Each cluster's packed triangle words are checked together as lanes of one big integer (_triangles_in_range): cluster id equal, and each 7-bit index below the vertex count via a carry-free add. AFalseanswer sends the cluster to_check_triangles_slow, the old per-word loop, so every rejection keeps its original message. The record read cannot run past the buffer because the payload-size check above it already bounds the group.Not touched:
join_streams/ModelSystemPages(claimed in #7750 by another contributor).Measured (Windows, Python 3.12, synthetic archives built by the existing test helpers)
End-to-end
scan_rpf, best of 5;tracemallocpeak was identical old vs new in every case.resourcesrows compare equal.So the gain is in meshlet-heavy groups; archives of many tiny groups are unchanged.
Tests
New
tests/test_restofworld_model_join_fast.py(5 tests, synthetic bytes only, no hashes or byte pins): the readers against a reference at every offset near both ends (bytes, bytearray, memoryview, empty);_triangles_in_rangeagainst the per-word loop on random clusters and over every index value x every cluster size; and_validate_meshlet_bufferagainst an inline copy of the old function on valid groups, 600 randomly corrupted groups and every truncation length.python -I -m compileall -q make_game.py tools testspython -I tests/test_restofworld_model_join.py(9 tests) andtests/test_restofworld_model_join_fast.py(5 tests)tests/semantic(translator suite, unrelated). No GPU involved.🤖 Generated with Claude Code