Repository navigation
fix: prevent tiny-pack storms during agent history reads - #197259
Conversation
Prepare bounded path-history blob sets before agent log, blame, and repeated show reads. Serialize common-directory prefetches and recheck missing objects under the lock so parallel readers share transfers. Keep native diff batching and negotiated commit acquisition; known blob-only wants use native noop negotiation to avoid falsely claiming missing blob closure.
Count raw discovery bytes under the C locale and use explicit benchmark sample values to satisfy strict indexing checks without changing sample order.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Use the constructed history length in workspace metadata and avoid shadowed variables in warm and allocator proof paths. Measured commands and sample ordering are unchanged.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR batches historical Git blob downloads and coordinates overlapping readers across shared worktrees. Example: An agent reads 600 historical versions with git blame in a shared blobless clone.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review The explicit maintainer acceptance satisfies the prior review’s sole open item. Final head 6903215 has zero open review items; no correctness or security findings remain. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe agent PATH Git shim prepares repository objects before native Git runs, preserving command arguments and output while reducing repeated blob fetches. flowchart LR
A[Agent Git command] --> B[Existing PATH shim]
B --> C[Bounded raw history discovery]
C --> D[Shared lock and missing object check]
D --> E[Native Git blob fetch]
E --> F[Original Git command and output]
Technical reviewBest possible solution: Land the bounded batching in the existing Git shim with the recorded warm-read tradeoff accepted. Do we have a high-confidence way to reproduce the issue? The supplied real-Git baseline measurements establish repeated single-blob hydration, and current-main source leaves historical blobs to that path; this read-only review ran no target code. Is this the best way to solve the issue? The patch uses the existing Git query and fetch owner, preserves native diff batching and fallback behavior, and adds no persistent cache; its measured warm-read cost now has explicit owner acceptance. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7f5697b3bf9d. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +145, Tests +190, Docs +1, Other +124. Total +460 across 5 files. Added test files: 1. View PR surface stats
Preflight sourceSource 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
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 11, 2026, 10:57 AM ET / 15:57 UTC (Revision 2). |
|
Addressing the latest ClawSweeper review, item 1 — Await maintainer action, on final head Peter explicitly accepted the measured warm-read regression on 2026-11-11. Warm log increases from 41.79 to 69.68 ms (approximately +28 ms), and warm blame from 17.82 to 30.07 ms (approximately +12 ms). He accepts this cost for cold log 13.5 s→76 ms, cold blame 12.6 s→63 ms, and collapsing roughly 600 single-blob promisor packs into one. Production evidence supplied with the decision: 596 single-blob promisor packs during 13:45–13:52Z, contributing to the shared base growing from 1,032 to 1,643 packs that morning. These are the peer's pre-fix observations; no deployment or post-deploy production validation is claimed. The accepted cost comes from bounded offline raw-history discovery at agent-git-shim.ts:228–250 and missing-object preparation at lines 319–340. Already-present sets return before acquiring the shared lock; no persistent cache was added. No code changed for this acceptance. The PR body now records the decision and exact measurements. CI run 43048946201 is green on this head. @clawsweeper re-review Please verify item 1 is satisfied by the explicit maintainer acceptance and report the open-item count for this final head. |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…7259) * fix: batch historical blob reads in shared worktrees Prepare bounded path-history blob sets before agent log, blame, and repeated show reads. Serialize common-directory prefetches and recheck missing objects under the lock so parallel readers share transfers. Keep native diff batching and negotiated commit acquisition; known blob-only wants use native noop negotiation to avoid falsely claiming missing blob closure. * fix: make blob discovery byte bounds locale-independent Count raw discovery bytes under the C locale and use explicit benchmark sample values to satisfy strict indexing checks without changing sample order. * fix: keep historical blob benchmark checks precise Use the constructed history length in workspace metadata and avoid shadowed variables in warm and allocator proof paths. Measured commands and sample ordering are unchanged.
What Problem This Solves
Fixes bursts of tiny promisor packs when parallel agents read file history in shared blobless Git worktrees.
User Impact
Path-scoped patch/stat logs, ordinary blame, and repeated
show rev:pathreads hydrate bounded historical blob sets in one fetch. Command output stays unchanged. Native diff already batches endpoint blobs and keeps that implementation.Warm history reads have extra offline discovery work: final Linux medians are log 41.79→69.68 ms and blame 17.82→30.07 ms (three additional Git processes). Loaded macOS controls showed increases of 79–88 ms; shared-host timing noise is recorded. Peter explicitly accepted this tradeoff on 2026-11-11: +28 ms for warm log and +12 ms for warm blame is acceptable for cold log 13.5 s→76 ms, cold blame 12.6 s→63 ms, and collapsing roughly 600 single-blob promisor packs into one. Production evidence supplied with that decision: 596 single-blob promisor packs appeared during 13:45–13:52Z, contributing to the shared base growing from 1,032 to 1,643 packs. This is acceptance of the measured regression, not a claim of production validation after deployment. No new configuration, persistent cache, dependency, or schema.
Why This Change Was Made
The PATH shim already prepares missing commits, but history traversal leaves blobs to individual lazy fetches. Git's offline raw changes supply old/new IDs—including range and count boundaries—without scanning unrelated tree contents. A common-directory lock and missing-object check under that lock coalesce identical/overlapping readers.
Batches cap candidate IDs at 2,048 and 128 KiB; raw discovery stops at 8 MiB. These bound discovery/request size, not unknown remote blob payload sizes. Unsupported forms, content/rename tracking, oversized batches, prefetch errors, and bounded lock waits retain native lazy hydration. Present show objects skip history preparation; absent show objects prepare path history reachable from HEAD and the requested revision, covering loops in either order.
Known blob-only batches use Git's native noop negotiation. Advertising a commit as a have can suppress its promised blobs: a retained synthetic fixture produced an empty negotiated pack followed by individual lazy fetches. Blob-only roots transfer only requested blobs; missing-commit preparation still negotiates history.
Evidence
Acceptance rule: on a fresh blobless shared clone with 62,000 stable paths (~1.116 GB logical content) and 600 append-only historical file versions, preserve output and transferred object counts while reducing promisor packs/transport starts from per-blob to one. Cold and warm runs are separate; a warm regression over 20% requires explicit acceptance.
Five counterbalanced A/B pairs per command, cached Linux environment with networking disabled, native filesystem, 2 CPUs, Git 2.47.3:
Every sample transfers exactly 600 blob objects and preserves output hashes. A/A log control was 29.29→10.72 s (substantial startup/host drift); blame was 11.72→11.12 s. The shared host is busy, so counts and CPU are stronger evidence than wall tails. macOS Git 2.56 independently reproduced 600 tiny packs; a full-scale candidate used one pack in ~0.5 s. Native allocation requests fall 4,969,628→102,312 for log and 5,328,179→81,996 for blame. Cumulative requested bytes fall 1,917,393,829→164,732,426 and 1,964,552,946→148,843,295 (91–92% less). These are observable malloc-family requests across Git children, not live heap; separate A/A byte drift is 0.0017% and zero. Five allocator-only pairs are separate from timing runs. Final-source warm and cold smoke pass; the final locale correction is ASCII-equivalent for the full fixture.
The committed workload is
node --import ./scripts/tsx.mjs scripts/perf/agent-git-probes.mts --history-blobs --commits 600 --files 62000 --samples 5 --baseline-shim <saved-baseline-shim> --scratch-parent <isolated-directory>;--aa-only,--ab-only, and--warmselect separate controls.Real-Git regressions pass (3 tests): original log/blame 11 packs, show loop 3 packs, concurrent identical reads 11 packs → one each; output/path scope, offline probes, bounded/ranged log boundaries and oversized fallback are preserved. Existing owner tests pass (2 tests). A 100-path native diff control transfers exactly 200 endpoint blobs in one pack. New tests take ~5 s on the initial run (~15 s under later host load); the exact 190-line allocation covers these distinct boundaries.
Independent Codex autoreview of the implementation and follow-ups is clean through P2. Core and test typechecks pass.
pnpm check:changedcaught benchmark indexing/shadowing errors, now fixed with passing targeted scripts typecheck, lint and formatting. Its remaining unused-export findings reproduce identically on exact main parent54bfcd8fd601618108b65f6637beb3f611f2e28e: 57 production, 32 full-tree, 0 script, no resolution errors. Introducing commits are attributed; no new finding appears beyond the previously reported main regressions. The full check is not claimed green. Exact-head CI run 43048946201 is green. ClawSweeper found no correctness or security issues on the final head; its sole open item was explicit warm-regression acceptance, now granted above. A final re-review with zero open items is required before landing.Production growth: 145 lines, required for bounded command selection, native raw-object enumeration, and cross-process coordination where no blob-batching owner existed. No UI-imported modules changed. No deployment or production pack-rate validation is claimed.