-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Node.js embedder objects and bindings in the snapshot #37476
Comments
I'll be looking into the ones in |
cc @nodejs/startup |
ModuleWrap is blocked on v8:10855 |
So we have to do some division of labor? |
@XadillaX Just a FYI and to avoid stepping on each other's toes :) I suppose the majority of the list should be crossed out as invalid so there isn't actually that much work to do. Maybe it would be good to have a call about the list to figure out what should be excluded, or maybe discussing in the thread is already enough. |
Maybe a good place to start is to document (that is, adding comments about) exactly what these classes are and what their fields are for. |
Print information relevant to snapshot building at the environment exit when NODE_DEBUG_NATIVE is set to include mksnapshot. This helps us understand what need to be fixed to build a snapshot when a script is run to completion. PR-URL: #37967 Refs: #37476 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
@joyeecheung the OP probably needs an update. |
Fwiw, Blob objects likely should not be serialized. They should not live beyond the process in which they were created. |
Put the hrtime backing store in the process methods binding data so that it can be integrated into the snapshot builder. For now we simply discard the contents of the hrtime buffer during serialization and create new buffers upon deserialization because the contents are only useful in a synchronous call. This also moves the helper function for creating V8 FastAPI methods into `Environment::SetFastMethod()` for code reuse. The v8::CFunction need to be created before the Environment is created so that we have the CTypeInfo address available for external reference registration. PR-URL: #40649 Refs: #35711 Refs: #37476 Reviewed-By: James M Snell <jasnell@gmail.com>
Put the hrtime backing store in the process methods binding data so that it can be integrated into the snapshot builder. For now we simply discard the contents of the hrtime buffer during serialization and create new buffers upon deserialization because the contents are only useful in a synchronous call. This also moves the helper function for creating V8 FastAPI methods into `Environment::SetFastMethod()` for code reuse. The v8::CFunction need to be created before the Environment is created so that we have the CTypeInfo address available for external reference registration. PR-URL: #40649 Refs: #35711 Refs: #37476 Reviewed-By: James M Snell <jasnell@gmail.com>
Put the hrtime backing store in the process methods binding data so that it can be integrated into the snapshot builder. For now we simply discard the contents of the hrtime buffer during serialization and create new buffers upon deserialization because the contents are only useful in a synchronous call. This also moves the helper function for creating V8 FastAPI methods into `Environment::SetFastMethod()` for code reuse. The v8::CFunction need to be created before the Environment is created so that we have the CTypeInfo address available for external reference registration. PR-URL: #40649 Refs: #35711 Refs: #37476 Reviewed-By: James M Snell <jasnell@gmail.com>
Put the hrtime backing store in the process methods binding data so that it can be integrated into the snapshot builder. For now we simply discard the contents of the hrtime buffer during serialization and create new buffers upon deserialization because the contents are only useful in a synchronous call. This also moves the helper function for creating V8 FastAPI methods into `Environment::SetFastMethod()` for code reuse. The v8::CFunction need to be created before the Environment is created so that we have the CTypeInfo address available for external reference registration. PR-URL: #40649 Refs: #35711 Refs: #37476 Reviewed-By: James M Snell <jasnell@gmail.com>
This patch enables internal/options to be included in the snapshot, so that when lazy loading the run time options, the modules only need to make sure that the options are queried lazily and do not have to lazy load the internal/options module together. We can still guarantee that no run time options are serialized into the state-independent bootstrap snapshot with the assertion inside GetCLIOptions(). PR-URL: #42203 Refs: #37476 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
To lazy load the run time options, the following properties are updated from value properties to accessor properties whose getter would turn them back to a value properties upon the initial access. - crypto.constants.defaultCipherList - crypto.pseudoRandomBytes - crypto.prng - crypto.rng PR-URL: #42203 Refs: #37476 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Instead of iterating over the bindings, iterate over the base objects that are snapshottable. This allows us to snapshot base objects that are not bindings. In addition this refactors the InternalFieldInfo class to eliminate potential undefined behaviors, and renames it to InternalFieldInfoBase. The {de}serialize callbacks now expect a InternalFieldInfo struct nested in Snapshotable classes that can be used to carry serialization data around. This allows us to create structs inheriting from InternalFieldInfo for Snapshotable objects that need custom fields. PR-URL: #44192 Refs: #37476 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Instead of iterating over the bindings, iterate over the base objects that are snapshottable. This allows us to snapshot base objects that are not bindings. In addition this refactors the InternalFieldInfo class to eliminate potential undefined behaviors, and renames it to InternalFieldInfoBase. The {de}serialize callbacks now expect a InternalFieldInfo struct nested in Snapshotable classes that can be used to carry serialization data around. This allows us to create structs inheriting from InternalFieldInfo for Snapshotable objects that need custom fields. PR-URL: #44192 Refs: #37476 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Instead of creating an object template for every ContextifyContext, we now create one object template that can be reused by all contexts. The native pointer can be obtained through an embdder pointer field in the creation context of the receiver in the interceptors, because the interceptors are only meant to be invoked on the global object of the contextified contexts. This makes the ContextifyContext template context-independent and therefore snapshotable. PR-URL: #44252 Refs: #44014 Refs: #37476 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Access to the global object from within a vm context is intercepted so it's slow, therefore we should try to avoid unnecessary access to it during the initialization of vm contexts. - Remove the Atomics.wake deletion as V8 now does not install it anymore. - Move the Intl.v8BreakIterator deletion into the snapshot. - Do not query the Object prototype if --disable-proto is not set. This should speed up the creation of vm contexts by about ~12%. PR-URL: #44252 Refs: #44014 Refs: #37476 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Instead of iterating over the bindings, iterate over the base objects that are snapshottable. This allows us to snapshot base objects that are not bindings. In addition this refactors the InternalFieldInfo class to eliminate potential undefined behaviors, and renames it to InternalFieldInfoBase. The {de}serialize callbacks now expect a InternalFieldInfo struct nested in Snapshotable classes that can be used to carry serialization data around. This allows us to create structs inheriting from InternalFieldInfo for Snapshotable objects that need custom fields. PR-URL: nodejs#44192 Refs: nodejs#37476 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Move util::WeakReference to a separate header and implement {de}serialization for it to be snapshotable. PR-URL: nodejs#44193 Refs: nodejs#44014 Refs: nodejs#37476 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
PR-URL: nodejs#44193 Refs: nodejs#44014 Refs: nodejs#37476 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Instead of creating an object template for every ContextifyContext, we now create one object template that can be reused by all contexts. The native pointer can be obtained through an embdder pointer field in the creation context of the receiver in the interceptors, because the interceptors are only meant to be invoked on the global object of the contextified contexts. This makes the ContextifyContext template context-independent and therefore snapshotable. PR-URL: #44252 Refs: #44014 Refs: #37476 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Access to the global object from within a vm context is intercepted so it's slow, therefore we should try to avoid unnecessary access to it during the initialization of vm contexts. - Remove the Atomics.wake deletion as V8 now does not install it anymore. - Move the Intl.v8BreakIterator deletion into the snapshot. - Do not query the Object prototype if --disable-proto is not set. This should speed up the creation of vm contexts by about ~12%. PR-URL: #44252 Refs: #44014 Refs: #37476 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Instead of iterating over the bindings, iterate over the base objects that are snapshottable. This allows us to snapshot base objects that are not bindings. In addition this refactors the InternalFieldInfo class to eliminate potential undefined behaviors, and renames it to InternalFieldInfoBase. The {de}serialize callbacks now expect a InternalFieldInfo struct nested in Snapshotable classes that can be used to carry serialization data around. This allows us to create structs inheriting from InternalFieldInfo for Snapshotable objects that need custom fields. PR-URL: nodejs#44192 Refs: nodejs#37476 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Move util::WeakReference to a separate header and implement {de}serialization for it to be snapshotable. PR-URL: nodejs#44193 Refs: nodejs#44014 Refs: nodejs#37476 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
PR-URL: nodejs#44193 Refs: nodejs#44014 Refs: nodejs#37476 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Instead of creating an object template for every ContextifyContext, we now create one object template that can be reused by all contexts. The native pointer can be obtained through an embdder pointer field in the creation context of the receiver in the interceptors, because the interceptors are only meant to be invoked on the global object of the contextified contexts. This makes the ContextifyContext template context-independent and therefore snapshotable. PR-URL: nodejs#44252 Refs: nodejs#44014 Refs: nodejs#37476 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Include a minimally initialized contextify context in the embedded snapshot. This paves the way for user-land vm context snapshots. PR-URL: nodejs#44252 Refs: nodejs#44014 Refs: nodejs#37476 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Access to the global object from within a vm context is intercepted so it's slow, therefore we should try to avoid unnecessary access to it during the initialization of vm contexts. - Remove the Atomics.wake deletion as V8 now does not install it anymore. - Move the Intl.v8BreakIterator deletion into the snapshot. - Do not query the Object prototype if --disable-proto is not set. This should speed up the creation of vm contexts by about ~12%. PR-URL: nodejs#44252 Refs: nodejs#44014 Refs: nodejs#37476 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Instead of iterating over the bindings, iterate over the base objects that are snapshottable. This allows us to snapshot base objects that are not bindings. In addition this refactors the InternalFieldInfo class to eliminate potential undefined behaviors, and renames it to InternalFieldInfoBase. The {de}serialize callbacks now expect a InternalFieldInfo struct nested in Snapshotable classes that can be used to carry serialization data around. This allows us to create structs inheriting from InternalFieldInfo for Snapshotable objects that need custom fields. PR-URL: nodejs#44192 Refs: nodejs#37476 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Move util::WeakReference to a separate header and implement {de}serialization for it to be snapshotable. PR-URL: nodejs#44193 Refs: nodejs#44014 Refs: nodejs#37476 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Instead of iterating over the bindings, iterate over the base objects that are snapshottable. This allows us to snapshot base objects that are not bindings. In addition this refactors the InternalFieldInfo class to eliminate potential undefined behaviors, and renames it to InternalFieldInfoBase. The {de}serialize callbacks now expect a InternalFieldInfo struct nested in Snapshotable classes that can be used to carry serialization data around. This allows us to create structs inheriting from InternalFieldInfo for Snapshotable objects that need custom fields. PR-URL: #44192 Refs: #37476 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Instead of iterating over the bindings, iterate over the base objects that are snapshottable. This allows us to snapshot base objects that are not bindings. In addition this refactors the InternalFieldInfo class to eliminate potential undefined behaviors, and renames it to InternalFieldInfoBase. The {de}serialize callbacks now expect a InternalFieldInfo struct nested in Snapshotable classes that can be used to carry serialization data around. This allows us to create structs inheriting from InternalFieldInfo for Snapshotable objects that need custom fields. PR-URL: #44192 Refs: #37476 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Instead of iterating over the bindings, iterate over the base objects that are snapshottable. This allows us to snapshot base objects that are not bindings. In addition this refactors the InternalFieldInfo class to eliminate potential undefined behaviors, and renames it to InternalFieldInfoBase. The {de}serialize callbacks now expect a InternalFieldInfo struct nested in Snapshotable classes that can be used to carry serialization data around. This allows us to create structs inheriting from InternalFieldInfo for Snapshotable objects that need custom fields. PR-URL: #44192 Refs: #37476 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Here is a list of embedder object classes we have in core. In order to make userland snapshot possible (#35711) we should support as many as possible of them.
Some of them can't simply be deserialized - for example, the
HandleWrap
s, because theoretically we can't resurrect auv_handle_t
from a snapshot, at best we can restore them by creating new ones, but that involves more work (which is system-specific) than "just deserialize the object". Some of them may be helper singletons that we can just throw away at serialization time and recreate upon deserialization, and some of them may not be supposed to be supported.class HistogramBase : public BaseObject
: src/histogram.hclass ModuleWrap : public BaseObject
: src/module_wrap.hclass Blob : public BaseObject
: src/node_blob.hclass BlobBindingData : public BaseObject
: src/node_blob.hclass MicrotaskQueueWrap : public BaseObject
: src/node_contextify.hclass ContextifyScript : public BaseObject
: src/node_contextify.hclass CompiledFnEntry final : public BaseObject
: src/node_contextify.hclass BindingData : public BaseObject
: src/node_http_parser.ccclass ConverterObject : public BaseObject
: src/node_i18n.hclass JSTransferable : public BaseObject
: src/node_messaging.hclass FastHrtime : public BaseObject
: src/node_process_methods.cc (WIP at bootstrap: implement run-time user-land snapshots via --build-snapshot and --snapshot-blob #38905)class SerializerContext : public BaseObject
: src/node_serdes.ccclass DeserializerContext : public BaseObject
: src/node_serdes.ccclass SnapshotableObject : public BaseObject
: src/node_snapshotable.hclass NodeCategorySet : public BaseObject
: src/node_trace_events.ccclass WeakReference : public BaseObject
: src/node_util.cc: src: support WeakReference, diagnostics_channel and net in the snapshot #44193class WASI : public BaseObject
: src/node_wasi.hThe following are probably less likely to need support since they involve some kind of asynchronous state or references to opened system handles.
class Http2State : public BaseObject
: src/node_http2_state.hclass AsyncWrap : public BaseObject
: src/async_wrap.hclass PromiseWrap : public AsyncWrap
: src/async_wrap.ccclass ChannelWrap : public AsyncWrap
: src/cares_wrap.ccclass QueryWrap : public AsyncWrap
: src/cares_wrap.ccclass HandleWrap : public AsyncWrap
: src/handle_wrap.hclass HeapSnapshotStream : public AsyncWrap
: src/heap_utils.ccclass JSBindingsConnection : public AsyncWrap
: src/inspector_js_api.ccclass JSStream : public AsyncWrap
: src/js_stream.hclass FixedSizeBlobCopyJob : public AsyncWrap
: src/node_blob.hclass DirHandle : public AsyncWrap
: src/node_dir.hclass FileHandle final : public AsyncWrap
: src/node_file.hclass Http2Stream : public AsyncWrap
: src/node_http2.hclass Http2Session : public AsyncWrap
: src/node_http2.hclass Http2Ping : public AsyncWrap
: src/node_http2.hclass Http2Settings : public AsyncWrap
: src/node_http2.hclass Parser : public AsyncWrap
: src/node_http_parser.ccclass WorkerHeapSnapshotTaker : public AsyncWrap
: src/node_worker.ccclass Worker : public AsyncWrap
: src/node_worker.hclass CompressionStream : public AsyncWrap
: src/node_zlib.ccclass ReqWrap : public AsyncWrap
: src/req_wrap.hclass StreamPipe : public AsyncWrap
: src/stream_pipe.hclass BindingData : public SnapshotableObject
: src/node_file.hclass BindingData : public SnapshotableObject
: src/node_v8.hclass IntervalHistogram : public HandleWrap
: src/histogram.hclass MessagePort : public HandleWrap
: src/node_messaging.hclass StatWatcher : public HandleWrap
: src/node_stat_watcher.hclass TraceSigintWatchdog : public HandleWrap
: src/node_watchdog.hclass ProcessWrap : public HandleWrap
: src/process_wrap.ccclass SignalWrap : public HandleWrap
: src/signal_wrap.ccclass LibuvStreamWrap : public HandleWrap
: src/stream_wrap.hclass UDPWrap final : public HandleWrap
: src/udp_wrap.hclass Http2Stream::Provider::Stream : public Http2Stream
: src/node_http2.hclass ZlibStream : public CompressionStream
: src/node_zlib.ccclass BrotliCompressionStream : public CompressionStream
: src/node_zlib.ccclass GetAddrInfoReqWrap : public ReqWrap
: src/cares_wrap.ccclass GetNameInfoReqWrap : public ReqWrap
: src/cares_wrap.ccclass ConnectWrap : public ReqWrap
: src/connect_wrap.hclass FSReqBase : public ReqWrap
: src/node_file.hclass FileHandleReadWrap final : public ReqWrap
: src/node_file.hclass CloseReq final : public ReqWrap
: src/node_file.hclass SendWrap : public ReqWrap
: src/udp_wrap.ccclass ELDHistogram : public IntervalHistogram
: src/node_perf.hclass ConnectionWrap : public LibuvStreamWrap
: src/connection_wrap.hclass TTYWrap : public LibuvStreamWrap
: src/tty_wrap.hclass JSUDPWrap final : public UDPWrap
: src/js_udp_wrap.ccclass Http2StreamListener : public Stream
: src/node_http2.hclass ShutdownWrap : public Stream
: src/stream_base.hclass WriteWrap : public Stream
: src/stream_base.hclass ReportWritesToJSStreamListener : public Stream
: src/stream_base.hclass StreamBase : public Stream
: src/stream_base.hclass ReadableListener : public Stream
: src/stream_pipe.hclass WritableListener : public Stream
: src/stream_pipe.hclass FSReqCallback final : public FSReqBase
: src/node_file.hclass FSReqPromise final : public FSReqBase
: src/node_file.hclass PipeWrap : public ConnectionWrap
: src/pipe_wrap.hclass TCPWrap : public ConnectionWrap
: src/tcp_wrap.hclass SimpleShutdownWrap : public ShutdownWrap
: src/stream_base.hclass SimpleWriteWrap : public WriteWrap
: src/stream_base.hclass EmitToJSStreamListener : public ReportWritesToJSStreamListener
: src/stream_base.hclass CustomBufferJSListener : public ReportWritesToJSStreamListener
: src/stream_base.hAnother list for external references registration:
config(all properties)symbols(all properties)The text was updated successfully, but these errors were encountered: