-
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
vm: include vm context in the embedded snapshot #44252
Conversation
Review requested:
|
29c650e
to
e582c5c
Compare
s/embeded/embedded in commit message |
c32efba
to
5e2a212
Compare
Rebased on top of #44258 and added a commit that makes use of the snapshot to speed up the initialization of the vm contexts a bit. |
From the CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1174
It seems that I needed to bump up the number of iterations (--set n=1000) to get a stable number from the benchmarks though. |
I've found that (inside build snapshot) const vm = require('vm')
const context = vm.createContext();
console.log(context, vm.isContext(context))
const global2 = vm.runInContext(
'this',
context,
) throws an error
should it be fixed in this PR or next? |
@goloveychuk My plan is to implement user-land vm context it in another PR (because that requires more refactoring to the lifetime management of the bindings), this only adds support for vm context in the embedded snapshot, which isn't that complex. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Opened #44277 and transferred the discussions there, in case this PR goes too off-topic. @goloveychuk please use that thread for discussions about user-land modules instead, thanks |
Extract common context embedder tag checks to ContextEmbedderTag so that verifying if a context is a node context doesn't need to access private members of node::Environment. PR-URL: #44258 Refs: #44179 Refs: #44252 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
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.
Include a minimally initialized contextify context in the embedded snapshot. This paves the way for user-land vm context snapshots.
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%.
Notable changes: * cli: * (SEMVER-MINOR) add `--watch` (Moshe Atlow) #44366 * doc: * add daeyeon to collaborators (Daeyeon Jeong) #44355 * lib: * (SEMVER-MINOR) add diagnostics channel for process and worker (theanarkh) #44045 * os: * (SEMVER-MINOR) add machine method (theanarkh) #44416 * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) #44255 * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) #44362 * vm: * include vm context in the embedded snapshot (Joyee Cheung) #44252 PR-URL: #44521
Notable changes: * cli: * (SEMVER-MINOR) add `--watch` (Moshe Atlow) #44366 * doc: * add daeyeon to collaborators (Daeyeon Jeong) #44355 * lib: * (SEMVER-MINOR) add diagnostics channel for process and worker (theanarkh) #44045 * os: * (SEMVER-MINOR) add machine method (theanarkh) #44416 * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) #44255 * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) #44362 * vm: * include vm context in the embedded snapshot (Joyee Cheung) #44252 PR-URL: #44521
Notable changes: * doc: * add daeyeon to collaborators (Daeyeon Jeong) #44355 * lib: * (SEMVER-MINOR) add diagnostics channel for process and worker (theanarkh) #44045 * os: * (SEMVER-MINOR) add machine method (theanarkh) #44416 * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) #44255 * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) #44362 * vm: * include vm context in the embedded snapshot (Joyee Cheung) #44252 PR-URL: #44521
Notable changes: * doc: * add daeyeon to collaborators (Daeyeon Jeong) [#44355](#44355) * lib: * (SEMVER-MINOR) add diagnostics channel for process and worker (theanarkh) [#44045](#44045) * os: * (SEMVER-MINOR) add machine method (theanarkh) [#44416](#44416) * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) [#44255](#44255) * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) [#44362](#44362) * vm: * include vm context in the embedded snapshot (Joyee Cheung) [#44252](#44252) PR-URL: #44521
Notable changes: * doc: * add daeyeon to collaborators (Daeyeon Jeong) #44355 * lib: * (SEMVER-MINOR) add diagnostics channel for process and worker (theanarkh) #44045 * os: * (SEMVER-MINOR) add machine method (theanarkh) #44416 * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) #44255 * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) #44362 * vm: * include vm context in the embedded snapshot (Joyee Cheung) #44252 PR-URL: #44521
Notable changes: * doc: * add daeyeon to collaborators (Daeyeon Jeong) nodejs#44355 * lib: * (SEMVER-MINOR) add diagnostics channel for process and worker (theanarkh) nodejs#44045 * os: * (SEMVER-MINOR) add machine method (theanarkh) nodejs#44416 * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) nodejs#44255 * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) nodejs#44362 * vm: * include vm context in the embedded snapshot (Joyee Cheung) nodejs#44252 PR-URL: nodejs#44521
Notable changes: * doc: * add daeyeon to collaborators (Daeyeon Jeong) #44355 * lib: * (SEMVER-MINOR) add diagnostics channel for process and worker (theanarkh) #44045 * os: * (SEMVER-MINOR) add machine method (theanarkh) #44416 * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) #44255 * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) #44362 * vm: * include vm context in the embedded snapshot (Joyee Cheung) #44252 PR-URL: #44521
Notable changes: * doc: * add daeyeon to collaborators (Daeyeon Jeong) #44355 * os: * (SEMVER-MINOR) add machine method (theanarkh) #44416 * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) #44255 * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) #44362 * vm: * include vm context in the embedded snapshot (Joyee Cheung) #44252 PR-URL: #44521
Notable changes: * doc: * add daeyeon to collaborators (Daeyeon Jeong) nodejs#44355 * os: * (SEMVER-MINOR) add machine method (theanarkh) nodejs#44416 * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) nodejs#44255 * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) nodejs#44362 * vm: * include vm context in the embedded snapshot (Joyee Cheung) nodejs#44252 PR-URL: nodejs#44521
Notable changes: * doc: * add daeyeon to collaborators (Daeyeon Jeong) #44355 * lib: * (SEMVER-MINOR) add diagnostics channel for process and worker (theanarkh) #44045 * os: * (SEMVER-MINOR) add machine method (theanarkh) #44416 * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) #44255 * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) #44362 * vm: * include vm context in the embedded snapshot (Joyee Cheung) #44252 PR-URL: #44521
Notable changes: * doc: * add daeyeon to collaborators (Daeyeon Jeong) #44355 * lib: * (SEMVER-MINOR) add diagnostics channel for process and worker (theanarkh) #44045 * os: * (SEMVER-MINOR) add machine method (theanarkh) #44416 * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) #44255 * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) #44362 * vm: * include vm context in the embedded snapshot (Joyee Cheung) #44252 PR-URL: #44521
Notable changes: * doc: * add daeyeon to collaborators (Daeyeon Jeong) #44355 * lib: * (SEMVER-MINOR) add diagnostics channel for process and worker (theanarkh) #44045 * os: * (SEMVER-MINOR) add machine method (theanarkh) #44416 * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) #44255 * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) #44362 * vm: * include vm context in the embedded snapshot (Joyee Cheung) #44252 PR-URL: #44521
Notable changes: * doc: * add daeyeon to collaborators (Daeyeon Jeong) #44355 * lib: * (SEMVER-MINOR) add diagnostics channel for process and worker (theanarkh) #44045 * os: * (SEMVER-MINOR) add machine method (theanarkh) #44416 * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) #44255 * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) #44362 * vm: * include vm context in the embedded snapshot (Joyee Cheung) #44252 PR-URL: #44521
Notable changes: * doc: * add daeyeon to collaborators (Daeyeon Jeong) #44355 * lib: * (SEMVER-MINOR) add diagnostics channel for process and worker (theanarkh) #44045 * os: * (SEMVER-MINOR) add machine method (theanarkh) #44416 * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) #44255 * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) #44362 * vm: * include vm context in the embedded snapshot (Joyee Cheung) #44252 PR-URL: #44521
Notable changes: * doc: * add daeyeon to collaborators (Daeyeon Jeong) #44355 * lib: * (SEMVER-MINOR) add diagnostics channel for process and worker (theanarkh) #44045 * os: * (SEMVER-MINOR) add machine method (theanarkh) #44416 * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) #44255 * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) #44362 * vm: * include vm context in the embedded snapshot (Joyee Cheung) #44252 PR-URL: #44521
Extract common context embedder tag checks to ContextEmbedderTag so that verifying if a context is a node context doesn't need to access private members of node::Environment. PR-URL: nodejs#44258 Refs: nodejs#44179 Refs: nodejs#44252 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Notable changes: * doc: * add daeyeon to collaborators (Daeyeon Jeong) nodejs#44355 * lib: * (SEMVER-MINOR) add diagnostics channel for process and worker (theanarkh) nodejs#44045 * os: * (SEMVER-MINOR) add machine method (theanarkh) nodejs#44416 * report: * (SEMVER-MINOR) expose report public native apis (Chengzhong Wu) nodejs#44255 * src: * (SEMVER-MINOR) expose environment RequestInterrupt api (Chengzhong Wu) nodejs#44362 * vm: * include vm context in the embedded snapshot (Joyee Cheung) nodejs#44252 PR-URL: nodejs#44521
This is not landing cleanly in v16.x |
Extract common context embedder tag checks to ContextEmbedderTag so that verifying if a context is a node context doesn't need to access private members of node::Environment. PR-URL: #44258 Refs: #44179 Refs: #44252 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
Extract common context embedder tag checks to ContextEmbedderTag so that verifying if a context is a node context doesn't need to access private members of node::Environment. PR-URL: #44258 Refs: #44179 Refs: #44252 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
Extract common context embedder tag checks to ContextEmbedderTag so that verifying if a context is a node context doesn't need to access private members of node::Environment. PR-URL: nodejs/node#44258 Refs: nodejs/node#44179 Refs: nodejs/node#44252 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
Extract common context embedder tag checks to ContextEmbedderTag so that verifying if a context is a node context doesn't need to access private members of node::Environment. PR-URL: nodejs/node#44258 Refs: nodejs/node#44179 Refs: nodejs/node#44252 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
The first commit comes from #44258
vm: make ContextifyContext template context-independent
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.
vm: include vm context in the embedded snapshot
Include a minimally initialized contextify context in the embedded
snapshot. This paves the way for user-land vm context snapshots.
vm: avoid unnecessary property getter interceptor calls
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.
anymore.
This should speed up the creation of vm contexts by about ~12%.
Refs: #44014
Refs: #37476