Skip to content

perf(gateway): avoid missing-blob scans in PR statistics - #166264

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-git-operations-still-dominant-on-team-20260919
Oct 7, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-git-operations-still-dominant-on-team-20260919

Conversation

@steipete

@steipete steipete commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Background PR statistics can repeatedly occupy a Git worker for 120 seconds when a partial clone is missing changed blobs. Git's failed-fetch path scans every promisor pack, even with lazy fetching disabled; a healthy multi-pack-index does not prevent it.

User Impact

On Git 2.45+, unavailable working-tree statistics return promptly without implicitly fetching missing blobs. Once the checkout materializes those blobs, the existing refresh path returns normal statistics. Ancestry checks and explicit diff/checkout operations retain their behavior. Older Git retains its native hydration behavior.

Why This Change Was Made

The existing statistics owner admits locally available blob inputs using a NUL-delimited raw diff and one batch object check before calling native shortstat. Git still owns rename, binary, conflict, and line-count semantics. The existing revision cache and five-minute fallback remain unchanged; no new configuration, schema, cache, or concurrency owner is introduced.

Production LOC is +50. This growth is required to avoid Git's expensive missing-object failure path while preserving native statistics and the Git versions shipped with documented Ubuntu/Debian installations. There is no superseded cache or scheduling machinery to retain or remove.

Evidence

Read-only diagnosis found repeated two-command PR-facts reads spending about 120 seconds inside Git with no queue wait. A sampled comparison needed eight unavailable blobs. Raw metadata plus local availability checks took 26 ms; disabling lazy fetching on shortstat alone still exceeded a 10-second diagnostic cap.

Blacksmith Testbox tbx_01m499p4phk0556smaebp0ba2d (openclaw-check): synthetic project with 700 worktrees, 55 overlapping promisor packs, 1,543,080 packed entries; ten active worktrees and ten concurrent readers each. Cold-inclusive comparison: 6.197 s → 3.425 s (44.7%), with identical PR facts. Steady state: 3.392 s → 0.341 s (90.0% less worker-path wall time), with identical unavailable-statistics facts. Process RSS was 428.1 MiB → 416.3 MiB (not a subprocess peak). With all blobs present, identical complete statistics cost 0.368 s → 0.524 s, or about 16 ms extra per refreshed worktree; unchanged cache hits still spawn no Git.

The regression uses a real partial clone, verifies no implicit fetch on supported Git, explicitly hydrates the missing blob, and then verifies the exact +1/-1, one-file statistics. The regression fails on the original code, which implicitly fetches the blob, and passes on the fix in 0.506 s. node scripts/run-vitest.mjs src/infra/git-worker.lifecycle.test.ts src/gateway/control-ui-session-prs-branch.test.ts src/infra/git-read-cache.test.ts --maxWorkers=1: 88 tests pass, 107.59 s wrapper wall time. The existing 55-case real-repository branch suite took 94.75 s including worker preparation; the infrastructure group took 10.24 s. This suite owns native Git rename, binary, conflict, replacement-ref, and refresh semantics, which cannot be established by command mocks. Independent Codex review is scoped-clean through P2, with no accepted/actionable findings. node scripts/check-changed.mjs --staged: passed, including all 27 test type graphs, core types, dead-code scans, lint (zero warnings/errors), and repository guards. The final healthy-rig-plus-gate command took 26m53s. All heavy validation ran on the named Testbox at base cc7e664dfe34; its lease is stopped. The publication rebase onto two unrelated main fixes preserves the identical patch (verified with range-diff); GitHub CI covers the published head. No production deployment or repository repair was performed.

Published-head CI

CI run 37521512105 at b385b41da921: all selected code/test/type/lint/docs jobs passed. The six selected Node jobs took 44–233 seconds each (whole-job time including setup).

CI remains blocked by the unchanged production lockfile's MCP client 2.0.0 and SDK 1.30.1, reported under GHSA-6qxp-vccf-f47h; the advisory fixes are client 2.2.0 and SDK 1.31.0. Current main has the same dependency versions, and this PR changes no manifest or lockfile. The fail-fast monitor separately hit GitHub HTTP 500 while attempting cancellation. An earlier labeler HTTP 500 was reconciled and its failed-job-only retry passed. No product failure was retried or hidden.

The dependency repair needs its own approved change; this performance PR stays scoped. No production deployment has been performed, so production savings remain unverified.

@clawsweeper

clawsweeper Bot commented Oct 6, 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 docs Improvements or additions to documentation gateway Gateway runtime size: S labels Oct 6, 2026
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 8:34 PM ET / October 7, 2026, 00:34 UTC (Revision 3).

ClawSweeper review

What this changes

Background pull-request statistics check local Git blob availability before calculating counts, avoiding expensive missing-object scans while preserving older Git behavior.

Merge readiness

✅ Ready for maintainer review

The PR remains useful: current main lacks the missing-blob admission check, and the supplied production-path evidence supports the optimization. No blocking correctness or security findings remain.

Priority: P2
Reviewed head: 5b56e42cd8430b5cd08c86c9686b81977093bda9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with meaningful real-Git evidence and explicit performance tradeoffs; no material review blockers were found.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured Testbox evidence exercises the statistics owner through real Git-worker reads against missing promisor blobs, reports identical facts with faster recovery, and verifies exact counts after hydration. The inspected regression uses real Git rather than mocked transport; its production code is unchanged since the previously reviewed head. 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 captured Testbox evidence exercises the statistics owner through real Git-worker reads against missing promisor blobs, reports identical facts with faster recovery, and verifies exact counts after hydration. The inspected regression uses real Git rather than mocked transport; its production code is unchanged since the previously reviewed head. No stored-data contract changes.
Evidence reviewed 9 items Pinned introduced change: The introduced delta adds blob admission inside the existing statistics owner. It preserves native shortstat, disables external diff and text conversion, and adds no configuration, persistent storage, or competing scheduling owner.
Current main still needs the change: The fetched main implementation calls native shortstat directly without a local-object inventory or batch availability check. The reported expensive missing-object path remains present.
Real Git worker regression: The new case creates a real partial clone and invokes pull-request.branch-facts through runGitWorkerOperation. It asserts no implicit fetch on supported Git, then explicitly hydrates the blob and checks exact one-file, +1/-1 statistics; older Git retains its native fetch result.
Findings None None.
Security None None.

How this fits together

The Gateway reads checkout facts through its Git worker to populate session pull-request indicators in the Control UI. Those reads produce branch eligibility and approximate change counts, using the existing revision cache and refresh lifecycle.

flowchart TD
  A[Session PR indicators] --> B[Checkout facts cache]
  B --> C[Git worker]
  C --> D[Local blob availability]
  D -->|Available or older Git| E[Native Git statistics]
  D -->|Missing blobs| F[Unavailable statistics]
  E --> G[Branch facts returned]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +50, Tests +46, Docs +2. Total +98 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 50 0 +50
Tests 2 47 1 +46
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 99 1 +98

Review metrics

Metric Value Why it matters
Production versus test growth production +50, tests +46 net The PR explicitly justifies production growth as local-object admission while retaining Git's statistics semantics and supported older versions.
Measured refresh tradeoff 90.0% less steady-state worker-path wall time with missing blobs; about 16 ms extra per complete refresh The reported production-path comparison quantifies both the targeted benefit and the cost when all blobs are available.

Technical review

Best possible solution:

Keep blob admission in the existing statistics owner, preserving native counts, older Git hydration, and the established refresh lifecycle.

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

Yes: the inspected partial-clone regression exercises the real Git worker and detects implicit fetching before explicit hydration. The PR reports a failing-before/passing-after run; this reviewer did not execute it.

Is this the best way to solve the issue?

Yes: admission in the existing statistics owner avoids the expensive missing-object path while leaving native line counts, cache ownership, and older Git behavior intact.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0288eb1f3692.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This addresses bounded background Git-worker stalls in partial clones without changing core agent execution or channel delivery.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured Testbox evidence exercises the statistics owner through real Git-worker reads against missing promisor blobs, reports identical facts with faster recovery, and verifies exact counts after hydration. The inspected regression uses real Git rather than mocked transport; its production code is unchanged since the previously reviewed head. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured Testbox evidence exercises the statistics owner through real Git-worker reads against missing promisor blobs, reports identical facts with faster recovery, and verifies exact counts after hydration. The inspected regression uses real Git rather than mocked transport; its production code is unchanged since the previously reviewed head. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced change: The introduced delta adds blob admission inside the existing statistics owner. It preserves native shortstat, disables external diff and text conversion, and adds no configuration, persistent storage, or competing scheduling owner. (src/gateway/control-ui-session-prs-git.runtime.ts:244, 5b56e42cd843)
  • Current main still needs the change: The fetched main implementation calls native shortstat directly without a local-object inventory or batch availability check. The reported expensive missing-object path remains present. (src/gateway/control-ui-session-prs-git.runtime.ts:243, 0288eb1f3692)
  • Real Git worker regression: The new case creates a real partial clone and invokes pull-request.branch-facts through runGitWorkerOperation. It asserts no implicit fetch on supported Git, then explicitly hydrates the blob and checks exact one-file, +1/-1 statistics; older Git retains its native fetch result. (src/infra/git-worker.lifecycle.test.ts:168, 5b56e42cd843)
  • Captured after-fix production-path evidence: The supplied PR body reports Testbox tbx_01m499p4phk0556smaebp0ba2d exercising real Git with 700 worktrees, 55 overlapping promisor packs, and 1,543,080 packed entries. Unavailable-statistics facts remained identical while steady-state worker-path wall time fell from 3.392 s to 0.341 s. Complete statistics also remained identical, with about 16 ms additional cost per refreshed worktree. The partial-clone regression reportedly failed before the fix and passed afterward in 0.506 s; 88 focused tests passed. These are contributor-reported observations, not checks executed by this reviewer. Captured context sourceRevision: 722684a4144c9e1f21dcd7ac1f5aec11c22f87686c02bfab953431a582501fe1.
  • Re-review continuity: The production statistics module and lifecycle regression are unchanged from the previous reviewed head. The supplied completed-review projection contains no outstanding findings or published rank-up moves. (src/gateway/control-ui-session-prs-git.runtime.ts:236, 5b56e42cd843)
  • Verified merge-result identity: The test merge records the exact fetched main parent followed by the exact PR head. Its comparison against main contains the same four introduced paths; no base-only deletion or downgrade was observed. (1d58024989e9)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • galiniliev: 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-06T19:51:49.570Z sha b385b41 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T20:01:35.451Z sha b385b41 :: needs maintainer review before merge. :: none

@steipete
steipete enabled auto-merge (squash) October 6, 2026 19:52
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 6, 2026
@steipete
steipete merged commit 367d33f into main Oct 7, 2026
101 checks passed
@steipete
steipete deleted the steipete/perf-micro-git-operations-still-dominant-on-team-20260919 branch October 7, 2026 00:39
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant