alexcrichton opened PR #3925 from delete-interurpts
to main
:
This commit removes the
Config::interruptable
configuration along with
theInterruptHandle
type from thewasmtime
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 theConfig::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 theConfig::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 toVMRuntimeLimits
.<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
alexcrichton updated PR #3925 from delete-interurpts
to main
.
alexcrichton updated PR #3925 from delete-interurpts
to main
.
cfallin submitted PR review.
cfallin created PR review comment:
Should we note here that it's also signal-safe (I think we have a similar note in the rustdoc text)?
cfallin created PR review comment:
Update type here in the doc comment (
VMRuntimeLimits
)?
cfallin submitted PR review.
cfallin created PR review comment:
/// WebAssembly code by instrumenting generated code to consume fuel as it
cfallin created PR review comment:
/// This can be used to deterministically prevent infinitely-executing
alexcrichton updated PR #3925 from delete-interurpts
to main
.
sunfishcode submitted PR review.
sunfishcode created PR review comment:
* \brief Configures WASI state within the specified store.
alexcrichton updated PR #3925 from delete-interurpts
to main
.
alexcrichton merged PR #3925.
Last updated: Dec 23 2024 at 12:05 UTC