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

add VatWorker for local threads (Node.js "Worker") #1366

Closed
wants to merge 3 commits into from

Conversation

warner
Copy link
Member

@warner warner commented Aug 4, 2020

This adds a per-vat option to run the vat code in a separate thread, sharing the process with the main (kernel) thread, sending VatDelivery and VatSyscall objects over the postMessage channel. This isn't particularly useful by itself, but it establishes the protocol for running vats in a separate process, possibly written in a different language or using a different JS engine (like XS).

This 'nodeWorker' managertype has several limitations. The shallow ones are:

  • vatPowers is missing transformTildot, which shouldn't be hard to add
  • vatPowers.testLog is missing, only used for unit tests so we can probably live without it
  • vatPowers is missing makeGetMeter/transformMetering (and will probably never get them, since they're only used for within-vat metering and we're trying to get rid of that)
  • metering is not implemented at all

Metering shouldn't be too hard to add, although we'll probably make it an option, to avoid paying the instrumented-globals penalty when we aren't using it. We also need to add proper control over vat termination (via meter exhaustion or manually).

The deeper limitation is that nodeWorkers cannot block to wait for a syscall (like callNow), so they cannot invoke devices

Remaining design issues:

  • I'm not yet sure how the new manager should be organized, or where it should be located.
  • the 'local' vatManager can probably be refactored to share more code with the new 'nodeWorker' type

The controller/kernel acquired a new shutdown() method, to use at the end of unit tests that create nodeWorker -style workers. Without shutdown(), the worker thread would keep the process from ever exiting.

refs #1299

CC @dckc

@warner warner added the SwingSet package: SwingSet label Aug 4, 2020
@warner warner self-assigned this Aug 4, 2020
@warner warner force-pushed the 1299-node-vatworker branch 2 times, most recently from f87e167 to 738b875 Compare August 5, 2020 05:30
@warner warner marked this pull request as ready for review August 5, 2020 05:31
@warner warner requested a review from FUDCo August 5, 2020 05:31
@warner warner removed the request for review from FUDCo August 6, 2020 21:35
@warner warner marked this pull request as draft August 6, 2020 21:35
This adds a per-vat option to run the vat code in a separate thread, sharing
the process with the main (kernel) thread, sending VatDelivery and VatSyscall
objects over the postMessage channel. This isn't particularly useful by
itself, but it establishes the protocol for running vats in a
separate *process*, possibly written in a different language or using a
different JS engine (like XS).

This 'nodeWorker' managertype has several limitations. The shallow ones are:

* vatPowers is missing transformTildot, which shouldn't be hard to add
* vatPowers.testLog is missing, only used for unit tests so we can probably
live without it
* vatPowers is missing makeGetMeter/transformMetering (and will probably
never get them, since they're only used for within-vat metering and we're
trying to get rid of that)
* metering is not implemented at all
* delivery transcripts (and replaying one) is not yet implemented

Metering shouldn't be too hard to add, although we'll probably make it an
option, to avoid paying the instrumented-globals penalty when we aren't using
it. We also need to add proper control over vat termination (via meter
exhaustion or manually).

The deeper limitation is that nodeWorkers cannot block to wait for a
syscall (like `callNow`), so they cannot invoke devices

Remaining design issues:

* I'm not yet sure how the new manager should be organized, or where it
should be located.
* the 'local' vatManager can probably be refactored to share more code with
the new 'nodeWorker' type

The controller/kernel acquired a new `shutdown()` method, to use at the end
of unit tests that create `nodeWorker` -style workers. Without `shutdown()`,
the worker thread would keep the process from ever exiting.

The process of creating vatManagers was refactored into a single
vatManagerFactory(vatID, options). Some options were added, and others fixed:
managerType, enableSetup, enableInternalMetering.

refs #1299
@warner warner changed the base branch from master to 1127-vat-manager-factory August 7, 2020 03:41
@warner
Copy link
Member Author

warner commented Aug 7, 2020

closing this one to use a different branch

@warner warner closed this Aug 7, 2020
@warner warner deleted the 1299-node-vatworker branch August 7, 2020 03:46
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.

1 participant