v8ken: orthogonally persistent JavaScript
Tom Van Cutsem <[email protected]> Fri, 29 Mar 2013 18:00:49 +0100
| Newsgroups | gmane.comp.lang.e.general,gmane.comp.capabilities.general |
|---|---|
| Message-ID | <CAKDfNj_ghKbwNg9T0ZNmn5rasVRqudZ0cCz5c97WMXM2j-pTJg@mail.gmail.com> |
Hi,
As some of you may know, my student Gillis has been working for some
time on v8-ken, which integrates the CKen [1] library with the v8
Javascript engine. The result is an orthogonally-persistent Javascript
engine. This is a key piece of the larger Dr. SES [3] puzzle.
I thought I'd send an update of how this work is progressing.
A couple of weeks ago, Gillis managed to overcome a few critical bugs
that now allow us to successfully restore a JS session from a heap
state file. I wouldn't use v8-ken for anything serious at this point,
but this is a huge milestone: it's now possible to crash a v8ken
process and restart it without loss of either local data, or messages
in-flight.
v8ken's messaging system is based on that of Ken (reliable,
FIFO-ordered messages carried over UDP). The message-passing interface
is fairly primitive at this point: simple unidirectional send and
receive of JSON-serialized messages, directed to vat IDs. No E-style
far references or promises, although that can probably all be layered
on top in JavaScript itself.
Our long-term goal is to integrate v8ken with node.js, so that we can
have an orthogonally persistent HTTP server. We don't have node.js
integration yet, but v8ken currently does have ad-hoc support for
serving HTTP requests. Consider a v8ken process started with the
following script:
var counter = 0;
var handleRequest = function(request, response) {
if (request.uri === "/counter") {
response.statusCode = 200;
response.status = "OK";
response.data = "Counter: " + (counter++);
}
};
Visiting http://127.0.0.1:8000/counter reveals the counter's value. If
the v8ken server crashes and restarts, the counter will retain its
state.
v8ken currently runs on 64-bit Linux. The adventurous might want to
try it out for themselves!
Cheers,
Tom
[1] v8-ken: https://github.com/supergillis/v8-ken
[2] CKen: http://ai.eecs.umich.edu/~tpkelly/Ken/
[3] Dr. SES: https://es-lab.googlecode.com/files/distr-erights-in-js.pdf