Skip to content

perf(gitwork): find the nearest patch baseline without probing every remote ref - #975

Open
CJX-xw wants to merge 1 commit into
Tencent:mainfrom
CJX-xw:perf/patch-baseline-remote-refs
Open

CJX-xw wants to merge 1 commit into
Tencent:mainfrom
CJX-xw:perf/patch-baseline-remote-refs

Conversation

@CJX-xw

@CJX-xw CJX-xw commented Nov 16, 2026

Copy link
Copy Markdown

What changed

At the end of each SOP node, patch inventory collection probed every origin remote-tracking ref with separate merge-base and rev-list processes. On a repository with thousands of remote branches, this kept the runner busy for minutes after every node, so it did not pick up the next task.

nearestPatchBaseline now lists recorded..HEAD once and counts only refs whose tips are in that range. If the recorded baseline is invalid, it uses one merged-ref query instead of probing ancestry ref by ref. Ref ordering, filtering, and strict count comparison are unchanged.

Scope

  • Platform core / API / runner
  • Public adapter / deployment
  • Classic
  • Portable
  • Shared behavior contract
  • Installer / CLI
  • Documentation only

Compatibility

The selected baseline is unchanged, including ties, refs at HEAD, origin/HEAD, merged upstream refs, and invalid recorded baselines. There are no schema or runner-protocol changes and no migration is required.

Validation

Relevant checks passed:

  • gofmt -l internal/gitwork — no output.
  • go vet ./....
  • go test ./internal/gitwork/ -run 'Baseline|Patch' -count=1 -v — all seven new scenarios passed and matched the retained scan implementation.
  • python3 scripts/check-public.py.

Performance was measured once per implementation in a temporary repository with 2,000 unrelated remote branches and one published intermediate commit. Both implementations selected that same commit. Process starts, including HEAD resolution, were counted with a Git wrapper, and the temporary measurement code was removed.

Implementation Elapsed Git processes
Previous per-ref scan 47.693653042s 4,007
Range-filtered candidates 342.929583ms 5

Safety

  • I did not include credentials, internal endpoints, production data, or organization-specific infrastructure.
  • I preserved user files and unrelated changes.

…remote ref

nearestPatchBaseline ran merge-base and rev-list once per remote-tracking
ref, so collecting node outputs scaled with the number of origin branches.
On repositories with a few thousand branches this kept the runner busy for
minutes after every node.

Only refs pointing into recorded..HEAD can be closer than the recorded
baseline, so list that range once and count just those candidates. The
selected baseline is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant