Repository navigation
perf(sandbox): attribute slow setup and reuse clean failed-install source - #181996
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. |
ffa4031 to
0c04ec6
Compare
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. |
|
0c04ec6 to
e47053f
Compare
a586f24 to
127ddf4
Compare
|
Codex review: needs maintainer review before merge. What this changesThis PR adds detailed sandbox setup timings and reuses validated source after dependency installation fails without changing tracked files. Example: A pnpm installation fails after leaving partial node_modules and .env.installer files but unchanged source.ts and pnpm-lock.yaml.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses a source-confirmed redundant checkout and useful setup attribution; no discrete correctness or security defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway chat dispatch prepares an agent workspace and sandbox, consuming managed-worktree templates and publishing request-scoped setup timings to slow-send diagnostics. flowchart TD
A[Gateway chat dispatch] --> B[Attempt workspace preparation]
B --> C[Sandbox owner]
C --> D[Dependency template owner]
D --> E[Source validation and cleanup]
C --> F[Recorded worktree timings]
F --> G[Slow send diagnostics]
B --> G
Technical reviewBest possible solution: Reuse the existing validator and timing owners while preserving full rebuilds for changed or unverified source. Do we have a high-confidence way to reproduce the issue? Source inspection confirms that main recreates source after every failed dependency installation, including clean failures; the PR reports red-to-green checkout-count and attribution regressions, but no target code was executed during this read-only review. Is this the best way to solve the issue? The patch follows the smallest complete approach: extend the existing validator to discard generated outputs, retain its tracked-source checks, and forward existing timing facts through the request observer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against be0519d983fb. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +90, Tests +93, Docs +70, Other +252. Total +505 across 16 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 23, 2026, 8:02 PM ET / October 24, 2026, 00:02 UTC. |
Expose attempt setup checkpoints and recorded worktree phase durations in slow chat send diagnostics. Preserve full rebuilds when installation changes tracked source. Add a reproducible cold-template and warm-turn Gateway workload.
127ddf4 to
2a85d12
Compare
|
@clawsweeper re-review Final head: |
|
🦞👀 Re-review progress:
|
…urce (openclaw#181996) * perf(sandbox): reuse clean source after dependency install failure Expose attempt setup checkpoints and recorded worktree phase durations in slow chat send diagnostics. Preserve full rebuilds when installation changes tracked source. Add a reproducible cold-template and warm-turn Gateway workload. * test(perf): exercise cold sandbox templates and attribute runtime pauses * fix(perf): type setup summaries and capture whole-workload loop tails
What Problem This Solves
Slow sandboxed chat startup can report tens of seconds under
attempt.setupwithout its nested worktree phases in the same line. A failed dependency installation also rebuilds the entire source checkout even when the installer left tracked files unchanged.User Impact
Slow-send diagnostics identify the setup work directly. Clean dependency-install failures reuse the validated source checkout after removing generated files; changed or unverified source still rebuilds. No configuration, schema, or authority changes.
Why This Change Was Made
A recent startup had
attempt.setup=67201msand a separate earlierworktree=23891ms. The sandbox owner already recorded 67198ms, including 42428ms of template preparation, 24666ms of accumulated checkout work, and a dependency install that failed in 442ms. Its unattributed time was only 16ms. These nested timings overlap and must not be summed.Request-owned checkpoints now separate setup policy, baseline waiting, workspace, skills, backend, and browser preparation. The worktree owner forwards its recorded durations as
detail.worktree.managed.*anddetail.worktree.sandbox.*; it does not remeasure them. Labels are fixed and elapsed timing is monotonic. The existing template validator removes partial dependencies and installer debris before reusing unchanged source, eliminating the second checkout in the clean-failure case.Historical owner attribution (milliseconds; inclusive parents and accumulated children overlap):
attempt.setupworktree.sandboxworktree.sandbox.reservationworktree.sandbox.templatePrepareworktree.sandbox.checkoutworktree.sandbox.templateApplyworktree.sandbox.synchronizeProjectionworktree.sandbox.snapshotworktree.sandbox.containerStartworktree.sandbox.workspaceLayoutworktree.sandbox.setupworktree.sandbox.unattributedThe earlier chat
worktree=23891mssurrounds a separate managed preparation (durationMs=23622,unattributedMs=61); it must not be subtracted fromattempt.setup. The repeated “Native image: sandbox validation failed” warning validates prompt image-file paths, not container images. It occurs outside this setup boundary, with no retry loop in that validation path, so this change does not alter it.Evidence
Measurement contract (recorded before paired runs)
Use a real isolated Gateway with synthetic model transport, 5,000 sessions, 6,000 retained runs, 5,000 distinct 4 KiB tracked files, managed worktrees, Podman session sandboxes, and synthetic plugin/Streamable HTTP MCP tools verified at the model boundary. Generate distinct same-tree commits so each of 32 cold samples per side prepares a cold dependency template; use four concurrent turns per 16-core side, keep the resident Gateway, and reuse the final four sessions for 200 warm turns. Report send-to-first-model-request p50/p99, sample counts, CPU, GC/work, promotion, loop tails and maximum pauses. Cold means session/template, not a fresh Gateway process.
Run concurrent pairs under one shared quiet lock and production guard, then swap interleaved CPU sets. Discard guard-interrupted pairs. Decide on paired means; reject at >=20% adverse mean or >=10% adverse in both pairs. Opposite-signed deltas or baselines differing by >5x are inconclusive, with absolute deltas and a third pair if gating. p99 needs 1,000 samples per side, p95 needs 200; smaller tails are context. Apply the GC collection-count, absolute pause-delta, and maximum-pause exceptions from the campaign rules.
The comparison uses candidate
127ddf47af7742f5e663a59baa3443bf97b70446and baseline production9538d3ab0bb5d1d5de262fe53ec0c24da0b2f0cc, with the same benchmark harness on both sides. Its continuous whole-workload histogram supplies event-loop p99 and count, including cold session creation between cohorts.Measurement and landing decision
Both model-bound catalogs contained the synthetic plugin and MCP tools. No dropped diagnostic events, histogram samples, or collection errors occurred. Interleaved 16-core sets and sandbox-container placement were verified. The common barrier produced measurement starts 1 ms apart; first-cohort admission differed by 22.23 ms. One high-load minute (67.36) recovered without meeting the shared guard's three-consecutive-minute abort rule; both drivers and the orchestrator exited 0. This is a qualified first pair, not a completed performance verdict.
The small 20 MiB tracked-source fixture makes checkout much cheaper than the historical production case. Do not extrapolate its absolute saving to production. Mean owner-unattributed time fell from 1,205.79 to 105.05 ms because quiesce/resume now have labels; that is attribution coverage, not latency saved.
paired measurement deferred: Team outage; simplification. The lead explicitly authorized landing this duplicate-work removal without further pairs under the updated decision rule. The valid first pair showed no qualifying regression; it is not a completed swapped-pair estimate.
The first swapped attempt timed out during the initial cold cohort on both sides before completing a round. Its partial data is retained and excluded. Owner logs show progress: final setup completed at 164.495s on baseline and 159.721s on candidate, leaving insufficient time under the 170s observation ceiling. The prepared retry uses fresh cold fixtures and an identical, independently reviewed benchmark-only overlay: setup-image provider/turn deadlines increase to 600s and RPC observation to 610s. Workload, timestamps, and product source stay unchanged; pair 1 never reached its original deadlines. Overlay driver SHA-256:
b16beddfcea43656c0f8c2f293bf5d1e66f9258921531e4d3eeafd27310a8302. The subsequent Team outage prevented the retry. The host has recovered, but no retry will run under the lead’s landing instruction; no complete swapped result exists.Captured live diagnostic signal
The real candidate sandbox emitted this synthetic slow-send excerpt during pair 1:
These are nested/inclusive facts, not additive buckets. New fields are verified in a running isolated Gateway, not yet in production. Production observation requires the normal deployment; this lane does not restart or deploy a production Gateway.
Initial CI run 40037827662 passed the production checks but found an implicit-array-type error in the benchmark's nested summary construction. Two direct summaries fix that inference error without changing the reported samples. Pre-rebase CI run 40039266721 passed all 88 jobs and verifies the repair. The required main rebase also brought a general chat diagnostic capture into this block; the independently reviewed resolution keeps ordinary chat and the dedicated attempt-setup capture correctly named and reported.
Changed-file lint/format, the
tsgo:corelane (native tsrs), export-name collision guard, and the two source-closure files passed (22 closure tests). Focused test wall time was 45.42s for attempt setup, 64.75s across the four recovery/timing files, and 26.73s for closure checks; this includes compilation. Broad tests are delegated to PR CI; no Testbox/Crabbox lease was used under the lane's compute policy.Runtime production delta is +90 lines: +81 for the explicitly requested continuous attribution and worktree-fact bridge, and +9 for source-only recovery while preserving the integrity rebuild. The deleted work is a complete second source checkout, not an alternate cached implementation. Benchmark fixtures and tests are separate from that runtime count.
The complete functional Gateway smoke passed plugin/MCP catalog assertions and a sandbox README read. It exercised a cold-template failed install and a warm reused sandbox. Added
runtimeQuiesce/runtimeResumetimings after that smoke exposed pause/resume work outside the existing worktree phases; both focused pause/resume behavior cases passed. These smoke timings are not paired performance evidence.The final main rebase resolved a conflict in adjacent benchmark summary fields by preserving both sets. Independent review and focused lint/format passed; range-diff confirms the runtime changes remained identical. All paired measurements use this final head. Exact-head CI completed with the inherited failure below.
Exact-head CI: inherited failure
Run 40041421575 completed all 88 jobs. The only failing leaf was checks-node-changed-compact-large-24: two
progress-card-refresh.integration.test.tscases, “steers duplicate active refreshes…” withunconfirmed=false/true, expected an accepted retry but receivedPROGRESS_CARD_REFRESH_TERMINAL. The aggregate CI gate failed downstream; other jobs passed.The same single file reproduced 2 failed / 7 passed on both PR head
127ddf47and unchanged main baseline9538d3ab, using CI's pinned OpenClaw Bun1.4.4-canary.1+ef37c31dein the isolated sandbox. Command:OPENCLAW_VITEST_RUNTIME=bun node scripts/run-vitest.mjs src/gateway/server-methods/progress-card-refresh.integration.test.ts --maxWorkers=1. No broad suite or CI rerun was used.Main's #181953 moved steering after ACK. This fixture still completes the target run immediately after ACK, before awaiting its
queueMessagecall, so the hidden refresh can fall back and settle without changing the card. The failing test, fixture, and causal dispatch/receipt owners are byte-identical on baseline, PR head, and CI's tested merge6dd740a1(main parent215cb73b). All gateway-method source files are also unchanged between the replayed main baseline and that CI parent. This PR's instrumentation adds no receipt mutation or await on that path. That prior-head failure was baseline-attributed; it is not a claim of green CI. Final rebased-head CI is checked separately below.Final landing head
Rebased cleanly onto main
40e0e5ab151484228a9f6072ee9a20ede6db3fed; final head2a85d12991c761cfefbc3c3b5e9712ff0b3531de. Range-diff shows only surrounding perf-fixture context changes; the reviewed runtime patch is unchanged. Measurements above remain evidence for the explicitly named pre-rebase source, not a claim of a new run. Exact-head CI run 40058889539 completed successfully: 62 jobs passed and 26 were skipped. The earlier baseline-attributed progress-refresh failures did not recur. Independent rebase review confirmed the runtime diff is byte-for-byte unchanged and found no actionable P0–P2 issues.