You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src: let embedders supply a builtin code cache without a snapshot
Contexts and Environments created from the built-in snapshot get the
builtins' code cache from that snapshot. An embedder that bootstraps
them from scratch (its own isolate and context, no EmbedderSnapshotData)
has no way to provide one: every builtin the bootstrap touches, and the
per-context scripts NewContext() runs, are compiled from source in
every such process, and each of them then serializes a fresh cache
(SaveCodeCache) that only a later worker thread would ever consume.
Add a small public API for that case:
- node::GenerateBuiltinCodeCache(context) compiles every builtin in a
context of the right kind of isolate and returns the caches, for a
build step that embeds them.
- node::SetBuiltinCodeCache(entries) installs process-wide entries that
every BuiltinLoader created afterwards starts with, i.e. each
Environment's and the loader for the per-context scripts. Entries a
snapshot provides still merge on top (RefreshCodeCache() now merges
with insert_or_assign instead of assuming a single call).
- ProcessInitializationFlags::kNoHarvestBuiltinCodeCache stops
serializing caches for builtins compiled without one, for embedders
that supply their own or never create workers. The default is
unchanged because worker threads copy the harvested cache.
embedtest gains --builtin-code-cache-create, --builtin-code-cache and
--no-harvest-builtin-code-cache, and a test that generates a cache in
one process, checks that the bootstrap and per-context scripts of
another compile with it, and that a worker does or does not find a
harvested cache depending on the flag. On x64 Linux embedtest's
start-to-exit goes from ~64 to ~44 ms with a supplied cache; not
harvesting alone saves ~5 ms on a snapshot-less start and is a no-op
with the snapshot.
Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
0 commit comments