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

Will it be possible to serialize state and limit execution time? #87

Open
frodeborli opened this issue Nov 2, 2019 · 1 comment
Open
Labels
❓ question Further information is requested
Projects

Comments

@frodeborli
Copy link

Summary

Will this extension support non-blocking operation and state serialization?

Additional details

It can in many cases be helpful to run code for a certain number of instructions, or milliseconds before execution is preemptively halted.

This can be useful for example in event loop environments such as swoole or ReactPHP.

To support this, it would be necessary that wasm methods could return a special "WasmHalted" object. This object could represent that execution was halted due to timeout, waiting for IO, or it could represent a request for opening a resource such as a file.

$delayed = $instance->sum(1, 2);

$delayed->run(1000); // 1000 instructions
$s = serialize($delayed);

$delayed = $instance->resume(unserialize($s)) ;

while(!$delayed->done()) {
    $delayed->run(1000):
} 
$delayed->result(); // done

I would love if this object could be serialized and resumed. Sure, the serialized object can become quite large, if the wasm binary uses a lot of memory but that would be my problem.

@frodeborli frodeborli added the ❓ question Further information is requested label Nov 2, 2019
@Hywan
Copy link
Contributor

Hywan commented Nov 6, 2019

So far, the Wasmer runtime (the underlying WebAssembly runtime) supports gas metering, but I don't think it is what you want. I think a first step is wasmerio/wasmer#480. This is implemented, but not the C API doesn't handle it for the moment. We can work on it though.

@Hywan Hywan added this to 🏁 Ready in Kanban Dec 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓ question Further information is requested
Projects
Kanban
  
🏁 Ready
Development

No branches or pull requests

2 participants