Repository navigation
Conversation
…, output unchanged (PERF-RSC8-AUDIO) parse_adat_header_bytes unpacks a stream's tag rows with one struct call instead of one per word; decode_grid20_table and decode_marker_records read 256 entries/records per unpack_from and test ascending order, the p % 32 rule and the offset/extra maxima with all(map(...)), any(map(...)) and a Counter; decode_index_runs stops comparing once a run has descended; and the 0xbd tag is unpacked once (with its region-word flag) instead of twice in _tally_undocumented_tables. pair_marker_regions' early-out is one set lookup. The blocks keep the transient memory bounded (about 70 KiB however large the tag). decode_marker_records, decode_grid20_table and parse_adat_header_bytes return exactly what they did. tests/test_rsc8_audio_tables.py compares each decoder with a per-word reference on synthetic bytes at both sides of the block edge, with every invariant broken at a block edge, truncated and random tables. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Tested eb55b0d 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). |
|
Tested
The PR used 18.1% less CPU time in this one sequential pair (parent first). Timing covered the scan itself, with archive verification and report comparison outside the timed region. CachyOS, CPython 3.14.10, Core i9-12900K. AI-assisted QA. |
Item: PERF-RSC8-AUDIO (claimed in #7049). AI-assisted (Claude Code); written and checked by an agent, CPU only, synthetic data only.
What changed
tools/rsc8_audio.pyhas no PCM/ADPCM code; its hot loops are the AWC bank header parse and the companion-table decoders that run for every stream of a scan (420,1680xbdtags inaudio.rpf). Those now read their words a block at a time instead of onestructcall and one Python iteration per word:parse_adat_header_bytes: oneunpack_fromfor the stream words and one per stream's tag rows.decode_grid20_table: 256 entries perunpack_from; strictly-increasing positions withall(map(lt, ...)),p % 32asword2 & 31withany(map(...)).decode_marker_records(now a thin wrapper of_decode_marker_records): 256 records perunpack_from; names counted with aCounter(first-seen order kept), ascending/max checks withmap/maxon slices. The region-word flag comes out of the same pass, so_tally_undocumented_tablesno longer unpacks the tag a second time, and a tag with no region cue never builds its record list.decode_index_runs: the ascending check isall(map(lt, run, run[1:]))and stops once a run has descended.pair_marker_regions: the "no region cue" early-out is a set lookup.No change to the CLI, progress, error handling,
scan_*, the report writer or any returned key, value or order. Not touched: the lines of #6361, #4355, #5608. #5518 and #6780 re-add the region pairing that main already has, so a trial merge of them conflicts in the0xbdblock with this branch (it needs a rebase of theirs whichever lands first); #6361, #4355 and #5608 merge clean.Numbers
Python 3.12.10, Windows 11, one core, synthetic banks (6 banks x 40 streams:
0x76,0x5a150-400 entries,0xd920-60 groups,0xbd200-600 records with region cues on a third of the streams,0x55, and an RSC8 clip on every fourth stream). Minimum of 25 interleaved runs, base and branch in one process:decode_awc_bankx6, in memoryscan_dirof the same files (with file reads), best of 7, three runsMemory (
tracemallocpeak):decode_awc_bankx6 750 KiB -> 754 KiB (+4 KiB, 0.5 %, the per-block words);scan_dir1681 KiB -> 1670 KiB; the 16 MiB-tag region tally 588,835 KiB -> 588,730 KiB. A 16 MiB0xbdtag or a 300,000-entry0x5atable now needs a bounded transient of 72 KiB / 64 KiB however large the tag (the block size caps it).Parity
scan_dirJSON (records + summary,elapsed_secondsdropped) is byte-identical to before (same SHA-256 on every run), anddecode_awc_bankresults arerepr-identical.tests/test_rsc8_audio_tables.py(new, 21 tests): each decoder against a per-word reference at both sides of the block edge, every invariant broken at each block edge, truncated and random tables,namesfirst-seen order, thezhalf of thepword, ADAT flags/zero-stream/tag-past-end/bank-offset cases, the tally path, and the bounded-memory ceiling. Mutating the block code (a<=for<, a 15 mask for 31, a>=bound, a wrong stride) makes it fail.Tests run
python -m compileall -q tools/rsc8_audio.py tests;python -I tests/<f>fortest_rsc8_audio.py(49),test_rsc8_audio_tables.py(21),test_awc_cue_labels.py,test_awc_manifest.py,test_awc_markers.py,test_awc_names.py,test_awc_opus.py,test_awc_shorts.py,test_audio_config.py,test_audio_stage_resume.py,test_audio_wav.py,test_file_mode.py: all pass (some skip without game files).scripts/check_no_game_data.pyon the two files: clean.tests/semanticnot run (no translator change). No GPU or driver involved. (test_text_write_line_endings.pyfails ontools/leonida_tui.py:753andtools/wave_diff.py:373, untouched here.)Depends on: none.
🤖 Generated with Claude Code