Skip to content

[WIP] node-api: optimize finalizer queue using container swap #57861

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mertcanaltin
Copy link
Member

I replaced the iterative per-item removal with a swap to reduce the overhead

@nodejs-github-bot
Copy link
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 the Node-API. labels Apr 13, 2025
Copy link

codecov bot commented Apr 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.24%. Comparing base (964e41c) to head (b9521e8).
Report is 33 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #57861    +/-   ##
========================================
  Coverage   90.23%   90.24%            
========================================
  Files         630      630            
  Lines      185518   185935   +417     
  Branches    36369    36439    +70     
========================================
+ Hits       167401   167789   +388     
- Misses      11005    11009     +4     
- Partials     7112     7137    +25     
Files with missing lines Coverage Δ
src/node_api.cc 76.19% <100.00%> (+0.05%) ⬆️

... and 54 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

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

The assumption in the comment "userland code can delete additional references in one finalizer" will break with the new change.

However, this assumption was not reflected in test test/js-native-api/6_object_wrap/6_object_wrap.cc. Would you mind updating the test to verify deleting another reference in the destructor of MyObject?

MyObject::~MyObject() {
  napi_delete_reference(env_, nested_);
  napi_delete_reference(env_, wrapper_);
}

@mertcanaltin
Copy link
Member Author

The assumption in the comment "userland code can delete additional references in one finalizer" will break with the new change.

However, this assumption was not reflected in test test/js-native-api/6_object_wrap/6_object_wrap.cc. Would you mind updating the test to verify deleting another reference in the destructor of MyObject?

MyObject::~MyObject() {
  napi_delete_reference(env_, nested_);
  napi_delete_reference(env_, wrapper_);
}

I updated, thanks

@mertcanaltin
Copy link
Member Author

tests passed in my local environment for macos but I think there is a problem in linux I will try

@mertcanaltin mertcanaltin changed the title node-api: optimize finalizer queue using container swap [WIP] node-api: optimize finalizer queue using container swap Apr 15, 2025
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++. needs-ci PRs that need a full CI run. node-api Issues and PRs related to the Node-API.
Projects
Status: Need Triage
Development

Successfully merging this pull request may close these issues.

4 participants