perf(tools): fetch pr_overlap pull request pages in parallel and cache base exports #10995
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10995"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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--branchbefore opening a pull request, are made faster without changing the report.Listing the open pull requests.
gh api --paginatewalks 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 itsLink: ...; 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--paginatewould 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 (noLink) is read as a single page, as before.Reading the exports of the base.
base_exportsparses every non-test.cppundercore/libsof the base (836 files) on every run, which took 14 to 19 s here, nearly all of it in the export regexes rather than ingit archive. The result is now cached by source blob and library inpr_overlap-exports.jsoninside the git directory, listing the base withgit ls-treeand reading only the uncached blobs through onegit cat-file --batch. The cache is versioned by a hash ofpr_overlap.pyandnid_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:
.cppchanged)The gain on a cold cache is small because
mainchanges hundreds of.cppfiles a day; the cache pays off whenpr_overlapis 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 previousbase_exportson the same base. The--helptext 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
mainwith 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*.pysuite andtest_nid_names.pypass, including the newtest_pr_overlap_pages.py(every page named byrel="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) andtest_pr_overlap_export_cache.pyagainst 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 realpython3 tools/pr_overlap.py --branch marc/pr-overlap-parallel-pagesrun printed the usual report; it lists only pull requests that also touchCMakeLists.txtortools/pr_overlap.py, besides #9539 and #10988, which this branch contains.python3 tools/check_conventions.py --base upstream/mainandgit diff --check upstream/mainpass. Windows and macOS were not run.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)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 withold.txt, rename it torenamed.txton main, and edit its first line in the reviewed branch. An older PR changes that same line underold.txt. Its clean merge onto main relocates the edit, and a full scan correctly detects the line-1 conflict onrenamed.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.
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.