Fork me on GitHub
#sci
<
2021-11-03
>
wombawomba15:11:29

Would it be possible in principle to serialize/deserialize SCI's state (to pause/resume computations)?

borkdude18:11:20

@wombawomba I think someone has tried this once with nippy and one of the issues was circular references within the state.

wombawomba19:11:35

Alright! If I wanted to give it a shot, how should I go about it?

phronmophobic19:11:22

essentially, you have a cyclical graph. there are many ways to represent a cyclical graph. I might suggest either EAV approach like datomic or just a graph approach with nodes and edges.

borkdude20:11:47

@wombawomba one of the problems is: how to persist functions. Red Planet Labs has some tricks for this which I recommended the last time someone tried this. https://tech.redplanetlabs.com/2020/01/06/serializing-and-deserializing-clojure-fns-with-nippy/. Unfortunately I can't find the conversation anymore.

Huahai23:11:58

One limitation of red planet labs solution is that it depends on eval. So it does not work with GraalVM. Otherwise, it works very well. For Datalevin, I had to use a special macro for serializable functions to send over the wire to the server.

borkdude07:11:38

Specter also relies on eval but I was able to patch specter to use SCI for eval to make it work with GraalVM. Perhaps the same can be done for this?

Huahai14:11:02

i remembered i tried that but it did not work. Forgot the reason, maybe it was the methodHandle stuff

borkdude20:11:29

The SCI context is essentially a map with an atom with a map inside of that. All of the things you wanted to save should be serializable somehow.

borkdude20:11:07

Hmm, perhaps @mkvlr also have some ideas about this since it's pretty similar to what Nextjournal is doing perhaps with Clerk.