Split workerd's bootstrap into process setup and a factory step #8929
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
bartlomieju
The motivation for this change is to let one process build more than one
worker factory. Today
bootstrap()sets up the process (perfetto, theasync trace file, tcmalloc, autogates, the test and bench modes, V8) and
builds a single
WorkerFactoryin one call, and attaches all of it tothat factory, so V8 is disposed together with it.
workerd replneedsV8 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 newfactory/per-process.{h,c++})sets up the process once, in the same order as before, and
newWorkerFactorybuilds a factory on it. Each factory holds areference 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,
bootstrapbecomes
process_startandfactory_new, whichserve,testandbenchcall once each. This is also the first step toward moving thisstartup 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
testandbenchoptions 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.