Skip to content
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

GC: implement full kernel-side refcount management #2646

Closed
warner opened this issue Mar 15, 2021 · 0 comments
Closed

GC: implement full kernel-side refcount management #2646

warner opened this issue Mar 15, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request SwingSet package: SwingSet

Comments

@warner
Copy link
Member

warner commented Mar 15, 2021

What is the Problem Being Solved?

Once the data feeds (dropImports) and actuators (dropExports) are in place, the biggest remaining subtask of #2615 will be to actually compute the unreachable objects and call dropExports for them.

The easier/cheaper piece of this is plain refcounting:

  • when we're informed about a refcount being decremented, add it to a candidate list
  • when we're done decrementing everything, process the list. for each item:
    • if the refcount is zero, find everything it used to point to, decref them, add them to the candiate list
      • then delete the item, and schedule it for a dropExports or something

The header/more expensive piece is to deal with cycles. The traditional approach is a full mark-and-sweep collector, but I'm worried about the expense of running that on-chain. @dtribble had an interesting idea: let an off-chain analysis tool compute the members of an unreachable cycle instead. It could submit a special transaction that says "I claim the following object/promise IDs form an unreachable clique". The kernel would then sweep the object graph starting from those points, to 1: make sure there are no edges pointing outside the cycle, and 2: make sure all the refcounts are accounted for by edges from within the clique. If both are true, the whole batch is deleted.

I'm also hopeful that there's some clever way to use bidirectional pointers to avoid any global mark-and-sweep operation, but I haven't sat down to consider the details.

@warner warner added enhancement New feature or request SwingSet package: SwingSet labels Mar 15, 2021
warner added a commit that referenced this issue Mar 16, 2021
Vat code can now use `vatPowers.disavow(presence)` (if enabled for that vat),
which will invoke `syscall.dropImports`. The kernel will delete the entry
from the vat's c-list, however no further reference-count management will
occur (that is scheduled for #2646).

This should be enough to allow work to proceed on liveslots (using WeakRef and
FinalizationRegistry) in parallel with kernel-side improvements.

Note that referencing a disavowed object is vat-fatal, either as the target
of a message, the argument of a message, or the resolution of a promise.

closes #2635
closes #2636
warner added a commit that referenced this issue Mar 17, 2021
Vat code can now use `vatPowers.disavow(presence)` (if enabled for that vat),
which will invoke `syscall.dropImports`. The kernel will delete the entry
from the vat's c-list, however no further reference-count management will
occur (that is scheduled for #2646).

This should be enough to allow work to proceed on liveslots (using WeakRef and
FinalizationRegistry) in parallel with kernel-side improvements.

Note that referencing a disavowed object is vat-fatal, either as the target
of a message, the argument of a message, or the resolution of a promise.

closes #2635
closes #2636
warner added a commit that referenced this issue Mar 19, 2021
Vat code can now use `vatPowers.disavow(presence)` (if enabled for that vat),
which will invoke `syscall.dropImports`. The kernel will delete the entry
from the vat's c-list, however no further reference-count management will
occur (that is scheduled for #2646).

This should be enough to allow work to proceed on liveslots (using WeakRef and
FinalizationRegistry) in parallel with kernel-side improvements.

Note that referencing a disavowed object is vat-fatal, either as the target
of a message, the argument of a message, or the resolution of a promise.

closes #2635
closes #2636
@warner warner self-assigned this May 20, 2021
@warner warner closed this as completed in d05eeb2 Jun 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request SwingSet package: SwingSet
Projects
None yet
Development

No branches or pull requests

1 participant