-
Notifications
You must be signed in to change notification settings - Fork 227
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
fix: add WeakRef tracking to liveslots #1927
Conversation
0bea751
to
3f598b5
Compare
I think the Zoe test failure is because the decref arrived after the vat was deleted, so
I'll add a more specific test and a fix. |
464c386
to
f0721d9
Compare
199591e
to
f2288d1
Compare
Liveslots maintains an import count: each time a vref is mentioned in an inbound message, liveslots increments the counter. When user-level code forgets about the Presence object, eventually (in some future turn, probably not during one of this vat's cranks) the finalizer callback will run, and liveslots will send a `vatDecRef()` message to the kernel with the old count. This will eventually be wired up with kernel-side code that maintains a similar counter, which will be decremented, and when it reaches zero, we'll remove the c-list entry. The handling of Promises needs more thought. Currently we retain a strong reference to imported Promises until they are retired (which happens in certain cases of resolution). refs #1872
The test is skipped if the platform lacks a `WeakRef` global (Node.js v12), or if it lacks a `gc` global (Node.js v14 without `--expose-gc`).
Finalizer callbacks run at strange times, and can occur after the vat which dropped the import has been terminated and cleaned up (so there are no c-list entries left to remove). Ignore these. The unit test is necessarily probablistic. This particular sequence appears to exercise the previously-failing path about 50% of the time. The other 50% of the time it does not, and the test passes without accomplishing anything useful.
f2288d1
to
3f1b6f4
Compare
I'm deprioritizing this in favor of more deterministic forms of GC, we'll reassess it later. |
We're no longer pursuing this counter-based approach, instead we're relying upon the engine to give us deterministic GC so we can avoid the counters. See #2615 for the current plan. |
Liveslots maintains an import count: each time a vref is mentioned in an
inbound message, liveslots increments the counter. When user-level code
forgets about the Presence object, eventually (in some future turn, probably
not during one of this vat's cranks) the finalizer callback will run, and
liveslots will send a
vatDecRef()
message to the kernel with the old count.This will eventually be wired up with kernel-side code that maintains a
similar counter, which will be decremented, and when it reaches zero, we'll
remove the c-list entry.
The handling of Promises needs more thought. Currently we retain a strong
reference to imported Promises until they are retired (which happens in
certain cases of resolution).
refs #1872