Delete historical interruptable support in Wasmtime#3925
Conversation
This commit removes the `Config::interruptable` configuration along with the `InterruptHandle` type from the `wasmtime` crate. The original support for adding interruption to WebAssembly was added pretty early on in the history of Wasmtime when there was no other method to prevent an infinite loop from the host. Nowadays, however, there are alternative methods for interruption such as fuel or epoch-based interruption. One of the major downsides of `Config::interruptable` is that even when it's not enabled it forces an atomic swap to happen when entering WebAssembly code. This technically could be a non-atomic swap if the configuration option isn't enabled but that produces even more branch-y code on entry into WebAssembly which is already something we try to optimize. Calling into WebAssembly is on the order of a dozens of nanoseconds at this time and an atomic swap, even uncontended, can add up to 5ns on some platforms. The main goal of this PR is to remove this atomic swap on entry into WebAssembly. This is done by removing the `Config::interruptable` field entirely, moving all existing consumers to epochs instead which are suitable for the same purposes. This means that the stack overflow check is no longer entangled with the interruption check and perhaps one day we could continue to optimize that further as well. Some consequences of this change are: * Epochs are now the only method of remote-thread interruption. * There are no more Wasmtime traps that produces the `Interrupted` trap code, although we may wish to move future traps to this so I left it in place. * The C API support for interrupt handles was also removed and bindings for epoch methods were added. * Function-entry checks for interruption are a tiny bit less efficient since one check is performed for the stack limit and a second is performed for the epoch as opposed to the `Config::interruptable` style of bundling the stack limit and the interrupt check in one. It's expected though that this is likely to not really be measurable. * The old `VMInterrupts` structure is renamed to `VMRuntimeLimits`.
Subscribe to Label Actioncc @fitzgen, @peterhuene DetailsThis issue or pull request has been labeled: "fuzzing", "wasmtime:api", "wasmtime:c-api", "wasmtime:config", "wasmtime:docs"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
Label Messager: wasmtime:configIt looks like you are changing Wasmtime's configuration options. Make sure to
DetailsTo modify this label's message, edit the To add new label messages or remove existing label messages, edit the |
cfallin
left a comment
There was a problem hiding this comment.
LGTM -- this is a nice simplification!
Handles the changes made in bytecodealliance/wasmtime#3925
Handles the changes made in bytecodealliance/wasmtime#3925
Handles the changes made in bytecodealliance/wasmtime#3925
Handles the changes made in bytecodealliance/wasmtime#3925
Handles the changes made in bytecodealliance/wasmtime#3925
* Remove InterruptHandle, bind epochs Handles the changes made in bytecodealliance/wasmtime#3925 * Run clang-format
|
I would appreciate some guidance on how to achieve interruption support with async yielding now. Before The only idea I came up with is wrapping the But maybe I'm missing a better solution? |
|
Yes if you're using the epoch support for async yielding then you'll want to use a timeout-like approach to drop the future at an await point (or abortable as you mentioned) to stop execution of wasm altogether. |
Handles the changes made in bytecodealliance/wasmtime#3925
This commit removes the
Config::interruptableconfiguration along withthe
InterruptHandletype from thewasmtimecrate. The originalsupport for adding interruption to WebAssembly was added pretty early on
in the history of Wasmtime when there was no other method to prevent an
infinite loop from the host. Nowadays, however, there are alternative
methods for interruption such as fuel or epoch-based interruption.
One of the major downsides of
Config::interruptableis that even whenit's not enabled it forces an atomic swap to happen when entering
WebAssembly code. This technically could be a non-atomic swap if the
configuration option isn't enabled but that produces even more branch-y
code on entry into WebAssembly which is already something we try to
optimize. Calling into WebAssembly is on the order of a dozens of
nanoseconds at this time and an atomic swap, even uncontended, can add
up to 5ns on some platforms.
The main goal of this PR is to remove this atomic swap on entry into
WebAssembly. This is done by removing the
Config::interruptablefieldentirely, moving all existing consumers to epochs instead which are
suitable for the same purposes. This means that the stack overflow check
is no longer entangled with the interruption check and perhaps one day
we could continue to optimize that further as well.
Some consequences of this change are:
Interruptedtrapcode, although we may wish to move future traps to this so I left it
in place.
for epoch methods were added.
since one check is performed for the stack limit and a second is
performed for the epoch as opposed to the
Config::interruptablestyle of bundling the stack limit and the interrupt check in one. It's
expected though that this is likely to not really be measurable.
VMInterruptsstructure is renamed toVMRuntimeLimits.