-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
src: integrate ContextifyContext to cppgc #56522
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #56522 +/- ##
=======================================
Coverage 89.20% 89.20%
=======================================
Files 662 662
Lines 191816 191818 +2
Branches 36926 36923 -3
=======================================
+ Hits 171102 171111 +9
+ Misses 13559 13555 -4
+ Partials 7155 7152 -3
|
28b6b67
to
4cfe15f
Compare
bcb919d
to
a4ef690
Compare
After tracing the lifetime of ContextifyContexts a bit I realized that ContextifyContext does not even need to do any special cleanups, as the weak global handles in the context list would just become empty when the cycle involving Context/ContextifyContext is unreachable and will get purged sooner or later. So this no longer depend on #56534 |
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 failed test-inspector-contexts
seems to be persistent and could be related
That test seems to be doing something pretty unreliable - calling gc() in a loop until a context is collected. It should at least do that with setImmediate to free up the main thread, but we also already know from all the workarounds in test/common/gc that there is no reliable way to count on one particular object to be garbage collected (modulo taking a heap snapshot but that's a hack that I prefer not to abuse). We can see if using setImmediate helps and if not, try allocating a ton of contexts and see if any of them would be destroyed. If none of it helps stabilizing the test maybe we should just remove it or mark it as flaky... |
d08c61f
to
9667ff6
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This simplifies the memory management of ContextifyContext, making all references visible to V8. The destructors don't need to do anything because when the wrapper is going away, the context is already going away or otherwise it would've been holding the wrapper alive, so there's no need to reset the pointers in the context. Also, any global handles to the context would've been empty at this point, and the per-Environment context tracking code is capable of dealing with empty handles from contexts purged elsewhere. To this end, the context tracking code also purges empty handles from the list now, to prevent keeping too many empty handles around.
8b366bd
to
e67c128
Compare
* The v8::TracedReference and the ContextEmbedderIndex::kContextifyContext | ||
* slot in the context act as shortcuts from the node::ContextifyContext | ||
* C++ object to the V8 context. | ||
*/ |
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.
Love the additional comment detail :-)
Landed in cee63dc...74717cb |
PR-URL: #56522 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
This simplifies the memory management of ContextifyContext, making all references visible to V8. The destructors don't need to do anything because when the wrapper is going away, the context is already going away or otherwise it would've been holding the wrapper alive, so there's no need to reset the pointers in the context. Also, any global handles to the context would've been empty at this point, and the per-Environment context tracking code is capable of dealing with empty handles from contexts purged elsewhere. To this end, the context tracking code also purges empty handles from the list now, to prevent keeping too many empty handles around. PR-URL: #56522 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
This simplifies the memory management of ContextifyContext,
making all references visible to V8.
The destructors don't need to do anything because when the wrapper is
going away, the context is already going away or otherwise it would've
been holding the wrapper alive, so there's no need to reset the
pointers in the context. Also, any global handles to the context
would've been empty at this point, and the per-Environment context
tracking code is capable of dealing with empty handles from contexts
purged elsewhere.
To this end, the context tracking code also purges empty handles
from the list now, to prevent keeping too many empty handles around.