saulecabrera opened PR #9472 from saulecabrera:winch-fuel
to bytecodealliance:main
:
Closes: https://github.com/bytecodealliance/wasmtime/issues/8090
This commit introduces the initial implementation of fuel-based interruption in Winch.
To maintain consistency with existing fuel semantics, this implementation closely follows the Wasmtime/Cranelift approach, with the following exception:
- Local Fuel Cache: Given Winch's emphasis on compilation speed, this implementation does not optimize for minimizing loads and stores. As a result, checking and incrementing fuel currently requires explicit loads and stores. Future optimizations may be considered to improve this aspect.
This commit also includes a small refactoring in the visitor, which introduces more generic "visitor hook" which enable handling the invariants that need to happen before and after emitting machine code for each Wasm operator.
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
saulecabrera requested elliottt for a review on PR #9472.
saulecabrera requested wasmtime-compiler-reviewers for a review on PR #9472.
saulecabrera requested wasmtime-core-reviewers for a review on PR #9472.
github-actions[bot] commented on PR #9472:
Subscribe to Label Action
cc @saulecabrera
<details>
This issue or pull request has been labeled: "winch"Thus the following users have been cc'd because of the following labels:
- saulecabrera: winch
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
alexcrichton submitted PR review:
Looks reasonable to me, tahnks for this!
One thought I had reading over this was that this should probably update some documentation somewhere around enabling fuel that Winch is supported. I don't think that's quite right though since we don't exhaustively document Winch's support on all other
Config
options, so documenting this as a one-off doesn't feel right. That being said it led me to another thought though that there was no change here associated with "ok actually allow Winch to use fuel". This means that it looks like we were silently accepting fuel-enabled-Config
even though Winch didn't support it.To handle that, either here or as a follow-up, mind updating the
Compiler for ...
in winch-codegen? IIRC there's a methodset_tunables
and it might be good to have Winch-specific logic to reject configurations that Winch doesn't support. For example Winch doesn't supportgenerate_native_debuginfo
orepoch_interruption
. This might help move some code out ofConfig::validate
as well and keep it in a Winch-specific location.
alexcrichton created PR review comment:
stray
;
alexcrichton created PR review comment:
Out of curiosity was the
vmruntime_limits
cache-of-sorts here added because the original methods were too slow? Or because the originalself.vmoffsets.ptr
wasn't accessible when the cache was needed?
alexcrichton submitted PR review:
Looks reasonable to me, thanks for this!
One thought I had reading over this was that this should probably update some documentation somewhere around enabling fuel that Winch is supported. I don't think that's quite right though since we don't exhaustively document Winch's support on all other
Config
options, so documenting this as a one-off doesn't feel right. That being said it led me to another thought though that there was no change here associated with "ok actually allow Winch to use fuel". This means that it looks like we were silently accepting fuel-enabled-Config
even though Winch didn't support it.To handle that, either here or as a follow-up, mind updating the
Compiler for ...
in winch-codegen? IIRC there's a methodset_tunables
and it might be good to have Winch-specific logic to reject configurations that Winch doesn't support. For example Winch doesn't supportgenerate_native_debuginfo
orepoch_interruption
. This might help move some code out ofConfig::validate
as well and keep it in a Winch-specific location.
saulecabrera submitted PR review.
saulecabrera created PR review comment:
Not really, I didn't perform extensive benchmarking here, I think it might be fine to immediately resolve the limits when constructing
FuncEnv
.
saulecabrera commented on PR #9472:
Thanks for the review @alexcrichton.
One thought I had reading over this was that this should probably update some documentation somewhere around enabling fuel that Winch is supported. I don't think that's quite right though since we don't exhaustively document Winch's support on all other Config options, so documenting this as a one-off doesn't feel right. That being said it led me to another thought though that there was no change here associated with "ok actually allow Winch to use fuel". This means that it looks like we were silently accepting fuel-enabled-Config even though Winch didn't support it.
I think it's reasonable to audit the
Config
options and be explicit in the documentation regarding those options that are not fully supported by Winch. I'll do that in a separate PR paired with the change to perform winch-specific configuration validation inset_tunables
in Winch's compiler implementation.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Ah ok makes sense, I ask because it felt a bit unidiomatic to copy a few fields from
VMOffsets
into a separate structure vs threading around theVMOffsets
themselves, but it's also a pretty minor point
saulecabrera commented on PR #9472:
@alexcrichton I've opened https://github.com/bytecodealliance/wasmtime/pull/9490 -- once https://github.com/bytecodealliance/wasmtime/pull/9490 lands, I'll rebase and land this change.
saulecabrera updated PR #9472.
saulecabrera updated PR #9472.
saulecabrera updated PR #9472.
saulecabrera merged PR #9472.
Last updated: Dec 23 2024 at 13:07 UTC