← Back to Pull requests

Split workerd's bootstrap into process setup and a factory step #8929

Closed
unknown closed this pull request without merging on Nov 30, 2026 11:50 UTC
View on GitHub
unknown unknown commented on Nov 26, 2026 00:38 UTC
Author

The motivation for this change is to let one process build more than one
worker factory. Today bootstrap() sets up the process (perfetto, the
async trace file, tcmalloc, autogates, the test and bench modes, V8) and
builds a single WorkerFactory in one call, and attaches all of it to
that factory, so V8 is disposed together with it. workerd repl needs
V8 that lives as long as the process and a factory for each config it
loads, so it keeps its own copy of this setup. This change splits the
bootstrap in two. ProcessState (the new factory/per-process.{h,c++})
sets up the process once, in the same order as before, and
newWorkerFactory builds a factory on it. Each factory holds a
reference to the process, so V8 is torn down, the async trace file ended
and the perfetto trace flushed only after the last factory is gone, and
a second start fails once V8 has started. In the bridge, bootstrap
becomes process_start and factory_new, which serve, test and
bench call once each. This is also the first step toward moving this
startup code to Rust: with the split in place, reading the config's
settings and mapping the command's options can move to Rust in a
separate change.

Behaviour doesn't change: C++ still reads the autogates and V8 flags
from the config, and applies the test and bench options as before.
The one difference in order is that each factory now builds its own I/O
(the loop's timer, the kj-rs-io network, the monotonic clock, the
filesystem and entropy) after V8 starts rather than before perfetto, and
drops it right after itself rather than after the perfetto trace is
flushed. These objects hold no state, log nothing and can't be reached
from a Worker, so the difference isn't observable. Tested with
server-test, the server and command-line crates' unit tests, the
async-trace tests (including perfetto), the structured-logging and REPL
tests, and wd_test and wd_bench targets in their all-autogates,
all-compat-flags, gc-stress and smoke variants.

Diff: 250 lines (+187 / -63) across 3 files Reviewer: bartlomieju Review duration: 6432m
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.39) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 250 lines diff across 3 files
0.39
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
56%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.331
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8929"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 56.8% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 39.0% (MEDIUM) · Higher = larger blast radius
39.0%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 56.8% · Lower = rushed or shallow review
56.8%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 16.9% · Safe to merge
16.9%