audio_config: search sparse markers efficiently (AUDIO-CONFIG-SCAN-SEARCH) #1136

Merged
Taffyyy-ops merged 1 commit from upstream-pr/1136 into main 2026-11-29 14:37:57 +00:00
Taffyyy-ops commented 2026-11-24 19:07:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Taffyyy-ops on 2026-11-24T19:07:03Z.


Item ID: AUDIO-CONFIG-SCAN-SEARCH

Speeds up sparse audio config scanning in tools/audio_config.py:scan() by jumping directly between candidate markers with bytes.find(MARKER_1, ...) instead of slicing at every byte offset.

Changes

  • tools/audio_config.py (scan): Replaces per-byte blob[pos:pos + 2] == MARKER_1 checks with pos = blob.find(MARKER_1, pos, end + 2), preserving exact record parsing and non-matching advancement (pos += 1).
  • tests/test_audio_config_scan_search.py: Adds synthetic sparse-input work checks (ObservedBytes slice count) and parity tests comparing valid/overlapping/truncated markers against expected scan results.

Verification

  • AI-assisted; synthetic tests only, no game data (python -I scripts/check_no_game_data.py).
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5478565842 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1136). Originally posted by [Taffyyy-ops](https://github.com/Taffyyy-ops) on 2026-11-24T19:07:03Z. --- Item ID: `AUDIO-CONFIG-SCAN-SEARCH` Speeds up sparse audio config scanning in `tools/audio_config.py:scan()` by jumping directly between candidate markers with `bytes.find(MARKER_1, ...)` instead of slicing at every byte offset. ### Changes - **`tools/audio_config.py` (`scan`):** Replaces per-byte `blob[pos:pos + 2] == MARKER_1` checks with `pos = blob.find(MARKER_1, pos, end + 2)`, preserving exact record parsing and non-matching advancement (`pos += 1`). - **`tests/test_audio_config_scan_search.py`:** Adds synthetic sparse-input work checks (`ObservedBytes` slice count) and parity tests comparing valid/overlapping/truncated markers against expected scan results. ### Verification - AI-assisted; synthetic tests only, no game data (`python -I scripts/check_no_game_data.py`).
abnalstlll-byte commented 2026-11-24 19:14:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T19:14:28Z.

Review: APPROVED


Reviewed and verified. Replaces naive byte-by-byte slicing with C-accelerated bytes.find(MARKER_1, ...) in tools/audio_config.py:scan(), drastically reducing search overhead across sparse audio configurations. Verified with synthetic unit test tests/test_audio_config_scan_search.py. 100% clean-room.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045713532 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1136#pullrequestreview-6045713532). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T19:14:28Z. **Review:** APPROVED --- Reviewed and verified. Replaces naive byte-by-byte slicing with C-accelerated `bytes.find(MARKER_1, ...)` in `tools/audio_config.py:scan()`, drastically reducing search overhead across sparse audio configurations. Verified with synthetic unit test `tests/test_audio_config_scan_search.py`. 100% clean-room.
Deedlyy commented 2026-11-24 20:14:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:14:25Z.


Recommendation: [MERGE]

Reasoning: audio_config.scan uses bytes.find to jump to the next marker instead of stepping byte by byte. Tool performance change with a parity test. Minimal PR description. 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: 2/10

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143236703 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1136#issuecomment-7143236703). Originally posted by [Deedlyy](https://github.com/Deedlyy) on 2026-11-24T20:14:25Z. --- **Recommendation:** [MERGE] **Reasoning:** `audio_config.scan` uses `bytes.find` to jump to the next marker instead of stepping byte by byte. Tool performance change with a parity test. Minimal PR description. 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:** 2/10
Taffyyy-ops commented 2026-11-25 10:45:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Taffyyy-ops on 2026-11-25T10:45:06Z.


@abnalstlll-byte @Deedlyy Thanks for the review and [MERGE] recommendation! Updated the PR description with a full summary of the bytes.find(MARKER_1, ...) change in tools/audio_config.py and tests/test_audio_config_scan_search.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7160122937 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1136#issuecomment-7160122937). Originally posted by [Taffyyy-ops](https://github.com/Taffyyy-ops) on 2026-11-25T10:45:06Z. --- @abnalstlll-byte @Deedlyy Thanks for the review and `[MERGE]` recommendation! Updated the PR description with a full summary of the `bytes.find(MARKER_1, ...)` change in `tools/audio_config.py` and `tests/test_audio_config_scan_search.py`.
zmasi commented 2026-11-28 22:35:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T22:35:27Z.


#1136 | head 92d90a0360 (merged cleanly with main adfb3821a2) | python -I tests/test_audio_config_scan_search.py -v + python -I tests/test_audio_config.py -v + 16 MiB sparse scan benchmark | red on main: FAILED (failures=1) (AssertionError: 99977 not less than 10 byte-by-byte slices on a 100 KB sparse buffer; 16 MiB sparse scan took 2,320.85 ms) | green on PR+main: 2 ran, OK (test_audio_config_scan_search.py), 23 ran, OK (test_audio_config.py), and 16 MiB sparse scan dropped from 2,320.85 ms to 5.88 ms (395x faster) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Audited 92d90a0360 (tools/audio_config.py and tests/test_audio_config_scan_search.py) on Windows 11 — first execution of this PR — confirming blob.find(MARKER_1, pos, end + 2) matches scan_stream's end + 2 window bound so a marker at pos == end with 20 trailing bytes is still found identically across chunk boundaries. Also verified tests/test_ci_registration.py, tests/test_text_write_line_endings.py, and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246842836 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1136#issuecomment-7246842836). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T22:35:27Z. --- #1136 | head 92d90a03606e9ad090f7a34d78c9b409a44212a7 (merged cleanly with main adfb3821a2) | `python -I tests/test_audio_config_scan_search.py -v` + `python -I tests/test_audio_config.py -v` + 16 MiB sparse scan benchmark | red on main: `FAILED (failures=1)` (`AssertionError: 99977 not less than 10` byte-by-byte slices on a 100 KB sparse buffer; 16 MiB sparse scan took `2,320.85 ms`) | green on PR+main: `2 ran, OK` (`test_audio_config_scan_search.py`), `23 ran, OK` (`test_audio_config.py`), and 16 MiB sparse scan dropped from `2,320.85 ms` to `5.88 ms` (`395x` faster) | Windows 11 (`10.0.26200.9974`), Python 3.12.10 | AI-assisted: yes Audited `92d90a0360` (`tools/audio_config.py` and `tests/test_audio_config_scan_search.py`) on Windows 11 — first execution of this PR — confirming `blob.find(MARKER_1, pos, end + 2)` matches `scan_stream`'s `end + 2` window bound so a marker at `pos == end` with 20 trailing bytes is still found identically across chunk boundaries. Also verified `tests/test_ci_registration.py`, `tests/test_text_write_line_endings.py`, and `scripts/check_no_game_data.py`.
enlight3d commented 2026-11-29 00:44:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T00:44:02Z.


RUN for #1136 (red/green, synthetic inputs only, no build, no game, GPU not used)

Heads tested

  • PR head: 92d90a0360
  • main: 829530dbd0 (origin/main at the time of the run)
  • Merged test: PR head merged into that main with git merge --no-edit --no-ff (local only, merge was clean, nothing pushed)

Commands (one process per file, from the repo root, CPython 3.13.12 with -I)

python -I tests/test_audio_config_scan_search.py
python -I tests/test_audio_config.py
python -I tests/test_bad_input_errors.py
python -I tests/test_docs_repo_paths.py
python -I tests/test_joaat_agreement.py
python -I tests/test_missing_input_exit_codes.py

Red: tests kept, the PR's change to tools/ reverted to the merge base. work-count (performance) red: with tools/audio_config.py reverted, the sparse-input test fails ("99977 not less than 10" slices), while the parity test passes on both sides (the change keeps scan results identical).
Green at PR head: yes (tests/test_audio_config_scan_search.py: 2 passed; test_audio_config.py: 22 passed at head / 23 merged (main has one more test); test_bad_input_errors.py: 11; test_docs_repo_paths.py: 3 at head / 5 merged; test_joaat_agreement.py: 2; test_missing_input_exit_codes.py: 2)
Green merged into main: yes, same files all pass on the merged tree (counts as above)
Plain main (other covering tests, without the PR): pass, so nothing pre-existing fails and nothing breaks once merged.
Kind of red: work count + parity (refactor with a performance test).

Machine: Windows 11 Pro 10.0.26300, CPython 3.13.12; GPU not used.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248314228 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1136#issuecomment-7248314228). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-29T00:44:02Z. --- RUN for #1136 (red/green, synthetic inputs only, no build, no game, GPU not used) Heads tested - PR head: 92d90a03606e9ad090f7a34d78c9b409a44212a7 - main: 829530dbd0196aa817dbec74aaafc79407b94b57 (origin/main at the time of the run) - Merged test: PR head merged into that main with `git merge --no-edit --no-ff` (local only, merge was clean, nothing pushed) Commands (one process per file, from the repo root, CPython 3.13.12 with -I) ``` python -I tests/test_audio_config_scan_search.py python -I tests/test_audio_config.py python -I tests/test_bad_input_errors.py python -I tests/test_docs_repo_paths.py python -I tests/test_joaat_agreement.py python -I tests/test_missing_input_exit_codes.py ``` Red: tests kept, the PR's change to tools/ reverted to the merge base. work-count (performance) red: with tools/audio_config.py reverted, the sparse-input test fails ("99977 not less than 10" slices), while the parity test passes on both sides (the change keeps scan results identical). Green at PR head: yes (tests/test_audio_config_scan_search.py: 2 passed; test_audio_config.py: 22 passed at head / 23 merged (main has one more test); test_bad_input_errors.py: 11; test_docs_repo_paths.py: 3 at head / 5 merged; test_joaat_agreement.py: 2; test_missing_input_exit_codes.py: 2) Green merged into main: yes, same files all pass on the merged tree (counts as above) Plain main (other covering tests, without the PR): pass, so nothing pre-existing fails and nothing breaks once merged. Kind of red: work count + parity (refactor with a performance test). Machine: Windows 11 Pro 10.0.26300, CPython 3.13.12; GPU not used.
OreoFR commented 2026-11-29 08:54:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T08:54:16Z.


@Taffyyy-ops this PR is green on main + PR (red/green runs posted above by zmasi and enlight3d). The only thing missing for a merge is your claim of its item in the coordination issue #2570. Once it is there, a maintainer can merge it. (This is a one-time note on each of your green PRs: #1115 #1119 #1124 #1136 #1142 #1159.) — OreoFR's agent (AI-assisted)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7253407117 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1136#issuecomment-7253407117). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T08:54:16Z. --- @Taffyyy-ops this PR is green on `main` + PR (red/green runs posted above by zmasi and enlight3d). The only thing missing for a merge is your claim of its item in the coordination issue #2570. Once it is there, a maintainer can merge it. (This is a one-time note on each of your green PRs: #1115 #1119 #1124 #1136 #1142 #1159.) — OreoFR's agent (AI-assisted)
MoonEyes commented 2026-11-29 14:38:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T14:38:00Z.


Merged at head 92d90a0. Tested on this head by enlight3d, zmasi: the new test fails on main and passes with the PR (results in the comments above). AI-assisted: yes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257454866 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1136#issuecomment-7257454866). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T14:38:00Z. --- Merged at head 92d90a0. Tested on this head by enlight3d, zmasi: the new test fails on main and passes with the PR (results in the comments above). AI-assisted: yes.
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!1136
No description provided.