Skip to content

fix: avoid base hydration timeouts in large partial clones - #189288

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-managed-worktree-base-hydration-20260919
Oct 31, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-managed-worktree-base-hydration-20260919

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes managed-worktree creation timing out during base hydration in large partial clones, with no failure class or phase in the preparation receipt. Related: #188525.

User Impact

New worktrees hydrate the selected commit's missing contents without scanning unrelated promised packs. Failed preparations report their error class and innermost timed phase. Snapshot removal still refuses missing locally authored data and preserves the checkout. No configuration, schema, timeout or cache changes.

Why This Change Was Made

The snapshot-retirement promisor check was added to the shared hydrator. Git's --missing=allow-promisor initializes membership by scanning every promisor pack even with --max-count=1 (Git source); that offline command has a two-minute budget, while the actual fetch has five minutes. Move the check to the snapshot owner, restoring creation's previous semantics. Keep exact-object batch fetching, local validation, shared commit preparation and Gateway-internal Git placement.

Preparation diagnostics record class and phase without including error messages or command output. Runtime growth is 29 lines: 24 for the requested failure receipts and five for preserving the snapshot-only check and its error handling. No competing owner or new cache was added.

Evidence

Acceptance: identical allocated checkout size, remove the global promisor scan from creation, keep one exact-object fetch, and no material latency/CPU/allocation regression. Native Git fixture: 62,000 logical files / 1,142,784,000 payload bytes, one missing 18 KiB blob, and 600,000 unrelated historical blobs. Five fresh-seed interleaved pairs; separate five-pair allocation pass and two same-revision A/A pairs for each mode. macOS/APFS, local file:// transport; this measures the Git owner, not production network, btrfs or a large session database.

Metric Before After
Owner wall median / p95 1,715 / 1,904 ms 771 / 899 ms
Native Git CPU median 1,190 ms 250 ms
Native Git peak RSS median 162.4 MiB 30.4 MiB
JS owner CPU median 268.4 ms 245.1 ms
Sampled JS allocation median 61,101,304 bytes 60,315,216 bytes
Global promisor scans / fetches 1 / 1 0 / 1
Allocated checkout bytes 1,269,760,000 1,269,760,000

A/A wall spread was 1.56–2.68 seconds under substantial host load; native CPU was 1.15–1.28 seconds. Candidate timing's worst sample (899 ms) remained below baseline's best (1,565 ms). Allocation is effectively flat within A/A sampling noise (60.1–61.9 MB). Every counted acquisition arm fetched exactly one object. New fixture and existing measurement script make the comparison rerunnable.

Regression proof: the old preparation receipt fails the class/phase assertion; both promisor configuration variants fail the no-global-scan assertion on the old hydrator. The other 18 capacity tests passed on baseline. Existing snapshot tests cover promised, unavailable, corrupt and unpromised local objects; 15 added test lines extend those owner contracts rather than adding another suite.

All 75 focused tests pass across capacity, timing receipts, snapshot-removal safety and removal-budget suites (209 seconds of test-shard wall time, plus one worker build). The real managed-worktree service also materialized all 62,000 files with the correct commit and clean status; hydration/sizing took 535 ms. Total creation was 62.35 seconds under contention, dominated by checkout/template work; this is correctness evidence, not a before/after creation latency claim. Independent Codex autoreview is scoped-clean at P0–P2. The changed-file checks pass except the inherited dead-export audit: resolveFollowupReplyAnchor, captureRepositoryClientActor, RepositoryOperation, and RepositoryAuthorization. Their three owner files are byte-identical to baseline ed3e1a0f80999fcea86add63c806cbc9bd080477, and this patch changes no production import/export edges. The complete pnpm check:changed run finished with only that inherited audit failure; all other stages passed, including core/scripts lint, type checks, runtime boundaries and cycle checks. The test-line allowance also passed. Changed test execution cost: capacity 24.56 seconds, timing receipts 13 ms; no new suite or startup.

Keep the repository-wide promisor membership scan at snapshot retirement,
where it protects missing locally authored content, instead of running it
for every creation that needs an object batch. Preserve exact-object fetches,
local checkout validation, authority checks and existing preparation reuse.

Include the thrown error class and innermost phase in preparation receipts
without logging command output or changing the original exception.

Regression proof covers creation scan counts and failure receipts; native
snapshot safety tests retain local-object loss protection. A 62,000-file
synthetic fixture cuts median hydration wall time from 1.72 s to 0.77 s and
native Git CPU from 1.19 s to 0.25 s with identical checkout byte totals.
@clawsweeper

clawsweeper Bot commented Oct 31, 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 agents Agent runtime and tooling size: M labels Oct 31, 2026
@steipete
steipete marked this pull request as ready for review October 31, 2026 10:23
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T10:25:14.152883Z 9941346 Draft marked ready
ℹ️ 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.

@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. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR moves promisor classification into snapshot capture and adds failure class and phase to worktree preparation diagnostics.

Example: Create a worktree from the supplied 62,000-file partial-clone fixture with one missing blob and 600,000 unrelated historical blobs.

  • Before: Hydration performs one global promisor scan and one fetch.
  • After: Hydration performs no global promisor scan and retains one exact-object fetch.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused owner repair with green exact-head CI and no findings; supplied behavior evidence is strongest at native-Git and service boundaries.
Proof confidence 🦐 gold shrimp (3/6) The maintainer-authored PR is outside the ordinary contributor proof gate; its native Git benchmark and managed-worktree service report support hydration behavior, while failure attribution has unit-level evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Worktree creation can time out while classifying unrelated promised objects, and failed preparation receipts omit the failure class and phase.
Reason: The maintainer-authored direction restores creation semantics while preserving the earlier snapshot repair and improves diagnosis within the existing receipt owner.

Regression provenance

Regression provenance — verified: source commit a583332bd0a1 by RoboClaw; canonical PR #188525 (blame-to-merge-commit).

Merge readiness

✅ Ready for maintainer review

Keep open: this PR addresses a current-main creation regression while preserving snapshot safety; no actionable introduced defect was found.

Priority: P2
Reviewed head: 9941346e5481f35dd108ee68ce5fb1c442b39400

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied service-level creation report does not include a shipped CLI or Gateway trace exercising the new failure receipt.
Agent review details

How this fits together

Managed-worktree preparation resolves a selected Git commit, hydrates missing contents, and estimates checkout capacity; snapshot capture separately verifies that missing local data cannot be mistaken for promised contents.

flowchart TD
  A[Worktree request] --> B[Base preparation]
  B --> C[Shared object hydrator]
  C --> D[Exact object fetch]
  D --> E[Local sizing and checkout]
  F[Snapshot removal] --> G[Promisor classification]
  G --> C
Loading

Technical review

Best possible solution:

Keep exact-object acquisition shared, confine promisor classification to snapshot capture, and preserve original exceptions while recording preparation failure details.

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

Current-main creation reaches the global promisor classification, and Git source confirms its repository-wide initialization; the supplied native fixture reports the extra scan before the fix, but this read-only review ran no reproduction.

Is this the best way to solve the issue?

The patch fixes the misplaced responsibility directly, retaining existing hydration, local validation, and snapshot-loss protection without adding a cache, timeout, or competing owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3f8bff35bba2.

Provenance checked

  • Shared hydration and snapshot classification changes intended behavior with a stated reason (a583332: Enable snapshot hydration while rejecting missing locally authored data before checkout removal.)
  • Preparation timing receipts keeps the original intent (404d388: Attribute preparation costs and retain failed-phase duration without changing preparation results.)
  • Native measurement tooling keeps the original intent (0c6a286: Measure checkout-size owner work against controlled baseline and candidate implementations.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Introduced change and retained safety: The pinned introduced diff removes classification from the shared hydrator and places the same offline command before snapshot hydration, retaining cancellation, current-authority checks, and checkout-preserving error handling. (src/agents/worktrees/snapshot-host.ts:82, 9941346e5481)
  • Current-main defect remains: Fetched main still runs --missing=allow-promisor in hydrateCommitObjects before fetching; capacity.runtime.ts calls that shared owner during creation. (src/agents/worktrees/object-hydration.ts:65, 3f8bff35bba2)
  • Dependency contract verifies the expensive operation: The patch executes Git rev-list and its performance claim depends on Git's promisor implementation; is_promisor_object initializes membership by visiting objects across promisor packs. (packfile.c:2407, 67ad42147a7a)
  • Prior repair and original intent: fix: partial-clone worktree snapshots fail on unfetched blobs #188525 introduced shared snapshot hydration to preserve offline-restorable contents and reject lost non-promisor data; this PR retains that protection at the snapshot owner. (src/agents/worktrees/object-hydration.ts:65, a583332bd0a1)
  • Behavioral evidence supplied: The complete PR body reports interleaved native-Git measurements, unchanged checkout allocation, baseline-failing regression assertions, retained snapshot-safety tests, and successful materialization through the managed-worktree service. (9941346e5481)
  • Exact-head CI and mergeability: The reviewed head is mergeable with clean merge state; its pull-request CI run completed successfully, and aggregate CI, dependency-review, and security-sensitive-review statuses are successful. (9941346e5481)

PR surface

Source +29, Tests +15, Docs +11, Other +176. Total +231 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 50 21 +29
Tests 2 20 5 +15
Docs 1 11 0 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 3 178 2 +176
Total 9 259 28 +231

Review metrics

Metric Value Why it matters
Production versus test growth Production +29 net lines; tests +15 net lines Growth adds failure attribution and relocates the snapshot guard; regressions extend existing suites without another test startup.

Labels

Label changes:

  • add P2: Repairs worktree preparation failures in large partial clones with a limited affected surface.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Repairs worktree preparation failures in large partial clones with a limited affected surface.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

Reviewed October 31, 2026, 6:39 AM ET / 10:39 UTC.

@steipete
steipete merged commit 8631e67 into main Oct 31, 2026
222 of 226 checks passed
@steipete
steipete deleted the steipete/perf-micro-managed-worktree-base-hydration-20260919 branch October 31, 2026 10:51
@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 1, 2026
…189288)

Keep the repository-wide promisor membership scan at snapshot retirement,
where it protects missing locally authored content, instead of running it
for every creation that needs an object batch. Preserve exact-object fetches,
local checkout validation, authority checks and existing preparation reuse.

Include the thrown error class and innermost phase in preparation receipts
without logging command output or changing the original exception.

Regression proof covers creation scan counts and failure receipts; native
snapshot safety tests retain local-object loss protection. A 62,000-file
synthetic fixture cuts median hydration wall time from 1.72 s to 0.77 s and
native Git CPU from 1.19 s to 0.25 s with identical checkout byte totals.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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