Repository navigation
perf(code-mode): share prepared catalog bytes with Node workers - #169045
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: needs maintainer review before merge. What this changesThis PR prepares catalog metadata once per snapshot and shares its encoded bytes with Node Code Mode workers. Example: Repeated Code Mode executions with the reported 109-tool catalog.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-directed optimization removes repeated catalog preparation that remains on main, and the introduced diff has no actionable correctness finding. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherCode Mode receives a policy-filtered tool catalog and JavaScript cell, prepares guest metadata, executes it in a worker, and routes tool requests through the existing host authority. flowchart LR
A[Policy filtered catalog] --> B[Prepared catalog snapshot]
B --> C[Shared metadata bytes]
C --> D[Node worker]
E[Cell source and current limits] --> D
D --> F[Fresh guest context]
F --> G[Host tool dispatch]
G --> F
Technical reviewBest possible solution: Land the catalog-owned shared-byte optimization after the existing required gates pass. Do we have a high-confidence way to reproduce the issue? Current-main source establishes repeated metadata preparation and serialization; the PR reports comparative production-path measurements, which were not rerun during this read-only review. Is this the best way to solve the issue? The snapshot owner is the appropriate reuse boundary, and retaining per-call limits plus fresh encoding for public inputs avoids stale mutable-input behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 48a348028fb0. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +72, Tests +81. Total +153 across 9 files. Added test files: 0. View PR surface stats
Review metrics
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 11, 2026, 5:51 AM ET / 09:51 UTC. |
First-parent upstream fd0fc62..f4f4868 (8 commits: openclaw#169033 collaboration/workshop SQLite bookkeeping, 952c102, openclaw#155464 active turns during worker dispatch, openclaw#168995 approval/placement queries, openclaw#154286 telegram polling workers, 194a08e, openclaw#169045 code-mode catalog bytes, openclaw#159697 talk voice permissions). Conflicts: - session-sharing-store.native.ts: upstream folded the member lookup and delete into one DELETE ... RETURNING with a no-row early return; our recipient-authority advance now follows that return, so only an actual removal revokes access (same order as before the merge). - worker-access inventory: took upstream, regenerated (632 files, 2442 calls). sharing-store receipt/worker auto-merged: upstream's category plan (keys only) is disjoint from our authority.capture command. Refs #1475 Co-Authored-By: Claude Opus 5.5 <[email protected]>
What Problem This Solves
Node Code Mode serialized the entire tool catalog, namespace descriptors, and API declaration files on the Gateway thread for every
exec, including repeated cells in the same catalog generation.User Impact
Less Gateway main-thread work for repeated Code Mode calls. Tool visibility, execution permissions, fresh guest contexts, and per-call time/output/concurrency limits retain their existing behavior. No config or stored-data migration.
Why This Change Was Made
Prepare metadata and its UTF-8 shared buffer at the core-owned catalog snapshot boundary. Carry that snapshot through execution and send the shared buffer with each small execution payload. The worker decodes it into a fresh guest context. Catalog replacement/restriction produces a new snapshot; swarm availability still resolves per call.
The Node worker no longer stringifies initialization metadata per cell. Public executor inputs retain their mutable-input contract and are encoded anew when no core-prepared snapshot is supplied. This contract requires an explicit distinction between immutable core snapshots and public inputs; production LOC is +72: the immutable byte representation and the preserved mutable public-input contract require explicit preparation and transport typing. Repeated per-cell metadata preparation and worker stringify are removed.
Evidence
execpath; model/provider and HTTP latency are excluded. Main-thread CPU usesprocess.threadCpuUsage, excluding worker CPU. After 1,000 warmup calls, the median of three 1,000-execution batches dropped from 1,787 ms to 1,015 ms main-thread CPU (1.76×, 43% less). Median worker-post time dropped from 401 ms to 221 ms. Median wall time was 6.62 s → 6.07 s. End-process RSS was 2.53 GB → 2.76 GB; no memory reduction is claimed. The shared rig had background startup work: CPU samples were 1,992/1,787/1,694 ms before and 2,792/1,015/995 ms after. These are comparative medians, not isolated latency promises.--maxWorkers=1; export-name collision guard and both closure suites passed (20 tests). The initial broad gate included a temporary baseline fixture and was canceled; it is not counted as a passing gate. The clean staged gate on the rebased tree hits an inheritedmax-linesratchet failure in untouchedsrc/web-search/runtime.test.ts;node --import ./scripts/tsx.mjs scripts/check-max-lines-ratchet.mts --staged --base HEADreproduces the same failure on pristine mainfd1fd2ce0ef8. The remaining native gate commands were continued without hiding that failure, then the duplicate typecheck run was stopped once exact-head CI passed the corresponding production/test types, lint, architecture guards, and behavioral checks. The local gate is not claimed green. Blacksmith Testboxtbx_01m4mwzmp9djbyrc8pswgspxb9admission remained queued; the authorized AWS fallback iscbx_ad17bbd3133e(c7a.4xlarge). A fresh AWS lease fell back to an unusable 2 GB instance; Hetznercbx_eb4ba0d26af3then stalled during sync. Final validation uses the authorized Linux rig fallback with its index tree verified identical tod38d2b2798df. All leases were stopped.d38d2b2798df74b88a411f320ac5730d62d02580; all required checks and security review are green.