Skip to content

host: fix source-mode worker startup churn (esbuild-bundle the worker entry once)#857

Open
brandonpayton wants to merge 1 commit into
mainfrom
fix/source-mode-worker-startup-churn
Open

host: fix source-mode worker startup churn (esbuild-bundle the worker entry once)#857
brandonpayton wants to merge 1 commit into
mainfrom
fix/source-mode-worker-startup-churn

Conversation

@brandonpayton

Copy link
Copy Markdown
Member

What

In source checkouts (no host/dist/*.js), every guest process spawns a fresh tsx loader for its worker entry (~500ms bootstrap each). Homebrew forks/spawns hundreds of short-lived subprocesses per command (git, curl, ruby, shells), and under that concurrency the per-worker tsx path stalls — "source-mode worker startup churn." This was a real contributor to the brew config/doctor timeouts observed in the brew-in-Kandelo probes.

Fix

NodeWorkerAdapter gains a middle load path: when running from source, bundle the .ts worker entry once with esbuild into a single cached .mjs, and launch all workers from that prebuilt bundle. Load order becomes compiled-dist → esbuild-bundle-once → tsx-fallback. Only affects source-mode dev/probe runs; production/dist is unchanged. No guest-observable behavior change, no ABI change. Adds esbuild (devDependency) and a node-worker-adapter.test.ts.

Context

This is the one host fix from the brew-in-Kandelo frontier (originally on the kd-9jd worktree) not yet on main; every other scattered fix has already been independently merged. It's folded into the Track B2 brew-bootstrap re-verification branch. Opening standalone for review.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

@brandonpayton

Copy link
Copy Markdown
Member Author

Verification: host/test/node-worker-adapter.test.ts passes locally under the dev-shell (Vitest 4, 1 test, 68ms). Full source-mode benefit is exercised by the Track B2 brew-bootstrap re-verification (many-worker Homebrew workload) on the same branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant