-
-
Notifications
You must be signed in to change notification settings - Fork 32k
node-api: use container swap in DrainFinalizerQueue to reduce erase overhead #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
node-api: use container swap in DrainFinalizerQueue to reduce erase overhead #57861
Conversation
Review requested:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #57861 +/- ##
==========================================
- Coverage 90.15% 90.13% -0.02%
==========================================
Files 630 629 -1
Lines 186756 186629 -127
Branches 36653 36623 -30
==========================================
- Hits 168369 168227 -142
- Misses 11189 11199 +10
- Partials 7198 7203 +5
🚀 New features to boost your workflow:
|
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.
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 |
tests passed in my local environment for macos but I think there is a problem in linux I will try |
#57861 (review) was not addressed. The change proposed does not fulfill the behavior as described in the original comment: Lines 116 to 118 in 68cc1c9
This change will crash the test #57981. |
thanks I updated it as you indicated here |
61b9793
to
8e74c92
Compare
8e74c92
to
a696b8b
Compare
Hello @vmoroz, @legendecas, @mhdawson I’ve updated this PR to implement the per-item finalizer drain as discussed—switching from value-based - pending_finalizers.erase(ref_tracker);
+ auto it = pending_finalizers.begin();
+ pending_finalizers.erase(it); |
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.
FWIW, the existing code always erase
the first item on the list. Though the new code LGTM as well.
@mertcanaltin , I do not see any meaningful difference from the existing code besides the declaring of the unnecessary |
thanks I am closing this pr as it does not contribute to the current code, thanks a lot for the information |
use container swap in DrainFinalizerQueue to reduce erase overhead