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

fix(SwingSet): VOM tracks Presence vrefs in virtualized data #3157

Merged
merged 1 commit into from
May 25, 2021

Conversation

warner
Copy link
Member

@warner warner commented May 22, 2021

If userspace puts a Presence into the state of a virtual object, or
somewhere inside the value stored in vref-keyed makeWeakStore() entry, it
gets serialized and stored as a vref, which doesn't (and should not) keep the
Presence object alive. Allowing this Presence to leave RAM, remembering only
the vref on disk, is a non-trivial part of the memory savings we obtain by
using virtualized data.

However, just because there is currently no Presence (for a given vref)
does not mean that the vat cannot reach the vref. Liveslots will observe
the Presence being collected (when the finalizer runs), but if the vref is
still stored somewhere in virtualized data, liveslots must not emit a
syscall.dropImport for it.

This changes the virtual object manager to keep track of Presences used in
virtualized data, and remember their vref in a Set. When liveslots' wants to
dropImport a vref that no longer has a Presence, it will ask the VOM first.
With this Set, the VOM can inhibit the dropImport call until later.

At this stage, we simply add the vref to a Set and never remove it. This is
safe but conservative. In the future, we'll need some form of refcounting to
detect when the vref is no longer mentioned anywhere in virtualized data. At
that point, the VOM will need to inform liveslots (or some sort of
"reachability manager") that the VOM no longer needs the vref kept alive. The
syscall.dropImport can be sent when neither the VOM nor a Presence is
causing the vref to remain reachable.

closes #3133
refs #3106

@warner warner added the SwingSet package: SwingSet label May 22, 2021
@warner warner added this to the Testnet: Stress Test Phase milestone May 22, 2021
@warner warner requested a review from FUDCo May 22, 2021 07:28
@warner warner self-assigned this May 22, 2021
@warner warner changed the base branch from master to expose-gc May 24, 2021 05:09
@warner warner force-pushed the 3133-track-virtualized-presences branch from 7154624 to 42b8a3e Compare May 24, 2021 05:09
Base automatically changed from expose-gc to master May 25, 2021 04:55
Copy link
Contributor

@FUDCo FUDCo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far, so good.

package.json Outdated
Comment on lines 90 to 92
"nodeArguments": [
"--expose-gc"
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really want to enable this globally for all tests in the entire agoric-sdk or just for SwingSet? I can see there being an argument for the former; I just want to be sure it's deliberate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I don't have a choice: now that the top-level yarn test runs AVA directly (which enables more parallelism), it no longer consults the individual packages/*/package.json files: every test program in the entire monorepo gets the same set of flags.

Also, it's not a problem to expose gc to the start compartment of all programs.. it doesn't enable that code to anything worse than it could already do.

If userspace puts a Presence into the `state` of a virtual object, or
somewhere inside the value stored in vref-keyed `makeWeakStore()` entry, it
gets serialized and stored as a vref, which doesn't (and should not) keep the
Presence object alive. Allowing this Presence to leave RAM, remembering only
the vref on disk, is a non-trivial part of the memory savings we obtain by
using virtualized data.

However, just because there is currently no Presence (for a given vref)
does *not* mean that the vat cannot reach the vref. Liveslots will observe
the Presence being collected (when the finalizer runs), but if the vref is
still stored somewhere in virtualized data, liveslots must not emit a
`syscall.dropImport` for it.

This changes the virtual object manager to keep track of Presences used in
virtualized data, and remember their vref in a Set. When liveslots' wants to
`dropImport` a vref that no longer has a Presence, it will ask the VOM first.
With this Set, the VOM can inhibit the `dropImport` call until later.

At this stage, we simply add the vref to a Set and never remove it. This is
safe but conservative. In the future, we'll need some form of refcounting to
detect when the vref is no longer mentioned anywhere in virtualized data. At
that point, the VOM will need to inform liveslots (or some sort of
"reachability manager") that the VOM no longer needs the vref kept alive. The
`syscall.dropImport` can be sent when neither the VOM nor a Presence is
causing the vref to remain reachable.

closes #3133
refs #3106
@warner warner force-pushed the 3133-track-virtualized-presences branch from 42b8a3e to cb15717 Compare May 25, 2021 07:09
@warner warner enabled auto-merge (rebase) May 25, 2021 07:12
@warner warner merged commit 71c85ec into master May 25, 2021
@warner warner deleted the 3133-track-virtualized-presences branch May 25, 2021 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SwingSet package: SwingSet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VOM should track Presence vrefs used in virtualized data, to inhibit dropImport
2 participants