Repository navigation
perf(github): avoid repeated publication commit fetches - #183799
Conversation
|
🦞👀 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. |
Codex Review SummaryThis 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 changesSkip publication commit fetches when the exact commit is physically present locally, while retaining missing-commit fetches and requested content hydration. Example: Prepare an already-local commit in the reported synthetic partial clone containing 524,288 blobs and 15,000 refs.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR removes measurable redundant Git work at the existing transport owner, and no actionable correctness or security defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway publication transport receives a selected repository and immutable commit, prepares local Git objects, and supplies publication and sandbox base-refresh operations. flowchart TD
A[Publication or base refresh] --> B[Guarded Git transport]
B --> C[Physical commit probe]
C --> D[Fetch absent commit]
C --> E[Prepare requested contents]
D --> E
E --> F[Publication or workspace integration]
Technical reviewBest possible solution: Retain the narrow physical-presence check in the existing publication transport and preserve its authenticated fetch and content-hydration contracts. Do we have a high-confidence way to reproduce the issue? Current main visibly performs the redundant fetch, and the PR supplies a committed real-Git reproducer with before/after measurements; no target code was executed during this review. Is this the best way to solve the issue? This is a focused owner-level repair: it reuses an established physical-presence probe, adds no cache, and leaves missing-object preparation intact. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c0140ebfa468. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +17, Tests +52, Docs +3, Other +285. Total +357 across 4 files. Added test files: 0. View PR surface stats
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 Reviewed October 25, 2026, 3:50 PM ET / 19:50 UTC. |
What Problem This Solves
Publication and base refresh fetch immutable commits that are already local. In a partial clone, fetching a non-promisor commit can start a connectivity walk that enumerates every promisor object and all refs, consuming substantial memory and CPU even when no objects need downloading.
User Impact
Repeated publication/base preparation reuses the exact local commit. Missing commits still fetch from the selected authenticated repository; requested missing contents still hydrate. There is no configuration, schema, scheduler, or repository-maintenance change.
Why This Change Was Made
The publication transport now checks physical commit presence without lazy fetching or commit-graph substitution, using the existing project-clone owner's Git probe. Callers with a prepared
commitPresentfact keep avoiding that probe. This removes unnecessary transfer/connectivity work at its owner without adding cached state.Pack consolidation already exists in #182204, but does not eliminate Git's object-count-dependent promisor enumeration. This change does not delete externally created refs/remotes or claim to bound a genuinely new commit fetch.
Evidence
Synthetic real-Git fixture: 258 promisor packs, 524,288 blobs, 15,000 refs, 16 MiB payload; Git 2.56.0; five samples per revision in counterbalanced ABABA/BABAB order. The committed script invokes the actual publication owner against a local file remote. Host 1-minute load was 9.62–10.02.
CPU resolution is 10 ms; RSS is largest-process rusage, not an aggregate process-tree total. Replaying the exact traced connectivity child separately gave median 73.921 ms wall, 60 ms CPU, and 91.859–93.922 MiB RSS. The candidate does not start that child. These small synthetic objects reproduce the mechanism, not a production repository's absolute memory usage.
Validation: the real partial-clone regression fails on base (one fetch instead of zero). All 41 focused tests pass across
github-publication-git-index.test.ts,github-publication-base-refresh-actions.test.ts, andgithub-publication.test.ts(76.42 s wrapper wall; includes existing hydration, cancellation, recovery, and publication proof). Changed-file formatting/lint and export-name collision guard pass. Independent subagent review (autoreview route unavailable): no actionable P0/P1/P2 findings; configured route mismatch was left unchanged.Production delta: +18/-1 lines (+17 net). The retained missing-commit fetch and missing-content hydration contracts require the new local-presence branch; no parallel transfer implementation or new cache is added. Regression +52 lines; benchmark usage is in its own header.
Gateway stress
Completed the canonical #183101 harness from tooling after ed32fdc against built main
ffea090901760fd50c088c0255f8819ae8c0e764and PRabe669c35de687b547f26a8a64f15bf3511c77d3: 10,800 sessions, 40 plugins, 65 WebSocket clients, four concurrent mock-provider turns per round, tool calls, native subagents, and sidebar/list/search churn. Two AB/BA timing pairs and two allocation pairs, ten measured minutes per arm. All twelve successful A/B and A/A arms completed 40 turns, 40 tool calls and 40 tool results each.The final allocation baseline initially failed before measurement because its listener did not become ready. Its process exited; the missing baseline was recovered with the canonical single-build allocation mode, identical baseline entry fingerprint, seed and fixture timestamp. The startup failure and gap are retained as limitations, not counted as a measured run. No successful window was excluded, no maintenance pauses were trimmed, and no startup timeout or workload setting was weakened.
Across the two A/B timing-arm means: main-thread CPU 8.60→8.48%, GC 0.188→0.160 s/min, loop p99 33.03→33.75 ms (+0.72 ms), RSS 2624.4→2668.3 MiB (+43.9 MiB, +1.7%), and heap 700.4→681.9 MiB. Separate sampled allocation means were 31.18→29.66 MiB/s (−4.9%; each pair lower). These broad-workload differences are descriptive, not a claim that the Git change accelerated unrelated RPCs.
Client list p99 means rose 98.34→140.07 ms, and server-handler histogram p99 means rose 81.21→120.49 ms. Latency is inconclusive under host contention. Two full identical-baseline timing pairs were declared after the A/B timing results and completed before the landing decision. Identical code produced list p99 149.54–990.66 ms, server-handler p99 118.92–1033.75 ms, and loop p99 33.75–111.80 ms; per-arm mean host load ranged 25.83–85.18. A/A paired server-tail changes were +8.33 and −880.38 ms, far larger and mixed-sign compared with the A/B mean +39.28 ms. This protocol cannot establish a latency regression or improvement. No rejection is based on client tails alone, and the broad result is not described as latency-neutral.
Landing rationale: the real publication-owner proof removes a fetch and its connectivity child on every already-present commit, cutting median Git CPU 85.7%, largest-process RSS 81.4%, and owner wall time 71.2%, with preserved missing-commit/content behavior and +17 production lines. The full Gateway workload completed, CPU/GC did not show a consistent adverse A/B change, and the A/A controls expose the tail-measurement limitation. Historic pack growth and genuinely new-commit fetch cost remain outside this fix.
All stress arms, host load, tail sample counts and GC maxima
Base/candidate
Handler tails are interpolated from server Prometheus histogram bucket deltas. Timing runs are untraced; allocation-pass latency is context only. Host load is sampled every 30 seconds during each measurement window.
Major-GC tails are context only: fewer than 50 collections per arm. Minor-GC p99 also has fewer than 1,000 samples per arm; total GC time remains the relevant comparison.
Identical-baseline control
Handler tails are interpolated from server Prometheus histogram bucket deltas. Timing runs are untraced; allocation-pass latency is context only. Host load is sampled every 30 seconds during each measurement window.
Major-GC tails are context only: fewer than 50 collections per arm. Minor-GC p99 also has fewer than 1,000 samples per arm; total GC time remains the relevant comparison.
Timing stall-event counts in execution order were 0/6/7/3 for A/B and 5/15/24/200 for A/A; allocation-pass counts were 49/25/392/313. These events are retained, not filtered. Sampled allocation instrumentation affects timing, so its latency/GC rows are context rather than the untraced timing gate.
Final validation
Exact-head CI passed: CI, build artifacts, and security review. No CI reruns were requested. Source-closure checks: 22 passed. Existing managed Git maintenance performance tests: 16 passed, 1 skipped; this change does not alter maintenance bounds, interruption behavior or locking. One targeted scripts typecheck passed. No Testbox lease was used; focused local checks and PR CI supplied validation.