Skip to content

node-api: remove RefBase and CallbackWrapper - #53590

Merged
nodejs-github-bot merged 4 commits into
nodejs:mainfrom
vmoroz:PR/remove_refbase
Aug 27, 2024
Merged

nodejs-github-bot merged 4 commits into
nodejs:mainfrom
vmoroz:PR/remove_refbase

Conversation

@vmoroz

@vmoroz vmoroz commented Jun 25, 2024 •

Copy link
Copy Markdown
Member

This PR simplifies internal Node-API implementation to reduce the code complexity and to reduce allocated memory size.
There are no API changes or changes to the code behavior. All existing tests are passing and no new tests are needed.

  • Removed RefBase class.
    • Reference class directly inherits from RefTracker.
    • napi_set_instance_data and napi_get_instance_data use TrackedFinalizer instead of RefBase.
  • v8impl::Ownership enum is renamed to v8impl::ReferenceOwnership to better reflect its purpose.
    • v8impl::ReferenceOwnership size changed to one byte to reduce Reference size.
  • Finalizer class became non-virtual to reduce its size.
    • All Finalizer fields became private for better encapsulation.
    • TrackedFinalizer and TrackedStringResource size changed from 64 to 56 bytes on 64-bit platforms.
  • Reference class is split up into three classes depending on the usage scenario: Reference, ReferenceWithData, and ReferenceWithFinalizer.
    • Previously Reference instance size on 64-bit platforms was 88 bytes.
    • New Reference size is 40 bytes, ReferenceWithData is 48 bytes, and ReferenceWithFinalizer is 72 bytes.
    • ReferenceWithFinalizer size reduced by 16 bytes due to changes to Finalizer (8 bytes) and removal of RefBase that along with the v8impl::ReferenceOwnership to be one byte gained reduction of another 8 bytes.
    • Instances of Reference and ReferenceWithData are not queued for finalization since they do not have user finalizer callbacks. They are finalized immediately.
  • Simplified FunctionCallbackWrapper.
    • Removed base classes CallbackWrapper and CallbackWrapperBase
    • All methods became non-virtual.
    • It should slightly improve perf for each function call.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/node-api

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. node-api Issues and PRs related to Node-API. labels Jun 25, 2024
Comment thread src/js_native_api_v8.cc Resolved
@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jun 27, 2024
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jun 27, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Comment thread src/node_api.cc Resolved
Comment thread src/js_native_api_v8.cc Resolved
Comment thread src/js_native_api_v8.cc Resolved
Comment thread src/js_native_api_v8.h Resolved
@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jul 1, 2024
toyobayashi added a commit to toyobayashi/emnapi that referenced this pull request Jul 2, 2024
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jul 3, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@vmoroz vmoroz added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jul 12, 2024
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jul 12, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@vmoroz
vmoroz force-pushed the PR/remove_refbase branch from e8bb387 to e73c7a0 Compare July 12, 2024 15:04

ghost 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.

LGTM

@mhdawson mhdawson added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jul 12, 2024
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jul 12, 2024
@legendecas legendecas added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. author ready PRs with CI started, the required approvals, and no outstanding review comments. labels Aug 23, 2024
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Aug 23, 2024
@nodejs-github-bot

ghost commented Aug 23, 2024

Copy link
Copy Markdown
Collaborator

@vmoroz vmoroz added the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 25, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 25, 2024
@nodejs-github-bot

ghost commented Aug 25, 2024

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/53590
✔  Done loading data for nodejs/node/pull/53590
----------------------------------- PR info ------------------------------------
Title      node-api: remove RefBase and CallbackWrapper (#53590)
Author     Vladimir Morozov <vmorozov@microsoft.com> (@vmoroz)
Branch     vmoroz:PR/remove_refbase -> nodejs:main
Labels     c++, node-api, author ready, needs-ci
Commits    4
 - node-api: remove RefBase and CallbackWrapper
 - reduce size of Reference
 - address PR feedback
 - add const for refcount()
Committers 2
 - Vladimir Morozov <vmorozov@microsoft.com>
 - GitHub <noreply@github.com>
PR-URL: https://github.com/nodejs/node/pull/53590
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/53590
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Gabriel Schulhof <gabrielschulhof@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last approving review:
   ⚠  - node-api: remove RefBase and CallbackWrapper
   ⚠  - reduce size of Reference
   ⚠  - address PR feedback
   ⚠  - add const for refcount()
   ℹ  This PR was created on Tue, 25 Jun 2024 21:35:58 GMT
   ✔  Approvals: 5
   ✔  - Yagiz Nizipli (@anonrig) (TSC): https://github.com/nodejs/node/pull/53590#pullrequestreview-2141773353
   ✔  - Gabriel Schulhof (@gabrielschulhof): https://github.com/nodejs/node/pull/53590#pullrequestreview-2148413989
   ✔  - Chengzhong Wu (@legendecas) (TSC): https://github.com/nodejs/node/pull/53590#pullrequestreview-2151082401
   ✔  - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/53590#pullrequestreview-2157911770
   ✔  - Michael Dawson (@mhdawson) (TSC): https://github.com/nodejs/node/pull/53590#pullrequestreview-2175228053
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2024-08-23T13:20:52Z: https://ci.nodejs.org/job/node-test-pull-request/61377/
- Querying data for job/node-test-pull-request/61377/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/10548497690

@nodejs-github-bot nodejs-github-bot added the commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. label Aug 25, 2024
@vmoroz

ghost commented Aug 25, 2024

Copy link
Copy Markdown
Member Author

@nodejs/node-api , could you please sign off the latest changes. The last CI build is succeeded and we must be able to merge the PR.

@vmoroz

ghost commented Aug 27, 2024

Copy link
Copy Markdown
Member Author

@mhdawson , could you please sign off the latest change?
The last change was only adding the const keyword to refcount() suggested by @anonrig.
The PR passed all the CI validation and is ready to merge.

@legendecas legendecas added commit-queue PRs queued for automated landing through the Commit Queue. commit-queue-squash PRs the Commit Queue should land as one squashed commit. and removed commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. labels Aug 27, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 27, 2024
@nodejs-github-bot
nodejs-github-bot merged commit 431ac16 into nodejs:main Aug 27, 2024
@nodejs-github-bot

ghost commented Aug 27, 2024

Copy link
Copy Markdown
Collaborator

Landed in 431ac16

@vmoroz
vmoroz deleted the PR/remove_refbase branch August 27, 2024 21:25
@vmoroz

ghost commented Aug 27, 2024

Copy link
Copy Markdown
Member Author

@legendecas , thank you for merging it! :)

@RafaelGSS RafaelGSS mentioned this pull request Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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++. commit-queue-squash PRs the Commit Queue should land as one squashed commit. needs-ci PRs that need a full CI run. node-api Issues and PRs related to Node-API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants