Repository navigation
fix: reduce standalone worker memory and startup cost - #183143
Conversation
Keep embedded module routes and file metadata encoded until a worker queries them. Preserve every alias and direct destination, decode requested rows once, and cache values within their own realm.
|
🦞👀 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 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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR decodes embedded routing and file metadata on demand instead of allocating complete lookup tables in every worker. Example: A standalone worker resolves dist/main.js.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR addresses measured standalone startup overhead that remains on main; no introduced correctness or security defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe standalone builder converts packaged module paths and metadata into executable bootstrap code consumed independently by the Gateway and its workers. flowchart LR
A[Packaged runtime modules] --> B[Standalone builder]
B --> C[Encoded routing and metadata]
C --> D[Gateway or worker bootstrap]
D --> E[Lookup and local cache]
E --> F[Existing module and metadata owners]
Technical reviewBest possible solution: Retain the shared lazy lookup emitter and existing resolution owners, then handle inherited fixture failures through the repository’s CI policy. Do we have a high-confidence way to reproduce the issue? Main visibly creates complete routing and metadata objects in each bootstrap; the PR reports controlled compiled-image measurements, but this read-only review did not reproduce the allocation measurements. Is this the best way to solve the issue? The patch addresses eager allocation at its build-time producer, preserves existing consumers and admission checks, and uses one shared emitter without introducing another runtime owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4ce728b934a2. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceTests +63, Docs +5, Other +53. Total +121 across 6 files. Added test files: 1. 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 24, 2026, 10:29 PM ET / October 25, 2026, 02:29 UTC. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Keep embedded module routes and file metadata encoded until a worker queries them. Preserve every alias and direct destination, decode requested rows once, and cache values within their own realm.
What Problem This Solves
Standalone Gateways pay unnecessary startup CPU and memory for large embedded routing maps in every worker.
User Impact
Workers allocate only the routing and metadata rows they use. Module aliases, direct embedded destinations, native dependency resolution, and file metadata retain their existing behavior. No configuration or migration is required.
Why This Change Was Made
Store sorted JSON-encoded rows as immutable embedded text, binary-search requested keys, and cache decoded values within each VM. This also removes the eager destination Set and the second eagerly materialized embedded-path dictionary.
Evidence
The same large routing map reproduced the penalty when compiled as JavaScript; 10,000 unused TypeScript interfaces did not. With a fixed compiler, the controlled memory slope fell from 104.66 to 9.11 MiB per worker. The full original-source desktop image retained all 145,971 aliases; its same-entry worker heap fell from 28.58 to 5.16 MiB (emitted-JS control: 4.96 MiB).
Eight interleaved samples per image on a loaded Mac, using the same frozen compiler:
The full-image comparison uses the original-source integration build; this PR ports the identical lookup implementation to current main's standalone owners. The rebased six-file patch is byte-identical to the independently reviewed patch. Focused validation: 69 tests pass; four existing metadata-fixture failures reproduce on unchanged main with identical signatures. Targeted lint, script/tooling typechecks, formatting, and diff checks pass.
The fixed TS image and matched emitted-JS baseline passed the frozen core campaign (fresh/reused config, Doctor contributions, Gateway/agent behavior, clean shutdown, and crash audit). One real Codex turn reused the existing login and completed its native hook plus exact-file proof. No engine changes or cross-VM mutable sharing are involved.
The only failed CI test job is checks-node-compact-small-1: the two secret-resolver fixture cases read missing
params.args, and the MXC/ACPX fixture cases lack theresolvePluginRuntimeProcessAssetUrl/resolvePackageRuntimeProcessEntrypointUrlbindings. These same four errors reproduce with unchanged main owners; the fixture and extracted owner inputs are unchanged by this PR. They remain failed and are being handled under the native inherited-failure landing policy.security-fastpassed independently.