perf(tools): collapse blank-line runs before matching stub wrappers in the progress scan #14321

Merged
MarcZX10 merged 2 commits from upstream-pr/14321 into main 2026-11-02 19:48:17 +00:00
MarcZX10 commented 2026-11-01 09:11:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T09:11:42Z.


What

tools/progress.py code() blanks comments to whitespace. A file with many comment-only lines therefore becomes a long run of blank lines. STUB_WRAPPER allows whitespace inside its return-type class, so the regex re-scanned that run from every line start. On the full tree, the two STUB_WRAPPER passes account for most of the scan time.

code() now collapses blank-line runs after the blanking. No line number is computed from the blanked text, so the matched names do not change. The output is byte-identical to the previous code (see Tested).

Commits:

  • 10e5486a27: the collapse in code().
  • 8710666a62: two tests in tools/tests/test_progress_wrappers.py.

Tested

Linux, Python 3.11.2, on upstream/main 5c9837bfe7 plus these commits.

  • python3 tools/tests/test_progress_wrappers.py: 13 tests, OK.
  • test_progress.py: 57 tests, OK. test_progress_encoding.py: 6, OK. test_progress_render_sliver.py: 2, OK. test_progress_read_encoding.py: 3, OK. test_progress_report_inputs.py: 2, OK.
  • Negative control: WrapperTests.test_comment_only_lines_leave_no_blank_line_runs run against upstream/main's tools/progress.py fails, because the blanked text still contains a blank-line run. WrapperTests.test_multi_line_return_type_helper_is_pending passes on both, and guards the STUB_WRAPPER class against a naive removal of newlines.
  • Output comparison on the full tree: python3 tools/progress.py <output> with the base tool and with this branch's tool, over the same source checkout. progress.json, progress.html and progress.svg are byte-identical. Wall time on this host, one run each: base 41.5 s, this branch 20.1 s. Other jobs were running on the host during both runs, so treat the times as indicative.
  • python3 tools/check_conventions.py --base upstream/main and git diff --check upstream/main: clean.
  • Test-quality helper, run by hand on tools/tests/test_progress_wrappers.py: 9 findings, all test-without-assertion. They are on tests that assert through the file's existing assertTodo helper, which the heuristic cannot see, as the existing tests already do. The new comment test uses a plain assertEqual.

Not run: the Pages and progress-report workflows on GitHub.

Checklist

  • Based on current main
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5105996219 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14321). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-01T09:11:42Z. --- ### What `tools/progress.py` `code()` blanks comments to whitespace. A file with many comment-only lines therefore becomes a long run of blank lines. `STUB_WRAPPER` allows whitespace inside its return-type class, so the regex re-scanned that run from every line start. On the full tree, the two `STUB_WRAPPER` passes account for most of the scan time. `code()` now collapses blank-line runs after the blanking. No line number is computed from the blanked text, so the matched names do not change. The output is byte-identical to the previous code (see Tested). Commits: - `10e5486a27`: the collapse in `code()`. - `8710666a62`: two tests in `tools/tests/test_progress_wrappers.py`. ### Tested Linux, Python 3.11.2, on `upstream/main` `5c9837bfe7` plus these commits. - `python3 tools/tests/test_progress_wrappers.py`: 13 tests, OK. - `test_progress.py`: 57 tests, OK. `test_progress_encoding.py`: 6, OK. `test_progress_render_sliver.py`: 2, OK. `test_progress_read_encoding.py`: 3, OK. `test_progress_report_inputs.py`: 2, OK. - Negative control: `WrapperTests.test_comment_only_lines_leave_no_blank_line_runs` run against `upstream/main`'s `tools/progress.py` fails, because the blanked text still contains a blank-line run. `WrapperTests.test_multi_line_return_type_helper_is_pending` passes on both, and guards the `STUB_WRAPPER` class against a naive removal of newlines. - Output comparison on the full tree: `python3 tools/progress.py <output>` with the base tool and with this branch's tool, over the same source checkout. `progress.json`, `progress.html` and `progress.svg` are byte-identical. Wall time on this host, one run each: base 41.5 s, this branch 20.1 s. Other jobs were running on the host during both runs, so treat the times as indicative. - `python3 tools/check_conventions.py --base upstream/main` and `git diff --check upstream/main`: clean. - Test-quality helper, run by hand on `tools/tests/test_progress_wrappers.py`: 9 findings, all `test-without-assertion`. They are on tests that assert through the file's existing `assertTodo` helper, which the heuristic cannot see, as the existing tests already do. The new comment test uses a plain `assertEqual`. Not run: the Pages and progress-report workflows on GitHub. ### Checklist - [x] Based on current `main` - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-02 06:22:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T06:22:29Z.

Review: COMMENTED


Reviewed — no blocking findings

progress.code() now collapses runs of blank lines after the comment and string blanking, so the stub-wrapper scan works on fewer characters. The result is only whitespace, and the scan's output is names and percentages, not line numbers. The hosted ubuntu CTest run passed progress_wrappers, which runs the new tests.

What I ran

  • Head 8710666a629e51e8dde7572ec825acdc649097b6; base 26fa1212b82f76dd49cf12d65e445d6ff3e0844c. 2 files: tools/progress.py (one line changed in code()) and tools/tests/test_progress_wrappers.py (+11: two new tests and an import re).
  • Read both diffs in full. Checked where code() is used: scan_library (line 167) reads the result for pattern matching. The result is used for matching and counting, not for line numbers. re is imported (line 5).
  • Hosted: the ubuntu relinker job's CTest run for this head (549 of 549 passed) ran progress_wrappers (Test #29, passed, 0.13 s).
  • Read-only checks from the trusted main checkout: diff check, conventions and PR template, and the stack check all passed. The ABI audit is not applicable. The Python tests were not run here, because the PR changes .py files.
  • No MarcZX10 review at this head.

Results

Check Result Note
Diff check passed
Conventions and PR template passed conventions check from the main checkout
Mergeability and dependencies passed stack check passed; no declared dependencies
code() output is used for matching, not line numbers passed by reading scan_library, line 167
re is imported passed by reading line 5
Collapsing blank runs does not change matching passed by reading statements and inert_body strip each part and skip empty ones; the STUB_WRAPPER header regex was not read
progress_wrappers (hosted, ubuntu CTest) passed Test #29, 0.13 s
The performance gain in the title not verified not measured here
ABI audit not applicable no export changed
Build and runtime tests (Linux) run hosted see above
Negative controls not run no local build
Hosted CI passed conventions, eligibility, labels, relinkers, relinker-asan and report succeeded; windows and linux skipped
Read-only check output

Precheck was not run: no PR-head code is run here, and the PR changes .py files. Diff check: passed. Conventions: passed. ABI audit: not applicable. Stack check: passed. Hosted: gh api repos/boykopovar/AnyPS5/commits/8710666a629e51e8dde7572ec825acdc649097b6/check-runs, and the ubuntu relinker job log.

Negative control

Not run here. A negative control needs a local run of the Python tests, and the PR's Python code is not run here.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

  • The performance gain stated in the title.
  • The STUB_WRAPPER header regex, against blank lines between a function's return type and its name.

To get this to a good state

  • Nothing to change.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5732771699 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14321#pullrequestreview-5732771699). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T06:22:29Z. **Review:** COMMENTED --- # Reviewed — no blocking findings `progress.code()` now collapses runs of blank lines after the comment and string blanking, so the stub-wrapper scan works on fewer characters. The result is only whitespace, and the scan's output is names and percentages, not line numbers. The hosted ubuntu CTest run passed `progress_wrappers`, which runs the new tests. ## What I ran - Head `8710666a629e51e8dde7572ec825acdc649097b6`; base `26fa1212b82f76dd49cf12d65e445d6ff3e0844c`. 2 files: `tools/progress.py` (one line changed in `code()`) and `tools/tests/test_progress_wrappers.py` (+11: two new tests and an `import re`). - Read both diffs in full. Checked where `code()` is used: `scan_library` (line 167) reads the result for pattern matching. The result is used for matching and counting, not for line numbers. `re` is imported (line 5). - Hosted: the ubuntu relinker job's CTest run for this head (549 of 549 passed) ran `progress_wrappers` (`Test #29`, passed, 0.13 s). - Read-only checks from the trusted main checkout: diff check, conventions and PR template, and the stack check all passed. The ABI audit is not applicable. The Python tests were not run here, because the PR changes `.py` files. - No MarcZX10 review at this head. ## Results | Check | Result | Note | | --- | --- | --- | | Diff check | passed | | | Conventions and PR template | passed | conventions check from the main checkout | | Mergeability and dependencies | passed | stack check passed; no declared dependencies | | `code()` output is used for matching, not line numbers | passed by reading | `scan_library`, line 167 | | `re` is imported | passed by reading | line 5 | | Collapsing blank runs does not change matching | passed by reading | `statements` and `inert_body` strip each part and skip empty ones; the `STUB_WRAPPER` header regex was not read | | `progress_wrappers` (hosted, ubuntu CTest) | passed | `Test #29`, 0.13 s | | The performance gain in the title | not verified | not measured here | | ABI audit | not applicable | no export changed | | Build and runtime tests (Linux) | run hosted | see above | | Negative controls | not run | no local build | | Hosted CI | passed | conventions, eligibility, labels, relinkers, relinker-asan and report succeeded; windows and linux skipped | <details><summary>Read-only check output</summary> Precheck was not run: no PR-head code is run here, and the PR changes `.py` files. Diff check: passed. Conventions: passed. ABI audit: not applicable. Stack check: passed. Hosted: `gh api repos/boykopovar/AnyPS5/commits/8710666a629e51e8dde7572ec825acdc649097b6/check-runs`, and the ubuntu relinker job log. </details> ## Negative control Not run here. A negative control needs a local run of the Python tests, and the PR's Python code is not run here. ## Findings **Blocking** None. **Non-blocking** None. ## Sources - Production: https://github.com/boykopovar/AnyPS5/blob/8710666a629e51e8dde7572ec825acdc649097b6/tools/progress.py - Test: https://github.com/boykopovar/AnyPS5/blob/8710666a629e51e8dde7572ec825acdc649097b6/tools/tests/test_progress_wrappers.py - Registration: https://github.com/boykopovar/AnyPS5/blob/8710666a629e51e8dde7572ec825acdc649097b6/CMakeLists.txt (lines 238-239) - Hosted log: ubuntu relinker job for 8710666a66 (CTest 549 of 549) ## Not verified - The performance gain stated in the title. - The `STUB_WRAPPER` header regex, against blank lines between a function's return type and its name. ## To get this to a good state - Nothing to change.
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
boykopovar/AnyPS5!14321
No description provided.