homotopy-io / homotopy-rs

A Rust/WASM implementation of homotopy.io
https://homotopy.io
BSD 3-Clause "New" or "Revised" License
84 stars 7 forks source link

Handle actions that take too long #930

Open calintat opened 1 year ago

calintat commented 1 year ago

As seen in #927, it is possible to get into a situation where an action is running for too long and there is no way to abort that without losing the proof state. I can think of two solutions:

This will hopefully be less relevant once we make collapse faster, but it would still be good to have.

Any thoughts?

mlharaujo commented 1 year ago

This would be great. It's very frustrating to have to wait a lot of time just because I accidentally clicked something.

regular-citizen commented 1 year ago

At the technical level, I was thinking that one possible approach to do this without killing the entire prover would be to store a mutable global bail_expensive_computations_asap flag, and then define some kind of yield function with signature fn yield() -> Result<(), ModelError>, which just checks the flag,

Then everywhere in the codebase we could just do yield()?; and propagate the failure upwards. This is inspired by what actually co-routine runtimes do for expensive computations.

regular-citizen commented 1 year ago

Discussed this with @calintat with outcome that we would need to integrate seriously with the tokio runtime, and add a bunch of calls to yield_now in core, plus support for aborts.

NickHu commented 1 year ago

I think tokio is pretty hard to integrate with WASM, at least last time I checked... good luck