perf(tools): fetch pr_overlap pull request pages in parallel and cache base exports #10995

Merged
MarcZX10 merged 19 commits from upstream-pr/10995 into main 2026-10-27 23:57:24 +00:00
MarcZX10 commented 2026-10-25 13:07:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T13:07:36Z.


What

Two of the slow steps of tools/pr_overlap.py, which AGENTS.md asks to run with --branch before opening a pull request, are made faster without changing the report.

Listing the open pull requests. gh api --paginate walks the 14 pages of open pull requests one after another, which took 18.2 s here. The first page is now requested with --include, the page count is read from its Link: ...; rel="last" header, and the remaining pages are fetched at once (8 at a time). The same 1,311 pull requests came back in 4.9 s. Pull requests opened during the fetch push the oldest ones past the last page, which --paginate would have followed, so a full last page is followed by the next page until a short one comes back. A pull request moved onto two pages is kept once, since pull requests are stored by number. A response without headers (no Link) is read as a single page, as before.

Reading the exports of the base. base_exports parses every non-test .cpp under core/libs of the base (836 files) on every run, which took 14 to 19 s here, nearly all of it in the export regexes rather than in git archive. The result is now cached by source blob and library in pr_overlap-exports.json inside the git directory, listing the base with git ls-tree and reading only the uncached blobs through one git cat-file --batch. The cache is versioned by a hash of pr_overlap.py and nid_names.py, so a change to either parser rebuilds it; an unreadable cache is rebuilt and a cache that cannot be written is skipped. Entries of other bases are kept, up to four times the current number of files, so switching branches stays cheap.

Measured on the base of this branch:

Run Before After
Same base again 14.2 s 0.2 s
Base 6 hours older (102 .cpp changed) 14.2 s 5.3 s
Base a day or more older, or no cache 14.2 s 11 to 14 s
Back to a base already seen 14.2 s 0.2 s

The gain on a cold cache is small because main changes hundreds of .cpp files a day; the cache pays off when pr_overlap is run repeatedly on the same or a recent base, which is the usual loop while preparing a pull request. The output is identical: all 12,924 export keys and names matched the previous base_exports on the same base. The --help text names the cache file.

This builds on #10988, which builds on #9539, so it depends on #10988. The tooling performance-report exception is proposed in #11064, so this PR depends on that rule change landing first. The first four commits are #9539's, by DavidSamir, and the next five are #10988's, applied unchanged on current main with their authorship kept; the seven commits after them are this pull request's (each change followed by its test and the test registration, then the help text). Once those are merged, rebasing drops their commits from this branch.

Tested

Linux x86-64, Python 3.11: every tools/tests/test_pr_overlap*.py suite and test_nid_names.py pass, including the new test_pr_overlap_pages.py (every page named by rel="last" fetched, a single page with one request, a full last page followed by the next one, a full last page followed by an empty one, a pull request on two pages kept once, headers with plain newlines, a non-array page rejected) and test_pr_overlap_export_cache.py against a temporary repository (tests and headers skipped, nothing parsed on a second run, only the changed source parsed after the base moves, an older base reused, a cache from other parsers ignored, an unreadable cache rebuilt, an unwritable cache not failing the run). The new tests fail before the corresponding commits. A real python3 tools/pr_overlap.py --branch marc/pr-overlap-parallel-pages run printed the usual report; it lists only pull requests that also touch CMakeLists.txt or tools/pr_overlap.py, besides #9539 and #10988, which this branch contains. python3 tools/check_conventions.py --base upstream/main and git diff --check upstream/main pass. Windows and macOS were not run.

Checklist

  • Based on current main; no other open PR implements the same functions
  • 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 (not applicable; no third-party code added)
  • Generic behaviour, not specific to one title
  • Depends on: #10988, #11064 (merge order only for the tooling performance-report rule)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5005000786 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10995). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T13:07:36Z. --- ### What Two of the slow steps of `tools/pr_overlap.py`, which AGENTS.md asks to run with `--branch` before opening a pull request, are made faster without changing the report. **Listing the open pull requests.** `gh api --paginate` walks the 14 pages of open pull requests one after another, which took 18.2 s here. The first page is now requested with `--include`, the page count is read from its `Link: ...; rel="last"` header, and the remaining pages are fetched at once (8 at a time). The same 1,311 pull requests came back in 4.9 s. Pull requests opened during the fetch push the oldest ones past the last page, which `--paginate` would have followed, so a full last page is followed by the next page until a short one comes back. A pull request moved onto two pages is kept once, since pull requests are stored by number. A response without headers (no `Link`) is read as a single page, as before. **Reading the exports of the base.** `base_exports` parses every non-test `.cpp` under `core/libs` of the base (836 files) on every run, which took 14 to 19 s here, nearly all of it in the export regexes rather than in `git archive`. The result is now cached by source blob and library in `pr_overlap-exports.json` inside the git directory, listing the base with `git ls-tree` and reading only the uncached blobs through one `git cat-file --batch`. The cache is versioned by a hash of `pr_overlap.py` and `nid_names.py`, so a change to either parser rebuilds it; an unreadable cache is rebuilt and a cache that cannot be written is skipped. Entries of other bases are kept, up to four times the current number of files, so switching branches stays cheap. Measured on the base of this branch: | Run | Before | After | |---|---|---| | Same base again | 14.2 s | 0.2 s | | Base 6 hours older (102 `.cpp` changed) | 14.2 s | 5.3 s | | Base a day or more older, or no cache | 14.2 s | 11 to 14 s | | Back to a base already seen | 14.2 s | 0.2 s | The gain on a cold cache is small because `main` changes hundreds of `.cpp` files a day; the cache pays off when `pr_overlap` is run repeatedly on the same or a recent base, which is the usual loop while preparing a pull request. The output is identical: all 12,924 export keys and names matched the previous `base_exports` on the same base. The `--help` text names the cache file. This builds on #10988, which builds on #9539, so it depends on #10988. The tooling performance-report exception is proposed in #11064, so this PR depends on that rule change landing first. The first four commits are #9539's, by DavidSamir, and the next five are #10988's, applied unchanged on current `main` with their authorship kept; the seven commits after them are this pull request's (each change followed by its test and the test registration, then the help text). Once those are merged, rebasing drops their commits from this branch. ### Tested Linux x86-64, Python 3.11: every `tools/tests/test_pr_overlap*.py` suite and `test_nid_names.py` pass, including the new `test_pr_overlap_pages.py` (every page named by `rel="last"` fetched, a single page with one request, a full last page followed by the next one, a full last page followed by an empty one, a pull request on two pages kept once, headers with plain newlines, a non-array page rejected) and `test_pr_overlap_export_cache.py` against a temporary repository (tests and headers skipped, nothing parsed on a second run, only the changed source parsed after the base moves, an older base reused, a cache from other parsers ignored, an unreadable cache rebuilt, an unwritable cache not failing the run). The new tests fail before the corresponding commits. A real `python3 tools/pr_overlap.py --branch marc/pr-overlap-parallel-pages` run printed the usual report; it lists only pull requests that also touch `CMakeLists.txt` or `tools/pr_overlap.py`, besides #9539 and #10988, which this branch contains. `python3 tools/check_conventions.py --base upstream/main` and `git diff --check upstream/main` pass. Windows and macOS were not run. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [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 (not applicable; no third-party code added) - [x] Generic behaviour, not specific to one title - [x] Depends on: #10988, #11064 (merge order only for the tooling performance-report rule) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
THEMANnt commented 2026-10-26 18:50:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-26T18:50:25Z.

Review: DISMISSED


Reviewed 2ca76b589c2ab9e9ff62e371e19ab981ab1c924d. Changes requested for a reproduced conflict-detection regression.

[P2] tools/pr_overlap.py, probe / related: retain candidates affected by base-branch renames. Start with old.txt, rename it to renamed.txt on main, and edit its first line in the reviewed branch. An older PR changes that same line under old.txt. Its clean merge onto main relocates the edit, and a full scan correctly detects the line-1 conflict on renamed.txt.

The new three-dot probe sees only old.txt, discards the candidate and reports no overlap. I reproduced this with real Git histories on the exact head; the comparison base retains the conflict. A raw merge-base path list is not a conservative substitute for the merged-tree paths.

Please account for base-branch renames or retain uncertain candidates, and add this older-base case to the optimized-versus-full equivalence tests.

Validation: Windows/Python 3.11. The five changed overlap suites run 45 tests with 5 platform skips and no failures. The separate rename reproduction is the decisive failing behavior; no timing or full-repository performance claim.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5657342978 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10995#pullrequestreview-5657342978). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-26T18:50:25Z. **Review:** DISMISSED --- Reviewed `2ca76b589c2ab9e9ff62e371e19ab981ab1c924d`. Changes requested for a reproduced conflict-detection regression. **[P2] `tools/pr_overlap.py`, `probe` / `related`: retain candidates affected by base-branch renames.** Start with `old.txt`, rename it to `renamed.txt` on main, and edit its first line in the reviewed branch. An older PR changes that same line under `old.txt`. Its clean merge onto main relocates the edit, and a full scan correctly detects the line-1 conflict on `renamed.txt`. The new three-dot probe sees only `old.txt`, discards the candidate and reports no overlap. I reproduced this with real Git histories on the exact head; the comparison base retains the conflict. A raw merge-base path list is not a conservative substitute for the merged-tree paths. Please account for base-branch renames or retain uncertain candidates, and add this older-base case to the optimized-versus-full equivalence tests. **Validation:** Windows/Python 3.11. The five changed overlap suites run 45 tests with 5 platform skips and no failures. The separate rename reproduction is the decisive failing behavior; no timing or full-repository performance claim.
THEMANnt commented 2026-10-27 03:25:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-27T03:25:17Z.

Review: APPROVED


Reviewed 2229b41d832b2f219ba41ea4aeca190a2032f36f. Approve: the updated prefilter retains candidates whose existing paths disappeared from the base, addressing the previously reproduced rename omission. The pagination and blob-keyed export cache retain their focused coverage, including corrupt JSON and failed cache writes.

On Windows, Python 3.11.9, the overlap suites ran 101 tests: 96 passed and 5 platform cases skipped. An independent real-Git rename control now finds the same conflict as the full scan; the prior head omitted it. The prior baseline control also showed expected differences in cache parsing and pagination interfaces; missing new APIs in that control are not behavioral regressions.

Hosted Windows, Linux and both macOS relinker jobs ran the four registered overlap tests on merges containing this head. Product jobs were skipped; ASan ran its targeted TLS coverage. No full-product validation or independent performance measurement is claimed. Preserve the prefilter correction when integrating the #9539 and #10988 dependencies.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5661869331 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10995#pullrequestreview-5661869331). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-10-27T03:25:17Z. **Review:** APPROVED --- Reviewed `2229b41d832b2f219ba41ea4aeca190a2032f36f`. Approve: the updated prefilter retains candidates whose existing paths disappeared from the base, addressing the previously reproduced rename omission. The pagination and blob-keyed export cache retain their focused coverage, including corrupt JSON and failed cache writes. On Windows, Python 3.11.9, the overlap suites ran 101 tests: 96 passed and 5 platform cases skipped. An independent real-Git rename control now finds the same conflict as the full scan; the prior head omitted it. The prior baseline control also showed expected differences in cache parsing and pagination interfaces; missing new APIs in that control are not behavioral regressions. Hosted Windows, Linux and both macOS relinker jobs ran the four registered overlap tests on merges containing this head. Product jobs were skipped; ASan ran its targeted TLS coverage. No full-product validation or independent performance measurement is claimed. Preserve the prefilter correction when integrating the #9539 and #10988 dependencies.
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!10995
No description provided.