node-api: use container swap in DrainFinalizerQueue to reduce erase overhead#57861
node-api: use container swap in DrainFinalizerQueue to reduce erase overhead#57861mertcanaltin wants to merge 2 commits intonodejs:mainfrom
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:
|
legendecas
left a comment
There was a problem hiding this comment.
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); |
@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