Skip to content

fix: batch content searches across shared Git history - #197448

Merged
steipete merged 4 commits into
mainfrom
steipete/perf-micro-pickaxe-lazy-fetch-storm-20260919
Nov 12, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/perf-micro-pickaxe-lazy-fetch-storm-20260919

Conversation

@steipete

@steipete steipete commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Agent content searches in shared blobless worktrees bypassed the history-prefetch owner from #197259, causing thousands of native Git lazy fetches and tiny promisor packs. This extends that owner; shared-base consolidation from #197287 stays in place.

User Impact

The existing PATH shim now batches log -S/-G (with pickaxe modifiers), range-wide patch/stat/numstat logs, endpoint diffs, and explicit-revision grep. Pathspecs remain scoped and the original command still runs unchanged. Large searches print a short object-count notice and continue through batches of at most 2,048 missing objects under the same shared lock. There is no new configuration, cache, schema, dependency, or fetch owner.

Why This Change Was Made

The classifier previously prepared only path-scoped logs, blame, and speculative show rev:path, abandoning history discovery above 2,048 candidates. Range-wide searches now enumerate raw old/new blob IDs; grep enumerates the requested trees. Missing objects flow through the existing fetch --stdin operation, with bounded requests and one lock across the complete operation. Readers wait for a live lock owner beyond thirty seconds; ownerless locks retain the existing bounded fallback. Show and blame retain their speculative discovery bounds.

Pickaxe -n/--max-count limits count matching commits, so discovery cannot stop at the first N commits. This can prefetch more history than an early successful search would require. Unsupported argument forms retain native Git behavior.

Evidence

Acceptance rule: preserve command output and object scope, eliminate per-blob transport overhead, and measure cold/warm behavior separately with A/A controls. Bound large requests without falling back to a fetch storm. Any worse metric is disclosed for explicit owner acceptance; this is not a claim of universal improvement.

Final bounded candidate, native macOS, real public OpenClaw history: 3,091 commits through 477fa49a30c4e00241f7d650115eb12418471d3f. Each arm uses a fresh blob:none clone and registered linked worktree served by a read-only local source. git log --oneline -S gateway HEAD returns the same 410 matches and SHA-256 47f61c98b1f3de3dfe9201fc9a3b1db6d1f76ccd3125a04b229cd27d480ad24c.

Metric Before Final bounded fix
New promisor packs / transports 2,939 11
Fetched blobs 22,112 22,112
Wall time 1,681.890 s 30.620 s
Qualified full Git-operation CPU at least 1,441.480 s 26.720 s
Maximum child RSS 405.00 MB 407.40 MB
Sampled client-tree RSS 525.01 MB 409.12 MB
Sampled local-server-tree RSS 113.43 MB 309.77 MB
Final Git peak memory footprint 137.97 MB 227.44 MB

One real-history A/B pair, not a latency distribution. A mid-baseline snapshot found a median of two objects per pack. Setup/hydration are outside measurement. The initial clone advertises filtering; subsequent blob-only local fetches emit an unsupported-filter warning, included in baseline timing. Both arms nevertheless transfer exactly the same 22,112 blobs. No production data or production deployment is involved.

Darwin /usr/bin/time loses pre-exec child CPU when the shim execs Git, so the candidate's original 2-second counter is not whole-flow CPU. A calibrated per-command timing proxy recovered 18 receipts including all 11 fetches, totaling 26.72 CPU seconds on a separate candidate run with identical counts/output. The baseline counter is a conservative lower bound because its final Git process owns the lazy-fetch children. This supports at least 98.1% less CPU. Instrumented wall time is not substituted for the primary wall measurement. The committed benchmark now labels Darwin's narrower CPU scope.

Five serial counterbalanced native synthetic A/B pairs use 62,000 stable paths / 1.116 GB logical workspace and 600 distinct historical versions:

Metric Before After
Cold packs / transports 600 1
Cold wall median / p95 70.865 / 77.489 s 1.000 / 1.102 s
Cold peak RSS median 55.640 MB 33.817 MB
Warm wall median / p95 528.918 / 648.187 ms 873.896 / 990.117 ms
Warm Git starts 2 5
Warm packs / objects / transports 0 0
Warm peak RSS median 33.915 MB 33.898 MB

All synthetic cold pairs preserve stdout and 601 transferred blobs. Cold A/A: 49.651 → 51.788 seconds with identical work counts. Warm A/A: 578.691 → 478.196 ms, two Git starts and zero transports in both arms. Shared-host load varied; work counts are stronger evidence than wall tails. Native synthetic CPU counters cover post-exec work only and are not used as full-flow claims.

Tradeoffs explicitly accepted by the lead/owner for lane 2425: warm median latency increases 65.2% (about 345 ms), and final Git peak footprint increases 64.8% (about 89 MB). Sampled client-tree RSS decreases, while the local serving process uses more memory to construct batches. Cumulative allocation remains unmeasured: the container runtime disappeared, a native allocator probe failed calibration, and standard profiling tools stalled. No unqualified allocation numbers are claimed. An earlier unbounded-batch RSS increase motivated the final 2,048-object request bound; the table above supersedes that intermediate result.

Reproduce using the existing committed workload:

node --import ./scripts/tsx.mjs scripts/perf/agent-git-probes.mts --pickaxe --history-repository <complete-public-fixture> --baseline-shim <baseline-shim> --scratch-parent <isolated-directory> --samples 1 --ab-only
node --import ./scripts/tsx.mjs scripts/perf/agent-git-probes.mts --pickaxe --commits 600 --files 62000 --baseline-shim <baseline-shim> --scratch-parent <isolated-directory> --samples 5 --ab-only

Use --warm for hydrated reads and --aa-only --samples 1 for controls. Role-separated RSS and qualified Darwin CPU use supplementary local sampling/proxy receipts; the committed workload reproduces the command and transport counts.

Validation and Review

The extended regression fails nine pack-count assertions on the unchanged parent while preserving stdout. The focused owner suites pass (5 tests). The final history suite passes all 3 tests, including path scoping, pickaxe result limits, concurrent overlapping readers, offline behavior, speculative show/blame bounds, and 2,049 missing objects in exactly two packs with no duplicate wants.

Codex autoreview found a grep -G parsing collision; its two-pack regression is fixed. Hosted Codex review found the unintended loss of the existing blame discovery cap; a blame -L regression reproduced 2,048 unnecessary requests, and the correction restores one requested blob. Independent final code and benchmark-metadata autoreviews are scoped-clean through P2. pnpm check:changed passed before the bounded-request follow-up. On final head, its typechecks, lint, formatting, dead-export scans and other guards passed, but four guards failed to resolve the shared origin/main ref (one was warning-only). Those four guards then passed against the same pinned parent 27af644cbfeebc86118b6abc8ebbbabdcec44499. The failed overall invocation is retained as an infrastructure interruption, not described as an inherited code failure or an entirely clean replay. Affected tests, diff checks and the test-line ratchet pass. Native scripts/pr prepare-run completed on the unchanged final head. Exact final-head CI 43139667087 passed, including the CI gate, without failures or reruns. ClawSweeper reviewed final head 0b2e160035c61d3cf52313489f9463fff1cafecc with no actionable code findings; its sole unchecked item requested explicit owner acceptance of the measured performance tradeoffs. The lead has now accepted the measured warm latency, final Git footprint and transient serving-tree RSS costs, with allocation totals remaining a disclosed limitation. Acceptance is limited to these measured values; later regressions beyond them require re-review. A numbered response records the decision and requests ClawSweeper to clear the item. No UI-imported modules changed.

Production growth is 75 net lines for classifier/discovery semantics, live-lock waiting, and bounded pack construction. The 27 net test lines extend existing real-Git fixtures. No new subsystem or production cache is introduced.

@clawsweeper

clawsweeper Bot commented Nov 12, 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 scripts Repository scripts size: M labels Nov 12, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR extends the existing Git shim to batch missing objects for content searches across shared blobless worktrees.

Example: Run git log --oneline -S gateway HEAD across the recorded 3,091-commit OpenClaw fixture.

  • Before: The search creates 2,939 promisor packs and takes 1,681.890 seconds.
  • After: The search creates 11 packs and takes 30.620 seconds, preserving all 410 matches and the same 22,112 fetched blobs.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Production-path measurements, focused real-Git regressions, green exact-head CI, and explicit owner acceptance leave no unresolved merge work.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied native macOS runs exercise the production shim and real Git transport in fresh blobless clones with linked worktrees, preserve output hashes and object counts, and demonstrate bounded fetching; cold/warm synthetic pairs and A/A controls supplement the real-history comparison.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Agent content searches can spend many minutes creating thousands of tiny packs that burden every linked worktree.
Reason: The recorded real-history search preserves results and transferred blobs while sharply reducing transport work, and the owner has accepted the measured costs.

Merge readiness

✅ Ready for maintainer review

This PR is ready for normal landing: no actionable findings remain, and the owner explicitly accepted the measured performance tradeoffs for the reviewed head.

Priority: P2
Reviewed head: 0b2e160035c61d3cf52313489f9463fff1cafecc

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Gateway installs a PATH-based Git shim for agent commands; it discovers missing repository objects, coordinates fetching across linked worktrees, and then executes the original Git command.

flowchart TD
  A[Agent Git command] --> B[Existing PATH shim]
  B --> C[Offline object discovery]
  C --> D[Shared repository lock]
  D --> E[Bounded native Git fetches]
  E --> F[Original Git command]
Loading

Technical review

Best possible solution:

Land the existing-owner batching change with its bounded fetch requests and preserved speculative discovery limits.

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

Current-main source excludes pickaxe searches and abandons oversized discovery; the supplied native Git measurements establish the resulting fetch storm, and no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch is the smallest complete extension of the existing owner: classify supported content reads, discover their objects, and fetch bounded batches under the shared lock while retaining native fallback.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 55cac5900c15.

Provenance checked

  • Historical-blob discovery and shared locking changes intended behavior with a stated reason (a07cbf5: Batch path-scoped history reads without changing output, using bounded speculative discovery and native fallback.)
  • Git shim delivery and benchmark keeps the original intent (b6d8eb2: Keep existence probes offline while preserving content hydration through the existing Gateway PATH owner and measuring its overhead.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a07cbf5 adds src/infra/agent-git-shim.ts:228 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a07cbf508fbd; files: src/infra/agent-git-shim.ts)

PR surface

Source +75, Tests +27, Docs 0, Other +36. Total +138 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 92 17 +75
Tests 1 33 6 +27
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 72 36 +36
Total 5 198 60 +138

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus regression-test growth Production +75 net lines; tests +27 net lines Growth extends the existing classifier, bounded fetch operation, and real-Git fixture to cover distinct content-search failures.
Benchmark controls 2 new benchmark flags --pickaxe and --history-repository extend the existing workload; no runtime configuration option is added.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on maintainer: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The fix addresses expensive content searches and shared-repository pack pressure with limited workflow scope.
  • merge-risk: 🚨 other: Batching has measured warm-latency and memory costs that CI cannot evaluate; the feature owner explicitly accepted those recorded values for this head.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-12T01:30:32.997Z sha 9eed252 :: ready, awaiting a maintainer decision. :: none
  • reviewed 2026-11-12T02:17:36.136Z sha 0b2e160 :: blocked before merge. :: none

Reviewed November 11, 2026, 9:37 PM ET / November 12, 2026, 02:37 UTC (Revision 3).

@steipete
steipete marked this pull request as ready for review November 12, 2026 01:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T01:57:57.589470Z e200800 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1da520e9ac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/infra/agent-git-shim.ts Resolved
@steipete

Copy link
Copy Markdown
Contributor Author

Final review response for head 0b2e160035c61d3cf52313489f9463fff1cafecc:

  1. ClawSweeper memory decision and incomplete controls (review): that review contains zero unchecked findings. The original unbounded request is now split into at most 2,048 objects per fetch under the existing common-directory lock (batch owner). The final native 3,091-commit pair preserves output and 22,112 blobs, reducing 2,939 packs to 11 and wall time from 1,681.89 to 30.62 seconds. Maximum child RSS changes 405.00 → 407.40 MB; sampled client-tree RSS falls 525.01 → 409.12 MB. Attribution also finds real costs: final Git footprint rises 137.97 → 227.44 MB and local serving-tree RSS rises 113.43 → 309.77 MB. Five cold/warm synthetic pairs and completed cold/warm A/A controls are now recorded in the body. Warm median increases 528.918 → 873.896 ms. Explicit owner acceptance of those tradeoffs is still pending; I am not treating improved cold throughput as acceptance.
  2. Hosted Codex blame finding (finding): fixed by retaining discovery caps for both speculative show and blame (owner). The existing real-Git fixture's new blame -L assertion failed with 2,049 requests before the correction and passes with one; the exhaustive pickaxe assertion still verifies two bounded packs for 2,049 missing objects (regression).
  3. CPU and allocation evidence: Darwin's post-exec CPU counter omitted prefetch children. A calibrated per-Git-command proxy captured all 18 operations including 11 fetches: 26.72 CPU seconds, versus a conservative baseline of at least 1,441.48 seconds. The committed harness now labels its Darwin CPU scope. Cumulative allocation could not be qualified after documented container-runtime and native-profiler failures; the body explicitly records that gap and makes no allocation-improvement claim.

Focused regressions, lint/format and independent Codex autoreview pass. Full CI on the preceding source head passed; the final metadata-label head's CI is running. The PR body now describes the final bounded implementation and complete available evidence.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper clawsweeper Bot removed the clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. label Nov 12, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Lead/owner decision for lane 2425: the measured tradeoffs are accepted, and landing is authorized for head 0b2e160035c61d3cf52313489f9463fff1cafecc.

  1. ClawSweeper “Await maintainer action” item — addressed. The lead explicitly accepts warm latency 529→874 ms (+345 ms), final Git footprint 138→227 MB (+89 MB), and peak local serving-tree RSS 113→310 MB (+197 MB). The unavailable cumulative-allocation totals remain a disclosed proof limitation. The acceptance is scoped to these measured values; any later regression beyond them needs re-review.

The lead's rationale:

the production storm shape (agent git log -S in a blob:none worktree) drops from 2,939 single-blob packs and ~28 min to 11 packs and ~31 s, with identical output, and it stops the tiny-pack storms that degrade the shared base clone for every user. Warm latency +345 ms (529→874 ms) is paid only by range-wide content searches, which are rare and already long-running. +89 MB final Git footprint is the same objects held in fewer, larger packs plus prefetched blobs, and consolidation (#197287) owns the pack layout. +197 MB peak serving-tree RSS is transient, for the duration of one search. Acceptance is for these measured values; a later regression beyond them needs re-review.

The implementation remains at the existing owner: bounded fetches under the shared lock, with speculative show/blame caps preserved. No source change follows this decision. Exact-head CI run 43139667087 passed, and native PR preparation completed at this head.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. labels Nov 12, 2026
@steipete
steipete merged commit 4092d35 into main Nov 12, 2026
180 of 181 checks passed
@steipete
steipete deleted the steipete/perf-micro-pickaxe-lazy-fetch-storm-20260919 branch November 12, 2026 02:41
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
* fix: batch content searches across shared Git history

* fix: bound shared history prefetch pack construction

* fix: retain bounded discovery for line-limited blame

* fix: label Darwin benchmark CPU accounting scope
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 merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: M 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