Description
Relevant earlier discussion on #9473 .
v8::SnapshotCreator
is a means to capture a heap snapshot of JS, CodeGen, and C++ bindings and revive them w/o performing loading/evaluation steps that got to there. This issue is discussing what would be needed for tools like webpack
which run many times and have significant startup cost need in order to utilize snapshots.
- All C++ bindings available as
intptr_t
- C++ addon API/declaration to register external
intptr_t
s - CLI flags for
--make-snapshot
and--from-snapshot
- JS API to declare
main()
functions for snapshots (save tov8::Private::ForApi($main_symbol_name)
). - JS API to declare
vm.Context
for snapshot - Serializer for
- ArrayBuffer/TypedArrays
- HandleWrap
- ObjectWrap
- Timer
- STDIO
-
require.cache
paths?
- File format for snapshots
- C++ Addon inlining / symlinking
The v8 API might be able to have some changes made (LANDED)
Right now the v8 API would need a --make-snapshot
CLI flag since v8::SnapshotCreator
controls Isolate
creation and node would need to use the created isolate.
Since all JS handles need to be closed when creating the snapshot, a main()
function would need to be declared during snapshot creation after all possible preloading has occurred. The snapshot could then be taken when node exits if exiting normally (note, unref
'd handles may still exist).
Some utility like WarmUpSnapshotDataBlob
from v8 so that the JIT code is warm when loaded off disk also relevant.