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

liveslots finalizers do syscall.dropImport, remove safety pins #3147

Closed
3 tasks done
warner opened this issue May 21, 2021 · 0 comments · Fixed by #3164
Closed
3 tasks done

liveslots finalizers do syscall.dropImport, remove safety pins #3147

warner opened this issue May 21, 2021 · 0 comments · Fixed by #3164
Assignees
Labels
enhancement New feature or request SwingSet package: SwingSet

Comments

@warner
Copy link
Member

warner commented May 21, 2021

What is the Problem Being Solved?

The vat-side delivery of GC events is driven by FinalizationRegistry callbacks firing at end-of-crank, after GC has been provoked and finalizers have had a chance to run. This populates the "dead set", which is then scanned to see what items are safe to drop, which can be retired, and what needs to be processed further.

GC as a whole will start saving RAM when:

  • the liveslots "safety pins" are removed, allowing objects to be collected (this ticket)
  • liveslots responds to finalizers and emits dropImport at the right time (this ticket)
  • the kernel processes refcounts and emits dispatch.dropExport
  • the kernel acts upon syscall.dropImport by decrementing refcounts
  • liveslots acts upon dispatch.dropExport (by dropping its strongref to the Remotable)

part of #3106

Description of the Design

  • change the liveslots dispatch function.
    • currently it waits for the userspace to become idle, then returns
    • instead, when userspace becomes idle, it will use gcAndFinalize to provoke a GC sweep (using some engine-specific means) and wait long enough for finalizers to run
    • then processDeadSet() will be called
  • finalizers already collect dead vrefs in the dead set, no change needed there
  • processDeadSet must examine each now-un-strong-referenced vref and decide what to do:
    • for Presences, if the vref is not reachable by the virtual object manager (VOM should track Presence vrefs used in virtualized data, to inhibit dropImport #3133), can be sent to dropImport
      • later, we'll also ask the VOM if the vref is in use as a key of a Weak Map/Set, and thus still recognizable, and if not, also send it to retireImport. but not today.
    • Representatives are exports, and for now are ignored
    • Remotables are sent to syscall.retireExport, since once the Remotable is gone, nobody can ever reach it again

Dependencies

It won't be safe to remove the safety pins until everything inside the vat is holding on to the objects they're supposed to. This means:

Test Plan

Unit tests which create a liveslots instance (without a kernel) whose userspace code creates and unreferences various objects. The test will observe the syscalls it makes to assert they are the expected ones.

@warner warner added enhancement New feature or request SwingSet package: SwingSet labels May 21, 2021
@warner warner self-assigned this May 21, 2021
warner added a commit that referenced this issue May 24, 2021
Change liveslots to provoke GC at mid-crank, then process the "dead set" and
emit `syscall.dropImports` for everything we can.

For now, we conservatively assume that everything remains recognizable, so we
do *not* emit `syscall.retireImport` for anything. The vref might be used as
a WeakMap/WeakSet key, and the VOM isn't yet tracking those. When #3161 is
done, we'll change liveslots to ask the VOM about each vref, and retire the
ones it does not know how to recognize (which will hopefully be the majority
of them).

closes #3147
refs #2615
refs #2660
warner added a commit that referenced this issue May 25, 2021
Change liveslots to provoke GC at mid-crank, then process the "dead set" and
emit `syscall.dropImports` for everything we can.

For now, we conservatively assume that everything remains recognizable, so we
do *not* emit `syscall.retireImport` for anything. The vref might be used as
a WeakMap/WeakSet key, and the VOM isn't yet tracking those. When #3161 is
done, we'll change liveslots to ask the VOM about each vref, and retire the
ones it does not know how to recognize (which will hopefully be the majority
of them).

closes #3147
refs #2615
refs #2660
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

Successfully merging a pull request may close this issue.

1 participant