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

Unify and pluralize promise resolution syscalls #2242

Merged
merged 2 commits into from
Jan 23, 2021
Merged

Conversation

FUDCo
Copy link
Contributor

@FUDCo FUDCo commented Jan 22, 2021

These changes lay the foundation for vat->kernel side of aggregate promise resolution, which is the logical dual of the tasks outlined in #2065. These changes provide a single, multi-promise resolution call that can be used to atomically resolve a promise and notify the kernel of any dependent promise resolutions.

@FUDCo FUDCo requested a review from warner January 22, 2021 09:15
@FUDCo FUDCo self-assigned this Jan 22, 2021
@FUDCo FUDCo added enhancement New feature or request SwingSet package: SwingSet labels Jan 22, 2021
@warner warner mentioned this pull request Jan 22, 2021
7 tasks
Copy link
Member

@warner warner left a comment

Choose a reason for hiding this comment

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

the Far markers should probably be re-instated, but the other changes are minor and I think we can defer them as long as we make sure they get addressed eventually

packages/SwingSet/src/kernel/kernelSyscall.js Show resolved Hide resolved
packages/SwingSet/test/test-vpid-liveslots.js Show resolved Hide resolved
packages/SwingSet/test/test-vpid-liveslots.js Show resolved Hide resolved
);
idx += 1;
kresolutions.push([kpid, rejected, kernelData]);
deleteCListEntryIfEasy(
Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty sure that we need to hold off deleting any clist entries until we've finished translating all of them (the same pattern we're using in the kernel-to-vat direction, on both the kernel side and the vat side).

Oh, maybe you're planning to change this in the next PR? It'll become an unconditional deleteCListEntry, rather than being limited to the "easy" cases, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes and yes and yes.

packages/SwingSet/src/vats/comms/delivery.js Outdated Show resolved Hide resolved
packages/SwingSet/src/vats/comms/delivery.js Show resolved Hide resolved
markPromiseAsResolved(vpid, resolution);
function handleResolutions(resolutions) {
const [[primaryVpid]] = resolutions;
const { subscribers, kernelIsSubscribed } = getPromiseSubscribers(
Copy link
Member

Choose a reason for hiding this comment

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

This feels wonky.. I think we'll need to make sure subscribers of all the promises are notified, not just the subscribers of the first one. I believe it's possible for one of the secondary promises in the batch to be one that the vat already knows about:

  • send P1 (unresolved) out through comms vat to remote A
  • send P2 (unresolved) out through comms vat to remote B
  • resolve P1 to data that contains P2
    • now the notify event is on the run-queue, but has not yet reached the comms vat
  • resolve P2 to something
    • now there are two notify events on the run-queue
  • the notify(comms-vat, P1) event reaches the top
    • the kernel creates a batch with P1 as the first promise, and P2 as the second
    • comms needs to send a two-promise batch (P1+P2) to remote A
    • comms needs to send a one-promise batch (just P2) to remote B
    • comms retires the kernel-facing vrefs for both P1 and P2
  • the notify(comms-vat, P2) event reaches the top
    • kernel ignores it because the P2 c-list entry was already retired

Figuring out what batches to create seems non-trivial, though, let's talk this through. I imagine this PR is good to land for now, but we'll need to examine this more closely and refine it in a later PR to make sure we're getting all the cases right.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds like a plausible argument, but I think that would explode into a bunch of very complicated mechanism which I'm not sure it is needed here. Keep in mind that primaryVpid is the root of a reference graph and that the comms vat is a simple pass through. So when notify notifies a bundle, that bundle travels as a unit through the network to the recipients; all the resolved promises in the bundle are in the same place.

If my thinking here is wrong, then we may have a more complicated mess on our hands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have filed ticket #2249 to make sure we don't lose track of this.

notifyOnePromise(vpid, vp.rejected, vp.data, willBeResolved);
}
// XXX question: do we need to call retirePromiseIDIfEasy (or some special
// comms vat version of it) here?
Copy link
Member

Choose a reason for hiding this comment

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

not here, because it needs to be done after the kernel-facing vrefs have been translated into comms-vat-local lrefs

in fact it might make sense to have resolveFromKernel be responsible for accumulating the willBeResolved list, and notify() becomes a no-op. hm.

packages/SwingSet/src/kernel/liveSlots.js Show resolved Hide resolved
@FUDCo FUDCo merged commit 6276286 into master Jan 23, 2021
@FUDCo FUDCo deleted the promise-gc-phase3-step1 branch January 23, 2021 09:17
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 this pull request may close these issues.

2 participants