Skip to content

perf(gateway): skip redundant same-tip session PR probes - #159301

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-session-pr-git-context-polling-20260919
Sep 27, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-session-pr-git-context-polling-20260919

Conversation

@steipete

@steipete steipete commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The session PR panel repeatedly starts an unnecessary Git ancestry process when a checkout's HEAD already equals the default-branch tip.

User Impact

Removes one Git process per uncached read of that state while preserving branch visibility, uncommitted diff counts, and the missing-object fallback. A 40-worktree plus three-project fixture measured 25% fewer idle Git spawns.

This is a bounded improvement, not the full event-driven checkout cache: idle zero and at-most-two processes after a changed checkout remain unmet. A metadata-only cache would miss unstaged file edits; a complete solution needs working-file invalidation as well.

Why This Change Was Made

Equal object IDs provide the candidate merge base directly. The existing diff read validates the object before equal remote tips suppress Create PR, so another ancestry probe is redundant. Different tips still use Git's merge-base calculation.

Production code grows by five net lines, with no configuration, cache, observer, or broker-capacity changes. The existing branch tests cover the process reduction and a HEAD pointing at a missing object.

Evidence

Real Git fixture: 40 linked worktrees and three independent project checkouts, all initially at the default-branch commit, exercised through the session PR loader and Git worker. Ten 60-second polling steps used a virtual clock; counts exclude fixture construction.

Measurement Before After
Warm admission, 43 checkouts 172 processes 129 processes
Idle processes/minute, mean over ten polling minutes 86 64.5
Forced refresh after one tracked-file edit 4 processes 3 processes

Blacksmith Testbox, profile openclaw-check:

  • tbx_01m3g3zvpb9adxqtcnmbmymq9q: baseline and candidate fixture runs produced the counts above. The fixture correctly failed its original zero-idle target on both versions; it was temporary measurement tooling and is not added to per-PR CI. Candidate branch and landing suites passed all 61 tests.
  • tbx_01m3g4xy2ra2hgse5jw21ygefs: node scripts/check-changed.mjs --base HEAD passed, including formatting, core and test typechecks, lint, and guards (21m40s remote command).
  • On the replacement lease, the extended equal-tip regression rejected the original production code (expected exit 1). Restoring the candidate and running pnpm test src/gateway/control-ui-session-prs-branch.test.ts --maxWorkers=1 passed all 49 tests: 40.37s wall including worker compilation, about 21s test execution. The added missing-HEAD case costs roughly 0.5s; existing Git-worker/session fixtures own these real-process contracts. GitHub CI run 36285487289 passed on 239ec7ebb7c6 in 829s end to end, including scheduling and builds. Separate per-file CI seconds were not available in the run artifacts.
  • Isolated Codex autoreview: no actionable P0–P2 findings. git diff --check passed.

The first lease lacked dependencies; frozen-lockfile installation succeeded. Its later checksum sync timed out twice, so it was stopped and replaced. The fresh lease's default check compared against newer origin/main and tripped an unrelated UI line-growth ratchet; using the actual unchanged task HEAD as the diff base selected only these three files and passed. No live Gateway was modified or used for validation.

@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Sep 27, 2026
@steipete
steipete marked this pull request as ready for review September 27, 2026 01:25
@steipete
steipete enabled auto-merge (squash) September 27, 2026 01:29
@clawsweeper

clawsweeper Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 9:32 PM ET / September 27, 2026, 01:32 UTC.

ClawSweeper review

What this changes

The Gateway session pull-request reader skips an ancestry process when the checkout and default branch have matching tips, with tests for branch visibility and missing objects.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still performs the redundant equal-tip ancestry probe, and this focused improvement has no identified correctness or security regression.

Priority: P2
Reviewed head: 239ec7ebb7c6ca297e10bc796e0ff62693d57927

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused patch with real-Git before-and-after measurements and a pre-fix failing regression provides good review confidence.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The changed Gateway branch-facts path was exercised through the session PR loader and Git worker over real Git checkouts; the reported after-fix measurements show fewer processes at warm admission, during idle polling, and after an edit. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The changed Gateway branch-facts path was exercised through the session PR loader and Git worker over real Git checkouts; the reported after-fix measurements show fewer processes at warm admission, during idle polling, and after an edit. No stored-data contract changes.
Evidence reviewed 8 items Introduced optimization: The branch resolves matching default and checkout tips directly; different tips retain the Git merge-base call.
Fallback and output path: The existing working-tree diff must succeed before equal remote tips suppress Create PR; failed diffs retain the unknown-comparison path.
Current main remains different: The fetched main revision still calls merge-base whenever both tip IDs exist, including when they match.
Findings None None.
Security None None.

How this fits together

The Gateway combines a session’s checkout state with GitHub pull-request data. Its Git worker reads branch tips and working-tree changes, then sends branch status and a possible Create PR link to the Control UI.

flowchart LR
A[Session checkout] --> B[Gateway PR loader]
C[GitHub PR data] --> B
B --> D[Git worker reads tips]
D --> E{Tips match?}
E -->|Yes| F[Read working-tree diff]
E -->|No| G[Check ancestry]
G --> F
F --> H[Control UI branch row]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +5, Tests +6. Total +11 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 9 4 +5
Tests 1 9 3 +6
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 18 7 +11

Review metrics

Metric Value Why it matters
Reported Git process reduction 172 to 129 warm spawns across 43 checkouts; 25% fewer The real-Git fixture measures the process cost targeted by this change.

Technical review

Best possible solution:

Keep the optimization in the Gateway branch-facts owner; assess a broader checkout cache separately if polling cost still warrants it.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main’s source shows the equal-tip merge-base call, and the PR reports baseline and candidate measurements using real Git checkouts; this read-only review did not rerun the fixture.

Is this the best way to solve the issue?

Yes. It removes one redundant call through the existing Git worker while retaining different-tip ancestry checks and the missing-object fallback.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 273742f9a0c4.

Labels

Label changes:

  • add P2: The measured reduction in repeated Git processes is a bounded Gateway performance improvement.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The changed Gateway branch-facts path was exercised through the session PR loader and Git worker over real Git checkouts; the reported after-fix measurements show fewer processes at warm admission, during idle polling, and after an edit. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: The measured reduction in repeated Git processes is a bounded Gateway performance improvement.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed Gateway branch-facts path was exercised through the session PR loader and Git worker over real Git checkouts; the reported after-fix measurements show fewer processes at warm admission, during idle polling, and after an edit. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • wanyongstar: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 53af3ce into main Sep 27, 2026
235 of 236 checks passed
@steipete
steipete deleted the steipete/perf-micro-session-pr-git-context-polling-20260919 branch September 27, 2026 01:39
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant