wasmtime icon indicating copy to clipboard operation
wasmtime copied to clipboard

c-api: allow top level API to set `wasm-timeout`

Open flouthoc opened this issue 2 years ago • 3 comments

Feature

Hi Folks,

Thanks for creating this wonderful runtime. I was wondering if there are any plans to expose wasm-timeout at c-api level ? It will allow users of c-api to timout the runtime as per the needs.

Benefit

Provides a timout knob for c-api users, giving more control to the end users.

Implementation

Maybe creating a top level interface and make timeout part of wasi_config_t could work ?

flouthoc avatar Oct 16 '22 05:10 flouthoc

I can understand that more than enough issues are already there and upstream maintainers are already busy, If the idea looks good I'd like to help by implementing this feature. :smile:

flouthoc avatar Oct 16 '22 05:10 flouthoc

Wasmtime doesn't have a native timeout knob precisely in its embedding API, but the CLI offers a timeout option as built from other primitives in the embedding API. One mechanism for timeouts is epochs which is possible through wasmtime_engine_increment_epoch and wasmtime_config_epoch_interruption_set. Another option is possible through wasmtime_config_consume_fuel_set and wasmtime_context_add_fuel. Are you able to combine those to satisfy your embedding use case?

alexcrichton avatar Oct 17 '22 14:10 alexcrichton

Wasmtime doesn't have a native timeout knob precisely in its embedding API, but the CLI offers a timeout option as built from other primitives in the embedding API. One mechanism for timeouts is epochs which is possible through wasmtime_engine_increment_epoch and wasmtime_config_epoch_interruption_set. Another option is possible through wasmtime_config_consume_fuel_set and wasmtime_context_add_fuel. Are you able to combine those to satisfy your embedding use case?

@alexcrichton Thanks a lot for checking this, I'll give it a try today and comment back here :)

flouthoc avatar Oct 17 '22 14:10 flouthoc