Repository navigation
perf(crabbox): warm the node runtime at boot on warm-image forks - #169886
Conversation
Forks of a warm image load EBS blocks lazily on first read, so a cold node start spent ~30 s on serial reads (fresh fork: openclaw --version 4.1 s, node --help 26.5 s; after a parallel read of the 551 MB runtime both are under 1 s). The enrollment script now records the current runtime and Node install directories and installs an idempotent @reboot crontab entry that reads them in parallel, so later forks warm the runtime while SSH readiness and Crabbox run setup are still pending. Linux only and best effort: images without cron keep the cold start.
|
🦞👀 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: needs changes before merge. What this changesThis PR installs a Linux reboot hook that warms cached worker-runtime files while a cloud worker boots. Example: An AWS worker boots from an image captured with the hook.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR open: the startup optimization has clear value, and the lease check resolves two earlier findings, but the system-wide prefetch defect still needs repair. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherThe Crabbox plugin turns Gateway provisioning requests into remote runtime preparation, image capture, and fresh node enrollment. flowchart LR
A[Gateway provisioning] --> B[Crabbox setup script]
B --> C[Verified runtime cache]
B --> D[Linux reboot hook]
C --> E[Captured image]
D --> E
E --> F[Boot and prefetch]
F --> G[Node enrollment]
Technical reviewBest possible solution: Keep the boot-time overlap, but prefetch only the verified worker runtime and resolved Node executable. Do we have a high-confidence way to reproduce the issue? Source deterministically establishes the /usr traversal for system-installed Node, supported by Crabbox's non-amd64 installation path; the reported AWS timings were not rerun. Is this the best way to solve the issue? Overlapping runtime reads with boot addresses the measured disk bottleneck in the existing plugin owner, but traversing a system installation prefix adds unrelated I/O. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d6bcf79466f1. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +17. Total +17 across 1 file. Added test files: 0. View PR surface stats
LabelsLabel changes: No label 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 (2 earlier review cycles)
Reviewed October 12, 2026, 9:53 AM ET / 13:53 UTC (Revision 3). |
…ox lease Linux CI ran the enrollment script locally, so the hook wrote prefetch files beside the runtime and edited the runner's crontab. Gate it on Crabbox's reserved CRABBOX_LEASE_ID matching the script's lease (set by crabbox run since v0.41.1).
…nclaw#169886) Forks of a warm image load EBS blocks lazily on first read, so a cold node start spent ~30-40 s on serial reads before first contacting the Gateway (fresh fork: openclaw --version 4.1 s, node --help 26.5 s; under 1 s after a parallel read). Inside its Crabbox lease (CRABBOX_LEASE_ID matches), the Linux enrollment script now records the current runtime and Node install directories and installs an idempotent @reboot crontab entry that reads them with 64 parallel readers, so later forks warm the runtime while SSH readiness and Crabbox run setup are still pending. Best effort; images without cron keep the cold start; local executions such as tests never touch the crontab. Live AWS: node launch to first Gateway contact 37-44 s -> 2-3 s; warm time to active 70.9 / 98.2 / 73.9 s (was 111-135 s; the 98 s sample had a 57.9 s EC2 fork).
What Problem This Solves
Fixes: a cloud worker forked from a warm image spends about 30–40 s starting its node before it first contacts the Gateway, because every first read of the forked disk loads its block lazily from the snapshot.
User Impact
User impact: warm cloud-session starts should become active up to about 30 s sooner on AWS, once the profile's warm image has been captured with this build. Cold starts are unchanged. Images without cron keep today's behavior.
Why This Change Was Made
A live trace of warm AWS starts showed node launch to first Gateway contact taking 37–44 s, and one lucky run took 8.7 s. On a kept box, the node used little CPU, while the disk had spent 132 s waiting on reads since boot. A/B on two fresh forks of the same image:
openclaw --versionopenclaw node --helpPrefetching inside the enrollment script would only move that time around. Instead, the enrollment script now writes a small Linux-only boot hook into the machine-level cache, which the image scrub already keeps:
~/.openclaw-worker/node-runtimes/.prefetchlists the current runtime and Node install directories..prefetch.shreads them with 64 parallel readers and records start and end times.@rebootcrontab entry runs it.Every later fork starts warming its disk the moment it boots. That overlaps the roughly 24 s SSH-readiness wait and the Crabbox run setup that come before the node launches.
Best effort throughout. Any failure is swallowed, non-Linux targets skip the hook, unrelated crontab entries are preserved, and the files contain only paths and timestamps.
Evidence
pnpm test extensions/crabbox/src/crabbox-worker-node-enrollment.test.ts --maxWorkers=1: 26/26 pass. These tests execute the generated script.node --check).@reboot), finished at T+44.6 s, and the node launched at T+42 s.