Skip to content
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

Open
joyeecheung opened this issue Feb 22, 2021 · 8 comments
Open

Support Node.js embedder objects and bindings in the snapshot #37476

joyeecheung opened this issue Feb 22, 2021 · 8 comments
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. snapshot Issues and PRs related to the startup snapshot

Comments

@joyeecheung
Copy link
Member

joyeecheung commented Feb 22, 2021

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 HandleWraps, because theoretically we can't resurrect a uv_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.h
  • class ModuleWrap : public BaseObject: src/module_wrap.h
  • class Blob : public BaseObject: src/node_blob.h
  • class BlobBindingData : public BaseObject: src/node_blob.h
  • class MicrotaskQueueWrap : public BaseObject: src/node_contextify.h
  • class ContextifyScript : public BaseObject: src/node_contextify.h
  • class CompiledFnEntry final : public BaseObject: src/node_contextify.h
  • class BindingData : public BaseObject: src/node_http_parser.cc
  • class ConverterObject : public BaseObject: src/node_i18n.h
  • class JSTransferable : public BaseObject: src/node_messaging.h
  • class 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.cc
  • class DeserializerContext : public BaseObject: src/node_serdes.cc
  • class SnapshotableObject : public BaseObject: src/node_snapshotable.h
  • class NodeCategorySet : public BaseObject: src/node_trace_events.cc
  • class WeakReference : public BaseObject: src/node_util.cc: src: support WeakReference, diagnostics_channel and net in the snapshot #44193
  • class WASI : public BaseObject: src/node_wasi.h

The 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.h
  • class AsyncWrap : public BaseObject: src/async_wrap.h
  • class PromiseWrap : public AsyncWrap: src/async_wrap.cc
  • class ChannelWrap : public AsyncWrap: src/cares_wrap.cc
  • class QueryWrap : public AsyncWrap: src/cares_wrap.cc
  • class HandleWrap : public AsyncWrap: src/handle_wrap.h
  • class HeapSnapshotStream : public AsyncWrap: src/heap_utils.cc
  • class JSBindingsConnection : public AsyncWrap: src/inspector_js_api.cc
  • class JSStream : public AsyncWrap: src/js_stream.h
  • class FixedSizeBlobCopyJob : public AsyncWrap: src/node_blob.h
  • class DirHandle : public AsyncWrap: src/node_dir.h
  • class FileHandle final : public AsyncWrap: src/node_file.h
  • class Http2Stream : public AsyncWrap: src/node_http2.h
  • class Http2Session : public AsyncWrap: src/node_http2.h
  • class Http2Ping : public AsyncWrap: src/node_http2.h
  • class Http2Settings : public AsyncWrap: src/node_http2.h
  • class Parser : public AsyncWrap: src/node_http_parser.cc
  • class WorkerHeapSnapshotTaker : public AsyncWrap: src/node_worker.cc
  • class Worker : public AsyncWrap: src/node_worker.h
  • class CompressionStream : public AsyncWrap: src/node_zlib.cc
  • class ReqWrap : public AsyncWrap: src/req_wrap.h
  • class StreamPipe : public AsyncWrap: src/stream_pipe.h
  • class BindingData : public SnapshotableObject: src/node_file.h
  • class BindingData : public SnapshotableObject: src/node_v8.h
  • class IntervalHistogram : public HandleWrap: src/histogram.h
  • class MessagePort : public HandleWrap: src/node_messaging.h
  • class StatWatcher : public HandleWrap: src/node_stat_watcher.h
  • class TraceSigintWatchdog : public HandleWrap: src/node_watchdog.h
  • class ProcessWrap : public HandleWrap: src/process_wrap.cc
  • class SignalWrap : public HandleWrap: src/signal_wrap.cc
  • class LibuvStreamWrap : public HandleWrap: src/stream_wrap.h
  • class UDPWrap final : public HandleWrap: src/udp_wrap.h
  • class Http2Stream::Provider::Stream : public Http2Stream: src/node_http2.h
  • class ZlibStream : public CompressionStream: src/node_zlib.cc
  • class BrotliCompressionStream : public CompressionStream: src/node_zlib.cc
  • class GetAddrInfoReqWrap : public ReqWrap: src/cares_wrap.cc
  • class GetNameInfoReqWrap : public ReqWrap: src/cares_wrap.cc
  • class ConnectWrap : public ReqWrap: src/connect_wrap.h
  • class FSReqBase : public ReqWrap: src/node_file.h
  • class FileHandleReadWrap final : public ReqWrap: src/node_file.h
  • class CloseReq final : public ReqWrap: src/node_file.h
  • class SendWrap : public ReqWrap: src/udp_wrap.cc
  • class ELDHistogram : public IntervalHistogram: src/node_perf.h
  • class ConnectionWrap : public LibuvStreamWrap: src/connection_wrap.h
  • class TTYWrap : public LibuvStreamWrap: src/tty_wrap.h
  • class JSUDPWrap final : public UDPWrap: src/js_udp_wrap.cc
  • class Http2StreamListener : public Stream: src/node_http2.h
  • class ShutdownWrap : public Stream: src/stream_base.h
  • class WriteWrap : public Stream: src/stream_base.h
  • class ReportWritesToJSStreamListener : public Stream: src/stream_base.h
  • class StreamBase : public Stream: src/stream_base.h
  • class ReadableListener : public Stream: src/stream_pipe.h
  • class WritableListener : public Stream: src/stream_pipe.h
  • class FSReqCallback final : public FSReqBase: src/node_file.h
  • class FSReqPromise final : public FSReqBase: src/node_file.h
  • class PipeWrap : public ConnectionWrap: src/pipe_wrap.h
  • class TCPWrap : public ConnectionWrap: src/tcp_wrap.h
  • class SimpleShutdownWrap : public ShutdownWrap: src/stream_base.h
  • class SimpleWriteWrap : public WriteWrap: src/stream_base.h
  • class EmitToJSStreamListener : public ReportWritesToJSStreamListener: src/stream_base.h
  • class CustomBufferJSListener : public ReportWritesToJSStreamListener: src/stream_base.h

Another list for external references registration:

  • fs
  • os
  • uv
  • v8
  • icu
  • url
  • blob
  • util
  • wasi
  • zlib
  • http2
  • types
  • buffer
  • config (all properties)
  • crypto (src: include crypto in the bootstrap snapshot #42203)
  • dtrace
  • errors
  • fs_dir
  • report
  • serdes
  • timers
  • worker
  • options
  • symbols (all properties)
  • profiler
  • tcp_wrap
  • tls_wrap
  • tty_wrap
  • udp_wrap
  • watchdog
  • inspector
  • js_stream
  • messaging
  • pipe_wrap
  • async_wrap
  • block_list
  • cares_wrap
  • contextify
  • heap_utils
  • mksnapshot
  • spawn_sync
  • task_queue
  • credentials
  • http_parser
  • js_udp_wrap
  • module_wrap
  • performance
  • signal_wrap
  • stream_pipe
  • stream_wrap
  • process_wrap
  • trace_events
  • fs_event_wrap
  • native_module
  • string_decoder
  • process_methods
@joyeecheung
Copy link
Member Author

joyeecheung commented Feb 22, 2021

I'll be looking into the ones in module_wrap.h and node_contextify.h so that we can include the user modules in the snapshot. Also we need a better story for fast API objects like FastHrtime though right now we don't use fast API much in core so it's low priority.

@joyeecheung
Copy link
Member Author

cc @nodejs/startup

@devsnek
Copy link
Member

devsnek commented Feb 22, 2021

ModuleWrap is blocked on v8:10855

@XadillaX
Copy link
Contributor

cc @nodejs/startup

So we have to do some division of labor?

@joyeecheung
Copy link
Member Author

joyeecheung commented Feb 24, 2021

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.

@joyeecheung
Copy link
Member Author

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.

legendecas pushed a commit that referenced this issue Apr 8, 2021
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>
@targos targos added c++ Issues and PRs that require attention from people who are familiar with C++. snapshot Issues and PRs related to the startup snapshot labels Aug 9, 2021
@targos
Copy link
Member

targos commented Aug 9, 2021

@joyeecheung the OP probably needs an update.

@jasnell
Copy link
Member

jasnell commented Aug 9, 2021

Fwiw, Blob objects likely should not be serialized. They should not live beyond the process in which they were created.

@joyeecheung joyeecheung changed the title Support (de)serialization of Node.js embedder objects in the snapshot Support Node.js embedder objects and bindings in the snapshot Sep 9, 2021
joyeecheung added a commit that referenced this issue Oct 19, 2021
PR-URL: #40239
Refs: #38905
Refs: #37476
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
joyeecheung added a commit that referenced this issue Oct 19, 2021
PR-URL: #40239
Refs: #38905
Refs: #37476
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this issue Oct 23, 2021
PR-URL: #40239
Refs: #38905
Refs: #37476
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
targos pushed a commit that referenced this issue Oct 23, 2021
PR-URL: #40239
Refs: #38905
Refs: #37476
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
joyeecheung added a commit that referenced this issue Nov 17, 2021
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>
targos pushed a commit that referenced this issue Nov 21, 2021
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>
BethGriggs pushed a commit that referenced this issue Nov 23, 2021
PR-URL: #40239
Refs: #38905
Refs: #37476
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
BethGriggs pushed a commit that referenced this issue Nov 23, 2021
PR-URL: #40239
Refs: #38905
Refs: #37476
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
danielleadams pushed a commit that referenced this issue Jan 30, 2022
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>
danielleadams pushed a commit that referenced this issue Feb 1, 2022
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>
nodejs-github-bot pushed a commit that referenced this issue Mar 11, 2022
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>
nodejs-github-bot pushed a commit that referenced this issue Mar 11, 2022
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>
nodejs-github-bot pushed a commit that referenced this issue Aug 12, 2022
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>
danielleadams pushed a commit that referenced this issue Aug 16, 2022
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>
joyeecheung added a commit that referenced this issue Aug 19, 2022
Move util::WeakReference to a separate header and implement
{de}serialization for it to be snapshotable.

PR-URL: #44193
Refs: #44014
Refs: #37476
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
joyeecheung added a commit that referenced this issue Aug 19, 2022
PR-URL: #44193
Refs: #44014
Refs: #37476
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
joyeecheung added a commit that referenced this issue Aug 23, 2022
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>
joyeecheung added a commit that referenced this issue Aug 23, 2022
Include a minimally initialized contextify context in the embedded
snapshot. This paves the way for user-land vm context snapshots.

PR-URL: #44252
Refs: #44014
Refs: #37476
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
joyeecheung added a commit that referenced this issue Aug 23, 2022
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>
joyeecheung added a commit to joyeecheung/node that referenced this issue Aug 25, 2022
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>
joyeecheung added a commit to joyeecheung/node that referenced this issue Aug 25, 2022
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>
joyeecheung added a commit to joyeecheung/node that referenced this issue Aug 25, 2022
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>
RafaelGSS pushed a commit that referenced this issue Sep 5, 2022
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>
RafaelGSS pushed a commit that referenced this issue Sep 5, 2022
Include a minimally initialized contextify context in the embedded
snapshot. This paves the way for user-land vm context snapshots.

PR-URL: #44252
Refs: #44014
Refs: #37476
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
RafaelGSS pushed a commit that referenced this issue Sep 5, 2022
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>
Fyko pushed a commit to Fyko/node that referenced this issue Sep 15, 2022
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>
Fyko pushed a commit to Fyko/node that referenced this issue Sep 15, 2022
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>
Fyko pushed a commit to Fyko/node that referenced this issue Sep 15, 2022
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>
Fyko pushed a commit to Fyko/node that referenced this issue Sep 15, 2022
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>
Fyko pushed a commit to Fyko/node that referenced this issue Sep 15, 2022
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>
Fyko pushed a commit to Fyko/node that referenced this issue Sep 15, 2022
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>
joyeecheung added a commit to joyeecheung/node that referenced this issue Oct 14, 2022
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>
joyeecheung added a commit to joyeecheung/node that referenced this issue Oct 14, 2022
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>
joyeecheung added a commit that referenced this issue Nov 1, 2022
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>
joyeecheung added a commit that referenced this issue Nov 1, 2022
Move util::WeakReference to a separate header and implement
{de}serialization for it to be snapshotable.

PR-URL: #44193
Refs: #44014
Refs: #37476
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
juanarbol pushed a commit that referenced this issue Nov 4, 2022
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>
juanarbol pushed a commit that referenced this issue Nov 4, 2022
Move util::WeakReference to a separate header and implement
{de}serialization for it to be snapshotable.

PR-URL: #44193
Refs: #44014
Refs: #37476
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
danielleadams pushed a commit that referenced this issue Jan 3, 2023
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>
danielleadams pushed a commit that referenced this issue Jan 3, 2023
Move util::WeakReference to a separate header and implement
{de}serialization for it to be snapshotable.

PR-URL: #44193
Refs: #44014
Refs: #37476
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. snapshot Issues and PRs related to the startup snapshot
Projects
None yet
Development

No branches or pull requests

5 participants