Skip to content

fix: reduce GitHub publication delays in fragmented clones - #195488

Merged
steipete merged 1 commit into
mainfrom
steipete/fix-publication-ref-completeness
Nov 9, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/fix-publication-ref-completeness

Conversation

@steipete

@steipete steipete commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes slow Control UI GitHub publication actions when a managed repository has thousands of refs and fragmented packs, even when fetching only a few new objects.

User Impact

Repeated publication acquisitions avoid Git's scan of unrelated session histories while preserving commit ancestry, trees, content hydration and shallow boundaries. No configuration or operator action is required. The first filtered fetch for a new publication URL retains Git's normal source-side promisor registration; acquisition without a cached base retains normal common-history discovery.

This improves the metadata acquisition phase. Content hydration remains a separate fetch when needed. Temporary metadata adds some JavaScript CPU and allocation; those costs are disclosed below and require owner acceptance before landing. This PR is intentionally unmerged.

Why This Change Was Made

The expensive phase is fetch-pack: mark_complete_local_refs, before negotiation. The negotiation tips from #195413 limit offered haves but do not remove that ref census. Publication now reuses the existing project-refresh transport: temporary bare Git metadata, copied shallow boundaries, and direct access to the authoritative object directory. Explicit cached-base tips preserve incremental negotiation. There are no pack copies, permanent alternates, new caches, configuration options, or ref-pruning policies.

The shared helper replaces the private project-refresh implementation and remains responsible for native initialization, shallow metadata and cleanup, including uncertain child-process settlement. Publication stages only after the exact URL is already a registered promisor. Codex review caught the importance of that condition: otherwise an ordinary full clone, or a different fork URL, could receive missing blobs without a persistent source-side promisor for later lazy hydration. The regression now exercises that case through real Git.

MIDX rebuilding is not restored: #182204 intentionally superseded #165858's whole-repository repair because it escaped maintenance budgets. Git ignores commit graphs while shallow. Blanket ref deletion would discard refs whose owning lifecycle has not established staleness.

Evidence

Synthetic local Git only; no production access or data. Parent: e673256f8a9351607912329020857906643a1c1c.

The committed fixture generates 13,536 refs, 1,609 packs, 263,693 packed objects, two shallow roots, blob:none and three stale commit-graph layers, without a MIDX. Git 2.56.0, Apple Silicon/APFS, file transport. It deliberately does not reproduce 800 million entries, thousands of linked worktrees, btrfs or application database size. Linked-worktree behavior is covered by the native regression.

python3 scripts/perf/publication-ref-completeness-fixture.py <fresh-root>

Five native samples per arm; p95 is the maximum. Staging setup is excluded here and included in the actual-owner measurements below.

Native fetch Wall median / p95 ms Completeness median ms Received objects / haves
Current argv 982 / 1127 751.541 2 / 1
MIDX 264 / 4858 184.180 2 / 1
Refreshed graph 989 / 1032 758.310 2 / 1
Disposable pruning to 3 refs 221 / 235 0.404 2 / 1
Staging with ordinary alternates 21494 / 30503 1608.476 2 / 263692
Staging, alternate refs suppressed 237 / 303 4.946 2 / 1
Direct shared object directory 256 / 307 0.144 2 / 1

The ordinary-alternates 21.5-second result is mainly negotiation (18.8 seconds), not completeness. Native A/A median drift was 2.98%. Large MIDX/A/A outliers are retained; five samples on a loaded host do not establish precise tail behavior. Both shallow graph writes returned success without changing the graph. A separate missing-parent nonshallow fixture failed both reachable and stdin-packs graph writes.

MIDX write on this small fixture took 170 ms wall / 150 ms CPU / 49.8 MiB RSS. At 800 million SHA-1 pack entries, index input alone is roughly 22.4 GB. Output and retained entry memory depend on unique objects, not duplicated pack entries: about 28 and 64 bytes per unique OID respectively, before allocator/sort/mapping overhead. Crude scaling from the small fixture gives minutes, not a request-safe bound; it does not justify reintroducing an unbounded maintenance rewrite.

Actual-owner proof uses the committed publication-fetch-measure.ts, warmed spawn broker and real publication owner, rewriting only the synthetic GitHub URL to the file remote. Point the fixture's seed symlink at its base directory; save the parent's transport module for --base-file.

node --import ./scripts/tsx.mjs scripts/perf/publication-fetch-measure.ts \
  --fixture <fixture> --output <fresh-output> --contents

Use --base-file <parent-transport.ts> for A and --allocation for separate heap-sampling runs. Acceptance: remove unrelated-ref reads, preserve ancestry/content and received-object counts, and reduce owner wall/native CPU while disclosing setup overhead.

Five final counterbalanced A/B pairs and five separate allocation pairs, with changed-file/type/review checks active on the host (load approximately 17–26):

Actual owner, contents Baseline median / p95 Candidate median / p95
Wall ms 1337 / 3847 634 / 2409
Native CPU ms 1200 / 2290 450 / 1690
Native peak RSS MiB 61.27 / 61.72 32.45 / 32.55
JS CPU ms 17.01 / 22.67 28.08 / 47.78
Sampled allocation bytes, separate runs 2506544 / 2580000 4092312 / 4143648

Both versions made two fetches, received three objects / 290 installed pack bytes, and offered one have. Completeness median: 715.491 → 0.123 ms. Median owner wall improves 52.6%, native CPU 62.5%, native RSS 47.0%. The cost is +11.07 ms JS CPU and +1.51 MiB sampled allocation per absent commit; the present-commit fast path is unchanged. This is a material measured tradeoff, not an all-metrics improvement.

Prior A/A controls on the unchanged baseline: median wall 1687 versus 1666 ms (1.25% drift), completeness 771.8 versus 786.5 ms. A retained 8582 ms A/A outlier and the final baseline 3847 ms and candidate 2409 ms outliers limit tail conclusions. Native CPU includes local upload-pack children. Node CPU profiles and Git Trace2 were collected; no claim of production endpoint timing or main-thread stall elimination is made.

The real-Git regression fails on the pinned parent in both full and shallow modes because acquisition reads an unrelated session pack. The corrected owner suite passes 24 tests, including a linked worktree, uncached-base discovery and ordinary full-clone lazy hydration. The final frozen-source run passes 32 suites / 604 tests, with 23 existing skips, including all 28 publication suites (523 passing tests), project clone/runtime/registry, native fetch and Doctor clone-shape coverage:

node scripts/run-vitest.mjs src/gateway/github-publication*.test.ts   src/projects/project-clone-runtime.test.ts src/agents/worktrees/git-fetch.test.ts   src/projects/project-registry.test.ts src/commands/doctor-project-clone-shape.test.ts   --maxWorkers=4

pnpm check:changed --base e673256f8a9351607912329020857906643a1c1c passes all checks except the inherited changelog-attribution gate described below. Core/test/script types, lint, format, production/full-tree Knip, SQLite and other guards pass. The separate test-line ratchet passes without an allocation increase.

Final-source Codex autoreview is clean at P0–P2 after fixing the promisor-registration issue and checking buffered cleanup propagation, including the optional-Error narrowing required by lint. The measurement source is pinned; a final-source smoke after that narrowing preserves 2 fetches/3 objects/1 have and measures 0.115 ms completeness.

Known inherited gate: changelog attribution rejects 20 existing automation-credit lines on exported exact-parent inputs. The current policy is from #194364 (266a7aa0fe69e2b5fe6445c4ceb1e15b5360c957). The preceding policy also fails on different human-credit lines; this is an unresolved main gate, not a passing check or a PR-caused change.

Production delta: +51 net lines: the shared helper replaces the project-only staging implementation; remaining growth preserves native Git initialization/cleanup, source promisor registration and no-tip discovery. Tests: +33 net lines, extending the existing real-Git case; no new test allocation is needed (6,588,335 lines against a 6,588,350 ceiling). No Control UI-imported module changed.

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review ended

ClawSweeper stopped reviewing this revision because the pull request closed.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: L labels Nov 9, 2026
@steipete
steipete marked this pull request as ready for review November 9, 2026 01:01
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 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-09T01:04:04.243018Z 0fa9eac 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 the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Nov 9, 2026
@steipete
steipete merged commit 3908a3e into main Nov 9, 2026
217 of 221 checks passed
@steipete
steipete deleted the steipete/fix-publication-ref-completeness branch November 9, 2026 01:12
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant