Skip to content

fix(worktrees): stop repeated cleanup of oversized results - #194642

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-idle-cleanup-overlimit-result-retry-loop-20260919
Nov 7, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-idle-cleanup-overlimit-result-retry-loop-20260919

Conversation

@steipete

@steipete steipete commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Related: #194475.

What Problem This Solves

Fixes repeated failed idle cleanup of the same oversized workspace result after the cleanup backoff expires.

User Impact

Operators get a durable cleanup deferral with the reserved result reference, retained guest-file location, and recovery instructions. Reduce and checkpoint the change, or recover it manually, then retry cleanup. The 768 MiB result cap, saved refs, and guest files remain intact. No configuration, schema, or retention change.

Why This Change Was Made

The existing checkpoint quarantine already prevents re-staging and applying a rejected result. Idle GC did not consume that terminal fact: it kept retrying removal, inspecting the checkout, and reporting a generic failure. GC now recognizes the rejection through recovery-error wrappers and records its existing cleanup disposition without a retry timer. The checkpoint owner remains authoritative; this adds no parallel rejection store or cache.

Evidence

A real managed-checkout/projection regression exceeds the actual aggregate cap, then checks one staging/removal attempt, durable rejection, visible recovery guidance, no retry timer, and retained files across three state reopenings. It fails on base ae0739da8acc9d2f2d8630533f19688da7e00a15 with a partial/failed cleanup and passes with the fix (4.14 seconds test time; 33.70 seconds including worker compilation). Eight existing GC-file tests also passed. Final focused run: all four GC/quarantine/aggregate-recovery tests passed in 38.39 seconds total across two shards. The aggregate-recovery test took 13.19 seconds because it exercises real oversized-file recovery. PR CI time: pending.

pnpm check:changed completed with two test-style lint errors (corrected; targeted lint passes) and one inherited changelog-attribution failure. All other stages passed, including core/test/script types, format, unused exports, database and import-cycle guards. Exact-base reproduction produces the same 20 forbidden-attribution findings. Commit 266a7aa0fe69e2b5fe6445c4ceb1e15b5360c957 (#194364) introduced those signatures by expanding the validator policy; its parent has zero of the current signatures (and a different older failure). This is an unresolved main gate regression, not ignored noise. No changelog files are changed here.

Codex autoreview of the complete staged change against that base is scoped-clean through P2, with no accepted/actionable findings. The review used the unchanged cleanup, checkpoint, and recovery owners as source context. Two subsequent mechanical test-lint corrections (variable name and braces) were verified with lint and the focused tests. Simplification kept only the existing-owner bridge: +23 runtime lines, justified by carrying the recorded rejection identity into GC's existing outcome; +64 regression lines have an exact scoped test-line allocation.

Synthetic workload, acceptance rule, A/A controls, and measurements

Acceptance written before measurement: one initial rejection, zero later removal/staging attempts, persistent actionable outcome and unchanged guest bytes/ref across process reopen. Advance only GC's selection clock by 25 hours per pass to exceed the previous maximum backoff; leave lease clocks and timers real. Compare wall time, main/process CPU, and exact main-thread V8 allocation, with no unexplained metric regression over 20%.

The existing committed benchmark now has a gc-overlimit mode. Each arm contains a synthetic repository with 64,389 files / 1,142,855,822 bytes, including 62,000 provisioned dependency files. The projection contains 2,420 files / 1,073,813,620 bytes, including 32 new 32 MiB result files; dependencies are excluded from projection publication. Setup is outside timing. Two identical-code baseline controls precede five serial interleaved baseline/candidate process pairs, with one reopen and one warm sweep per process.

Measurement (n=5 per arm) Baseline median / p95 Candidate median / p95
Warm GC: wall ms 5410.03 / 5555.07 8.83 / 8.96
Warm GC: main CPU ms 74.78 / 75.59 3.92 / 4.26
Warm GC: process CPU ms 6020.95 / 6092.61 11.28 / 11.48
Warm GC: main allocation MiB 41.30 / 47.16 3.10 / 4.19
First GC after process reopen: wall ms 7902.35 / 8792.57 965.21 / 1854.27
First GC after process reopen: main CPU ms 231.18 / 247.39 37.21 / 43.23
First GC after process reopen: process CPU ms 9583.78 / 10246.34 1362.01 / 1522.72
First GC after process reopen: main allocation MiB 154.58 / 160.57 11.27 / 13.75

Observed p95 is the maximum of five samples. Warm wall ranges: baseline 4,780.81–5,555.07 ms; candidate 6.26–8.96 ms. A/A warm controls were 4,642.18 / 6,274.95 ms (35% spread); reopen controls were 7,929.73 / 7,977.13 ms. Counts are the strongest evidence: all 10 baseline sweeps retried removal; all 10 candidate sweeps avoided removal and staging, retained the rejection/ref, and exposed recovery guidance without a retry timestamp. Neither arm restaged after quarantine.

Initial rejection was unchanged in shape (one sample/arm): wall 9,150.69→8,970.68 ms; main CPU 152.05→150.60 ms; process CPU 10,367.78→10,193.65 ms; allocation 132.11→137.80 MiB (+4.3%).

node --import ./scripts/tsx.mjs scripts/perf/worktree-removal-snapshot-measure.ts \
  --mode gc-overlimit --output <new-synthetic-directory> \
  --files 62000 --file-bytes 18432 --tracked 2388 --passes 2

Reopen each arm with --reuse-fixture --report <unique-name>.json. Baseline runs set OPENCLAW_BENCH_BASELINE_DIR to an overlay containing the two changed production files from the pinned base. Each arm retains its own fixture. Separate --cpu-prof diagnostic runs were excluded from aggregates.

Qualification: Node 26.12.1 on macOS/APFS, warmed filesystem cache and real owner/SQLite/Git operations. No btrfs, 35 GiB agent transcript DB, full Gateway/model, or session-transport claim. This owner does not read transcript payloads. Process CPU includes workers but excludes Git children; allocation is main-thread V8 allocation, not retained heap. Profiles covered the main thread only. The changed modules have no Control UI imports.

@clawsweeper

clawsweeper Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: M labels Nov 7, 2026
@steipete
steipete marked this pull request as ready for review November 7, 2026 14:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 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-07T14:29:50.994089Z fec3fde 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.

@steipete
steipete merged commit fcdb895 into main Nov 7, 2026
218 of 223 checks passed
@steipete
steipete deleted the steipete/perf-micro-idle-cleanup-overlimit-result-retry-loop-20260919 branch November 7, 2026 14:39
steipete added a commit that referenced this pull request Nov 7, 2026
* fix: keep ignored build outputs out of worker results

Apply standard Git exclusions at local and remote result capture while preserving tracked source, admitted paths, and accepted custody. Reuse the same capture owner during overflow recovery. Keep the result byte cap and recovery behavior from #194475 and #194642 unchanged.

* fix(workspaces): retain ignored artifacts and break capture cycle

* fix(workspaces): select capture scope at the caller

* fix(workspaces): preserve staged-input capture eligibility
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 8, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 8, 2026
* fix: keep ignored build outputs out of worker results

Apply standard Git exclusions at local and remote result capture while preserving tracked source, admitted paths, and accepted custody. Reuse the same capture owner during overflow recovery. Keep the result byte cap and recovery behavior from openclaw#194475 and openclaw#194642 unchanged.

* fix(workspaces): retain ignored artifacts and break capture cycle

* fix(workspaces): select capture scope at the caller

* fix(workspaces): preserve staged-input capture eligibility
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 gateway Gateway runtime scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant