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

various comms-GC-related cleanups #3363

Merged
merged 9 commits into from
Jun 20, 2021
Merged

various comms-GC-related cleanups #3363

merged 9 commits into from
Jun 20, 2021

Conversation

warner
Copy link
Member

@warner warner commented Jun 19, 2021

These commits smooth the way for the upcoming GC-over-comms branch. Mostly refactorings, although the processMaybeFree rearrangement has the potential to slightly modify the behavior (hopefully in a good way).

refs #3306

@warner warner added the SwingSet package: SwingSet label Jun 19, 2021
@warner warner added this to the Testnet: Stress Test Phase milestone Jun 19, 2021
@warner warner requested a review from FUDCo June 19, 2021 08:45
@warner warner self-assigned this Jun 19, 2021
@warner warner force-pushed the 3306-cleanup branch 3 times, most recently from 20af6b9 to 7f18cff Compare June 19, 2021 19:45
@warner warner requested a review from dckc June 19, 2021 22:39
Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

I haven't studied this part of the code enough to be confident that these changes preserve correctness; I just looked over the diffs and made a couple editorial comments.

packages/SwingSet/src/vats/comms/state.js Outdated Show resolved Hide resolved
packages/SwingSet/src/vats/comms/dispatch.js Show resolved Hide resolved
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.

This all seems fine.

@warner warner requested a review from FUDCo June 20, 2021 02:14
@warner
Copy link
Member Author

warner commented Jun 20, 2021

@FUDCo I added two more commits that warrant your attention, as they change the one-sided c-list retirement code we discussed many moons ago.

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.

Es ist gut.

warner added 9 commits June 20, 2021 14:36
There used to be code that called incrementRefCount / decrementRefCount with
a message `.result` value, which could be `null` if the message was a
sendOnly. All such code was changed to avoid calling inc/dec with an empty
reference, so now inc/dec can be slightly simpler.
The return value was leftover from an earlier approach, and will make
increasingly less sense as we introduce object-refcount checking.
This generalizes the refcounting code, which was previously only for
promises, into a form that's ready to track objects as well.

* replace `deadLocalPromises` with `maybeFree` (a set of lrefs)
* replace `purgeDeadLocalPromises()` with `processMaybeFree()`
* don't remove lrefs from the free list when incrementing, just
  let processMaybeFree notice the count is no longer zero
* change the main loop in `processMaybeFree()`
  * this ought to survive items being added to the set multiple times while
    it runs (even though Sets can be modified during iteration, I think the
    previous approach was vulnerable to losing items in unusual conditions)
  * tolerate promises that were deleted from the table before processing
Errors during comms processing were not being logged very usefully, and
are more likely to indicate a bug in the comms code than to be something
provoked by userspace, so log any errors during `dispach()` before
re-throwing them.

Remove a number of helper functions in preparation for changes to the way GC
deliveries are handled.
When the comms vat resolves a promise, it begins a two-part retirement
process. Right after it sends the `resolve` message to the remote, it deletes
the outbound half of the c-list, because this promise ID is partially
retired, and the comms vat won't be referencing it in any outbound messages
again.

The inbound half is retained until the other side acknowledges the resolution
message (i.e. some inbound messages arrives which demonstrates awareness of
the `notify`, by including an `ackSeqNum` at least as large as the `seqNum`
of the outbound `notify`).

This changes the code to retain both sides of the c-list entry until the ack
is received. I think this winds up being slightly cleaner, and most
importantly it retains our ability to map local-ref to remote-ref, which
enables an upcoming change to `deleteRemoteMapping` / `deleteKernelMapping`
to only take a single argument (lref, not lref+rret), which is a lot cleaner,
and avoids some error cases.

refs #3306
The comms vat c-list management code has a pair of
functions (`deleteRemoteMapping` and `deleteKernelMapping`) to remove c-list
entries. These functions take both a local reference (lref) and an
externally-facing reference (kfref for the kernel-facing side, rref for the
remote-facing side).

This change removes the externally-facing reference from the API, so now you
call it with only the lref. Both functions look up the necessary reference
internally.

This removes an easy-to-make error from `deleteRemoteMapping()`, because
rrefs come in both inbound- and outbound- flavors, and calling
`deleteRemoteMapping()` with the wrong flavor would leave half the c-list
entry undeleted.
@warner warner merged commit c16fd6d into master Jun 20, 2021
@warner warner deleted the 3306-cleanup branch June 20, 2021 22:06
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.

3 participants