Durable Coroutines for Go(github.com) |
Durable Coroutines for Go(github.com) |
edit: here it is https://dl.acm.org/doi/10.1145/949344.949362 It was a built-in bytecode interpreter with suspendable threads
It changed significantly how you think about cooperating processes. It was like watching 2 processes have a conversation with each other without the controlling code getting involved in any way. Also, if you save the coros after each call, you can get step-by-step replays which are very helpful in debugging.
The durable coroutine library is one part of a larger system we're releasing soon. See https://stealthrocket.tech/blog/fairy-tales-of-workflow-orch... for more information :)
As you can imagine there are a lot of challenges with it, but ideas are welcome!
This seems like a situation where defining the data structure in two different ways might be good?
https://github.com/stealthrocket/coroutine/blob/main/getg_am...
type Task struct {
I int
}
func (t *Task) Next() (bool, int) {
if t.I < 3 {
return t.I++, true
}
return 0, false
}
var t Task
t.Next()
json.Marshal(t)What if there were tools to inspect and debug the coroutine state? That's an area we're exploring now.
what if u build a wasm runtime that can save and restore memory with and execution states, sounds much more full proof. or i might have misunderstood this idea :D.
WASM is also not as mature of a tech for server side systems, a lot is left to figure out so the type of applications that you can build with it remains limited.
I’d be excited to see support for something like this get built tho!
In the case of network connections, the user could instead serialize connection details and then recreate the connection when deserializing the coroutine state. Same thing for files, where instead of serializing unstable low-level details like the file descriptor, the user can instead serialize higher level information (path, open flags, etc) and recreate the open file when deserializing the coroutine state.
In other languages they were used coz they were far lighter than native threads but that's not the case in Go