FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

vm: migrate ContextifyScript to cppgc by joyeecheung · Pull Request #52295 · nodejs/node · GitHub

/ node Public

vm: migrate ContextifyScript to cppgc - #52295

Closed
joyeecheung wants to merge 3 commits into
nodejs:mainfrom
joyeecheung:cppgc-data
Closed

vm: migrate ContextifyScript to cppgc#52295
joyeecheung wants to merge 3 commits into
nodejs:mainfrom
joyeecheung:cppgc-data

Conversation

joyeecheung commented Mar 31, 2024
edited
Loading

Copy link
Copy Markdown
Member

This PR includes two commits. One adds a helper mixin node::CppgcMixin to src/cppgc_helpers.h along with some documentation in src/README.md to facilitate migration from BaseObject to cppgc-based memory management (Oilpan), and another migrates ContextifyScript to cppgc which will be the first wrapper class in Node.js to use it. This class is chosen because it doesn't have any externally managed data - most other wrapper classes do and they will need to wait for https://chromium-review.googlesource.com/c/v8/v8/+/5630497.

For more information about migrating to Oilpan (cppgc) in Node.js, see the design doc and Chromium's documentation on Oilpan

Refs: #40786
Refs: https://docs.google.com/document/d/1ny2Qz_EsUnXGKJRGxoA-FXIE2xpLgaMAN6jD7eAkqFQ/edit

Local benchmark numbers show a small improvement in compiling small scripts, likely due to improved GC performance:

                                                                                                                                    confidence improvement accuracy (*)   (**)  (***)
vm/compile-script-in-isolate-cache.js n=1000 filename='test/fixtures/snapshot/typescript.js' type='with-dynamic-import-callback'                    0.37 %       ±0.51% ±0.69% ±0.91%
vm/compile-script-in-isolate-cache.js n=1000 filename='test/fixtures/snapshot/typescript.js' type='without-dynamic-import-callback'          *      1.01 %       ±0.87% ±1.18% ±1.56%
vm/compile-script-in-isolate-cache.js n=1000 filename='test/fixtures/syntax/good_syntax.js' type='with-dynamic-import-callback'            ***      6.45 %       ±1.39% ±1.86% ±2.44%
vm/compile-script-in-isolate-cache.js n=1000 filename='test/fixtures/syntax/good_syntax.js' type='without-dynamic-import-callback'         ***      8.69 %       ±0.99% ±1.32% ±1.72%

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/gyp
  • @nodejs/security-wg
  • @nodejs/v8-update

nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Mar 31, 2024

Copy link
Copy Markdown
Member Author

hubot pushed a commit to v8/v8 that referenced this pull request May 2, 2024
Refs: nodejs/node#52295

Change-Id: If0e34519c4fa83b019a0a67136e6515d85810a19
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5403888
Commit-Queue: Joyee Cheung <joyee@igalia.com>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#93690}

joyeecheung commented May 3, 2024
edited
Loading

Copy link
Copy Markdown
Member Author

https://chromium-review.googlesource.com/c/v8/v8/+/5403888 has landed but given that the upstream has deprecated the current wrapper descriptor-based integration and the new API requires a series of V8 changes to upgrade to, I think it would minify the risk of bugs if we wait until 12.5 is pulled in.

joyeecheung added the blocked PRs that are blocked by other issues or PRs. label Jun 18, 2024

Copy link
Copy Markdown
Member Author

Rebased after v8 upgrade landed. New benchmark numbers:

❯ node-benchmark-compare script.csv
                                                                                                                                    confidence improvement accuracy (*)   (**)  (***)
vm/compile-script-in-isolate-cache.js n=1000 filename='test/fixtures/snapshot/typescript.js' type='with-dynamic-import-callback'                    0.37 %       ±0.51% ±0.69% ±0.91%
vm/compile-script-in-isolate-cache.js n=1000 filename='test/fixtures/snapshot/typescript.js' type='without-dynamic-import-callback'          *      1.01 %       ±0.87% ±1.18% ±1.56%
vm/compile-script-in-isolate-cache.js n=1000 filename='test/fixtures/syntax/good_syntax.js' type='with-dynamic-import-callback'            ***      6.45 %       ±1.39% ±1.86% ±2.44%
vm/compile-script-in-isolate-cache.js n=1000 filename='test/fixtures/syntax/good_syntax.js' type='without-dynamic-import-callback'         ***      8.69 %       ±0.99% ±1.32% ±1.72%

Still need to finish some documentation about the helpers..

joyeecheung removed the blocked PRs that are blocked by other issues or PRs. label Aug 18, 2024
joyeecheung force-pushed the cppgc-data branch 4 times, most recently from 68814ab to ed0cffb Compare August 22, 2024 13:59
joyeecheung changed the title wip: migrate ContextifyScript to cppgc vm: migrate ContextifyScript to cppgc Aug 22, 2024
joyeecheung marked this pull request as ready for review August 22, 2024 14:05
joyeecheung added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 22, 2024

Copy link
Copy Markdown
Member Author

cc @nodejs/cpp-reviewers @mcollina @legendecas

github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 22, 2024

Copy link
Copy Markdown
Collaborator

codecov Bot commented Aug 22, 2024
edited
Loading

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 82.60870% with 12 lines in your changes missing coverage. Please review.

Project coverage is 87.31%. Comparing base (097dcfc) to head (b08778a).
Report is 29 commits behind head on main.

Files with missing lines Patch % Lines
src/heap_utils.cc 66.66% 2 Missing and 3 partials ⚠️
src/cppgc_helpers.h 84.21% 1 Missing and 2 partials ⚠️
src/node_contextify.cc 85.71% 0 Missing and 3 partials ⚠️
src/node_contextify.h 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #52295   +/-   ##
=======================================
  Coverage   87.30%   87.31%           
=======================================
  Files         649      650    +1     
  Lines      182706   182734   +28     
  Branches    35036    35042    +6     
=======================================
+ Hits       159516   159548   +32     
+ Misses      16456    16453    -3     
+ Partials     6734     6733    -1     
Files with missing lines Coverage Δ
src/base_object.h 88.88% <100.00%> (ø)
src/crypto/crypto_keys.cc 72.50% <100.00%> (-0.30%) ⬇️
src/crypto/crypto_util.cc 68.35% <100.00%> (+0.08%) ⬆️
src/node_file-inl.h 88.08% <100.00%> (ø)
src/node_messaging.cc 84.07% <100.00%> (+0.01%) ⬆️
src/stream_wrap.cc 87.61% <100.00%> (ø)
src/udp_wrap.cc 78.66% <100.00%> (ø)
src/node_contextify.h 75.00% <0.00%> (-10.72%) ⬇️
src/cppgc_helpers.h 84.21% <84.21%> (ø)
src/node_contextify.cc 80.73% <85.71%> (+0.18%) ⬆️
... and 1 more

... and 25 files with indirect coverage changes

mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

lgtm

Comment thread src/node_contextify.h Outdated
Comment thread src/cppgc_helpers.h Outdated
Comment thread src/node_contextify.cc Outdated
Comment thread src/cppgc_helpers.h Outdated
Comment thread src/node_contextify.h Outdated
nodejs-github-bot pushed a commit that referenced this pull request Aug 30, 2024
This patch adds helpers for wrapper classes based on cppgc (Oilpan)
in `src/cppgc_helpers.h`, including `node::CppgcMixin` and
`ASSIGN_OR_RETURN_UNWRAP_CPPGC`, which are designed to have
similar interface to BaseObject helpers to help migration.
They are documented in the `CppgcMixin` section in `src/README.md`

To disambiguate, the global `node::Unwrap<>` has now been moved
as `node::BaseObject::Unwrap<>`, and `node::Cppgc::Unwrap<>`
implements a similar unwrapping mechanism for cppgc-managed
wrappers.

PR-URL: #52295
Refs: #40786
Refs: https://docs.google.com/document/d/1ny2Qz_EsUnXGKJRGxoA-FXIE2xpLgaMAN6jD7eAkqFQ/edit
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
nodejs-github-bot pushed a commit that referenced this pull request Aug 30, 2024
This patch migrates ContextifyScript to cppgc-based memory
management using CppgcMixin.

PR-URL: #52295
Refs: #40786
Refs: https://docs.google.com/document/d/1ny2Qz_EsUnXGKJRGxoA-FXIE2xpLgaMAN6jD7eAkqFQ/edit
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
RafaelGSS pushed a commit that referenced this pull request Aug 30, 2024
Use a std::set<> for saving the JSGraphJSNode, since implementing
a proper hash function for v8::Data is complicated and this
path is only used by tests anyway, where the performance difference
between std::set and std::unordered_set doesn't matter.

PR-URL: #52295
Refs: #40786
Refs: https://docs.google.com/document/d/1ny2Qz_EsUnXGKJRGxoA-FXIE2xpLgaMAN6jD7eAkqFQ/edit
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
RafaelGSS pushed a commit that referenced this pull request Aug 30, 2024
This patch adds helpers for wrapper classes based on cppgc (Oilpan)
in `src/cppgc_helpers.h`, including `node::CppgcMixin` and
`ASSIGN_OR_RETURN_UNWRAP_CPPGC`, which are designed to have
similar interface to BaseObject helpers to help migration.
They are documented in the `CppgcMixin` section in `src/README.md`

To disambiguate, the global `node::Unwrap<>` has now been moved
as `node::BaseObject::Unwrap<>`, and `node::Cppgc::Unwrap<>`
implements a similar unwrapping mechanism for cppgc-managed
wrappers.

PR-URL: #52295
Refs: #40786
Refs: https://docs.google.com/document/d/1ny2Qz_EsUnXGKJRGxoA-FXIE2xpLgaMAN6jD7eAkqFQ/edit
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
RafaelGSS pushed a commit that referenced this pull request Aug 30, 2024
This patch migrates ContextifyScript to cppgc-based memory
management using CppgcMixin.

PR-URL: #52295
Refs: #40786
Refs: https://docs.google.com/document/d/1ny2Qz_EsUnXGKJRGxoA-FXIE2xpLgaMAN6jD7eAkqFQ/edit
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
RafaelGSS mentioned this pull request Aug 30, 2024
joyeecheung added dont-land-on-v18.x dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. labels Aug 30, 2024

Copy link
Copy Markdown
Member Author

This will need some patching to work on older versions of V8, applying the dont-land labels for now.

Comment thread src/base_object.h
template <typename T>
static inline T* Unwrap(v8::Local<v8::Value> obj) {
return BaseObject::FromJSObject<T>(obj);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@joyeecheung Might as well have removed this entirely, the point of this was to provide a shorthand but it's not really serving that purpose anymore :)

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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++. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. vm Issues and PRs related to the vm subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants


Back | FazBrowse Home | New Git URL