GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — vm: lazily initialize primordials for vm contexts by joyeecheung · Pull Request #31738 · nodejs/node

Conversation

@joyeecheung

@joyeecheung joyeecheung commented Feb 11, 2020

Copy link
Copy Markdown
Member

Lazily initialize primordials when cross-context support for
builtins is needed to fix the performance regression in context
creation.

Fixes: #29842

local benchmark results

                            confidence improvement accuracy (*)    (**)   (***)
 vm/create-context.js n=100        ***    485.26 %      ±15.48% ±21.32% ±29.29%
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss, benjamingr, and abenhamdine reacted with thumbs up emoji
All reactions
  • 👍 3 reactions
@joyeecheung
vm: lazily initialize primordials for vm contexts
d6b9d2a
Lazily initialize primordials when cross-context support for
builtins is needed to fix the performance regression in context
creation.
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. vm Issues and PRs related to the vm subsystem. labels Feb 11, 2020
joyeecheung
joyeecheung commented Feb 11, 2020
View reviewed changes
Comment thread src/api/environment.cc
return InitializePrimordials(context);
}

bool InitializePrimordials(Local<Context> context) {

@joyeecheung joyeecheung Feb 11, 2020

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block contains only indentation change

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot

nodejs-github-bot commented Feb 11, 2020

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/29072/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

joyeecheung
joyeecheung commented Feb 11, 2020
View reviewed changes
Comment thread src/api/environment.cc Outdated
Local<Object> exports = Object::New(isolate);
if (context->Global()->SetPrivate(context, key, exports).IsNothing())
return MaybeLocal<Object>();
InitializePrimordials(context);

@joyeecheung joyeecheung Feb 11, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only hit for vm contexts and main contexts created without snapshot support so there's no additional cost for the main context built with snapshot support

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@joyeecheung

joyeecheung commented Feb 11, 2020

Copy link
Copy Markdown
Member Author

Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/522/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung
fixup! vm: lazily initialize primordials for vm contexts
2c79633
devsnek
devsnek approved these changes Feb 11, 2020
View reviewed changes
joyeecheung
joyeecheung commented Feb 11, 2020
View reviewed changes
Comment thread src/api/environment.cc
Local<Object> exports = Object::New(isolate);
if (context->Global()->SetPrivate(context, key, exports).IsNothing())
if (context->Global()->SetPrivate(context, key, exports).IsNothing() ||
!InitializePrimordials(context))

@joyeecheung joyeecheung Feb 11, 2020

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, forgot to handle the return value of InitializePrimordials in the initial commit, fixed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
addaleax
addaleax approved these changes Feb 11, 2020
View reviewed changes
devnexen
devnexen approved these changes Feb 12, 2020
View reviewed changes
@addaleax

addaleax commented Feb 13, 2020

Copy link
Copy Markdown
Member
16:41:47                             confidence improvement accuracy (*)    (**)   (***)
16:41:47  vm/create-context.js n=100        ***    371.94 %      ±21.00% ±28.29% ±37.54%

🙂

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax addaleax added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Feb 13, 2020
@nodejs-github-bot

nodejs-github-bot commented Feb 13, 2020

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/29109/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

joyeecheung added a commit that referenced this pull request Feb 19, 2020
@joyeecheung
vm: lazily initialize primordials for vm contexts
e6c2277
Lazily initialize primordials when cross-context support for
builtins is needed to fix the performance regression in context
creation.

PR-URL: #31738
Fixes: #29842
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: David Carlier <[email protected]>
@joyeecheung

joyeecheung commented Feb 19, 2020

Copy link
Copy Markdown
Member Author

Landed in e6c2277. Thanks!

spasam reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung joyeecheung closed this Feb 19, 2020
codebytere pushed a commit that referenced this pull request Feb 27, 2020
@joyeecheung @codebytere
vm: lazily initialize primordials for vm contexts
a86cb0e
Lazily initialize primordials when cross-context support for
builtins is needed to fix the performance regression in context
creation.

PR-URL: #31738
Fixes: #29842
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: David Carlier <[email protected]>
@codebytere codebytere mentioned this pull request Feb 29, 2020
v13.10.0 proposal #32027
Merged
@codebytere

codebytere commented Mar 15, 2020

Copy link
Copy Markdown
Member

@joyeecheung if this should go to v12.x can you please open a manual backport? There are some conflicts i'd rather not chance myself.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codebytere codebytere added the backport-requested-v12.x label Mar 15, 2020
@targos targos removed the backport-requested-v12.x label Apr 25, 2020
targos pushed a commit to targos/node that referenced this pull request Apr 25, 2020
@joyeecheung @targos
vm: lazily initialize primordials for vm contexts
c648729
Lazily initialize primordials when cross-context support for
builtins is needed to fix the performance regression in context
creation.

PR-URL: nodejs#31738
Fixes: nodejs#29842
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: David Carlier <[email protected]>
targos pushed a commit that referenced this pull request Apr 28, 2020
@joyeecheung @targos
vm: lazily initialize primordials for vm contexts
02de66a
Lazily initialize primordials when cross-context support for
builtins is needed to fix the performance regression in context
creation.

PR-URL: #31738
Fixes: #29842
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: David Carlier <[email protected]>
@targos targos mentioned this pull request May 2, 2020
v12.17.0 release proposal #33197
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@addaleax addaleax addaleax approved these changes
+2 more reviewers
@devnexen devnexen devnexen approved these changes
@devsnek devsnek devsnek approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. vm Issues and PRs related to the vm subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Significant slowdown of createContext and runInContext

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@joyeecheung @nodejs-github-bot @addaleax @codebytere @devnexen @devsnek @targos
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.