fix(tools): merge only the pull requests that share files or exports with the branch in pr_overlap #9539
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9539"
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 DavidSamir on 2026-10-22T00:53:08Z.
What
tools/pr_overlap.py --branchmerged every open pull request againstmainbefore comparing, although a pull request can only appear in that report when it shares a file or an export with the branch. With 1,012 open pull requests a full run took 27 minutes on Windows 11 (jobs=4):scan_allwas 1,377 s of it, andgit merge-treeagainstmainwas 1,012 calls and 4,807 s of subprocess time. On the author's machine the check required by AGENTS.md before opening a pull request did not finish in 25 or 55 minutes.probe(pr)lists a pull request's changed files and, when it touchescore/libs/prx/*.cpp, its exports, fromgit diff refs/pr/base...<head>. That needs no merge and writes no objects.related(prs, executor)scans the branch, probes the other pull requests, and returns those that share a file or an export with it. The rest get empty file, added and export sets and no merged tree, which is what they would contribute to the report.scan_allmerges only whatrelatedreturns when a branch is present (key0).--out, the CI mode that compares every pair, is unchanged.The probe finds a superset of what the merge-based scan finds: a merge only drops changes that
mainalready has, andbase...headuses the same merge base the conflicted case already used.A pull request in the
Depends onchain of another is not scanned for its own sake: in--branchmode the branch has no dependencies, sooverlapsnever reads a shared dependency.Tested
Windows 11, Python 3.12. Open pull requests: 1,021 at the time of the run,
main0c6a5bd593, jobs=4, all four branches in one process so the fetch is shared. Each branch was scanned with this change first and then the old way (every pull request scanned, once for all four branches), and the printed report was compared byte for byte:scan_allcore/libs/CMakeLists.txt, a debt fileExport.cpp,Export.Discovery.cpp,CMakeLists.txt, a debt filedocs/user/USAGE.mdPipeline.cpp, a debt fileScanning every pull request the old way took 717.5 s in the same process. It ran after the four new-way runs, so it had warm caches; the first full run, cold, took 1,377 s for the same step. The slowest case here is the provoking-vertex branch: 129 merges, 308 s.
Unit tests:
tools/tests/test_pr_overlap_branch_scan.py(new, 3 tests) builds a throwaway repository with a branch and four pull requests (same lines, an unrelated file, the same export in another file, an unrelated export). It checks that the overlaps equal a scan of every pull request, that only the first and third are merged, and that a scan without a branch still merges all four. Onmain'spr_overlap.pythe second test fails (all four are merged); with the change all three pass. All 68test_pr_overlap*tests pass with the change.python tools/check_conventions.py --base origin/mainpasses.python tools/pr_overlap.py --branch fix/pr-overlap-branch-prefilter, run with this change on this branch against about 1,020 open pull requests (Windows 11, jobs=4): 3 min 54 s wall from start to printed report, where the unchanged tool did not finish in 25 or 55 minutes on the same machine. Its report:#988 appends eleven lines at the end of
tools/pr_overlap.pyand does not touchscan_all; it conflicts withmainfor other reasons.Merge checks with
git merge-tree: clean againstmain, #8970 and #8025, the other two open pull requests that changetools/pr_overlap.py.Not run on Linux or macOS: the speed-up is measured on Windows only.
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 MarcZX10 on 2026-10-22T01:00:16Z.
Review: CHANGES_REQUESTED
The branch-prefilter tests passed locally when I ran the exact PR script plus all
test_pr_overlap*.pyfiles: 68 tests passed. The optimization also retains the existing all-pairs scan when--outis used, and the new test checks report equality plus that only related PRs are merged.The hosted relinker matrix completed with the same failure on Linux, Windows, macOS arm64 and macOS x86_64:
test_script_registrationreportstools/tests/test_pr_overlap_branch_scan.py is a test script that no add_test or workflow runs. Please register the new script withadd_test(or a workflow as the repository rule allows), then rerun the relinker matrix. The overlap behavior itself passed the focused tests; the required relinker check currently fails on every platform. Eligibility, conventions, intake and labels pass; relinker ASan passes.I’m requesting changes for the missing test registration and CI failure.
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-22T01:32:04Z.
@MarcZX10 thanks for running it. The failure was
test_script_registration:tools/tests/test_pr_overlap_branch_scan.pywas not run by anyadd_test, and I had left it out. It is registered now aspr_overlap_branch_scanin the rootCMakeLists.txt, right afterpr_overlap_errors(61493f1f07), and I merged the currentmaininto the branch (b163c8784c, no force-push).On that head,
ctest -R "pr_overlap|test_script_registration"passes 9 of 9 on Windows 11, includingtest_script_registrationand the newpr_overlap_branch_scan, andtools/check_conventions.py --base origin/mainpasses. Could you take another look and rerun the relinker matrix?Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:44:10Z.
Review: APPROVED
Thanks for registering
test_pr_overlap_branch_scan.pywith CTest. This resolves the blocking finding from my previous review. I verified the current head is based on current main, the template remains complete, and the current hosted eligibility, conventions, labels and all relinker matrix jobs (Ubuntu, Windows, macOS x86_64/arm64 and ASAN) pass, including thetest_script_registrationgate that failed before. Platform product builds are skipped. I did not rerun the focused local test on this head; my earlier local suite run was on the preceding revision.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:17:23Z.
Review: APPROVED
I rechecked the current head after the test registration fix. The new branch-scan test is registered in CTest, the PR is based on current main, conventions and eligibility pass, and hosted relinker jobs pass on Ubuntu, Windows, macOS arm64/x86_64, and ASAN. Product builds are skipped, and I did not rerun the focused tests locally on this head; the prior local test evidence applies to the preceding revision. I found no remaining blocking issue in the reviewed diff.
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-22T04:42:41Z.
Linux data point for
b163c8784c: WSL2 Ubuntu 24.04 (virtualised kernel, not bare-metal), Python 3.12, PR head alone (not merged ontomain; its merge-base is94fbb8cea).tools/tests/test_pr_overlap_branch_scan.pyruns 3 tests and passes.tools/pr_overlap.pyrestored to the merge-base (the PR's test kept):test_only_pull_requests_sharing_a_file_or_an_export_are_mergedfails.Not tested: macOS, Windows.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T07:04:43Z.
Review: COMMENTED
Python 3.9 run of the new test, since macOS ships Python 3.9.6 as
/usr/bin/python3(Xcode command line tools) and the other tool tests run there.Apple M2 Max, macOS 27.2, head
b163c8784c,python3 tools/tests/test_pr_overlap_branch_scan.py:Ran 3 tests ... OKFAILED (errors=3), all three in the fixture helper:Path.write_text(newline=)is 3.10+. The same pattern was replaced before for 3.9 in the other tool tests; something like this keeps the LF output:The
pr_overlap.pychange itself was not exercised beyond these three tests.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-22T09:06:14Z.
@jotitadev thank you, that was a real defect:
Path.write_texttakesnewlineonly from Python 3.10, and the fixture helper of the new test is where all three tests errored on macOS's 3.9.6.4b0c1382b6writes the fixtures withopen(path, "w", encoding="utf-8", newline="\n")andhandle.write(text), which gives the same LF bytes on every version. On Windows with Python 3.12 the three tests pass; I have no 3.9 interpreter here, so I only checked that the file parses as 3.9 syntax, and the macOS run is still the real check.Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-22T09:07:23Z.
Checked on macOS with the system Python the review mentions: macOS 26 (Darwin 25.6),
/usr/bin/python33.9.6, head4b0c1382b6:tools/tests/test_pr_overlap_branch_scan.pyruns 3 tests, OK, andtools/tests/test_pr_overlap.pyruns 22 tests, OK.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:34:51Z.
I reran the complete focused overlap-tool test set on current head
4b0c1382b6: all 69 tests passed, including the branch-prefilter cases;git diff --checkand current conventions pass. The fixture now usesopen(..., newline="\\n"), so it avoids the Python 3.9Path.write_text(newline=...)incompatibility. The merge against currentmainis clean, but the sync check still reports 5 ahead / 116 behind (merge base94fbb8cea). Please refresh the branch onto currentmainbefore merge and rerun the focused suite there.Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-24T23:41:50Z.
Review: CHANGES_REQUESTED
Reviewed 4b0c1382b6e2 against 94fbb8cea80a. Changes requested because the new prefilter can discard a genuinely conflicting PR after a rename on the base branch.
tools/pr_overlap.py:151–155— Account for base-branch renames before discarding a PRIn a disposable real Git history, start with
old.txt, rename it torenamed.txton main, and change its first line in the reviewed branch. A second PR forked before the rename changes the same first line inold.txt. Merging that older PR onto main cleanly relocates its edit torenamed.txt, so the existing full scan detects a line-1 conflict with the reviewed branch. The new probe instead returnsold.txtfrom the old merge-base diff, compares it against the branch'srenamed.txt, and clears the PR's file set. On the exact head, full scan reports the conflict whilescan_allreports no overlap; on baseline,scan_allretains the conflict. This is reproduced with actual Git merges and unchanged production source.Please retain candidates whose paths may be transformed by base-branch renames, or map those paths conservatively before filtering. Add the older-base/renamed-file case to the optimized-versus-full equivalence tests. A raw three-dot diff is not always a superset of merged-tree paths.
Validation: Windows x64 / CPython 3.11: all eight overlap suites — 65 passed, 4 platform skips; 69 total. Baseline: 62 passed, 4 skips; 66 total. New-tests/old-code control has one expected optimization assertion failure and no errors. The separate rename reproduction is decisive. Its initial run encountered a local Windows temporary-directory cleanup error; corrected cleanup reruns exit 0 on both arms and retain the reproduced difference. Conventions, whitespace and registration pass. Hosted relinker matrix/ASan and conventions succeed; product jobs are skipped.
Scope: Local synthetic Git histories; no independent full-open-PR timing benchmark or performance claim.
Pull request closed