wain icon indicating copy to clipboard operation
wain copied to clipboard

Resource limits

Open oli-cosmian opened this issue 4 years ago • 3 comments

Once an execution is started, as a caller I have no control over the amount of memory and CPU time that is being used. Do you think it would be reasonable to

  • allow setting hard limits that will make additional allocations fail
  • stop the execution after a certain number of instructions?

The execution limit could potentially be made possible without any such limit existing in the engine by exposing more internal api so instead of just invoking invoke and waiting for the result, some API for driving each step could be exposed.

oli-cosmian avatar Jun 16 '20 13:06 oli-cosmian

allow setting hard limits that will make additional allocations fail

I think this is reasonable since for example JVM has this functionality. Current wain implementation tries to use memory until hitting bad alloc. But some use case would want to limit memory usage in some restricted environment.

stop the execution after a certain number of instructions?

Does it mean steps? This doesn't sound very useful for me since I'm not able to come up with actual use case.

Currently wain is under development as I wrote in README.md. The current main goal is passing all official spec tests. After reaching the milestone, I think we can start to consider some functionalities like memory usage limit.

rhysd avatar Jun 17 '20 15:06 rhysd

Does it mean steps? This doesn't sound very useful for me since I'm not able to come up with actual use case.

Our use case would be to be able to stop wasm programs that got stuck in infinite loops, or even just super long running programs. I think it would also work if there were some way to tell the engine to shut down even though it still has more wasm to process. This way if the engine is running in a thread, another thread could tell it to safely shut down.

oli-cosmian avatar Jun 18 '20 07:06 oli-cosmian

I see. It would be useful to have execution steps limit and/or timeout.

I'll keep this issue open to consider the functionality in the future. Thank you for the point.

rhysd avatar Jun 19 '20 09:06 rhysd