-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compiler: perform BuiltinFunctionCheckExitCode natively #1409
Comments
Nice!👍 |
If I understand correctly this boils down to EDIT: well not exactly that because |
no, you misunderstood |
ps the new benchmark's case should look like |
Ok, I just realized that this is in theory impossible - if we do this check completely in "native world", then Goroutine switch doesn't/may not happen and therefore the ExitCode might not get updated forever (See compiler/RATIONALE.md). That's why @evacchi is experiencing the forever-hung whatever change you make when t.Parallel was enabled in the tests in #1413. With that said, I am closing this as not planned. Thanks @evacchi for your investigation and try! |
Relates to tetratelabs#1409, tetratelabs#1413. Explains why the native check won't work. Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
wazeroir's BuiltinFunctionCheckExitCode operation has been introduced in the context cancelation integration in #1108. Basically, this operation is supposed to perform the check on
ModuleInstance.Closed
value, and exit the execution if the value is not zero.Currently, the compiler's implementation is pretty naive like simply exiting the native world and call
ModuleInstance.FailIfClosed
.wazero/internal/engine/compiler/impl_amd64.go
Lines 271 to 272 in 86444c6
wazero/internal/engine/compiler/engine.go
Lines 1012 to 1016 in 86444c6
but this comes with the cost -
BuiltinFunctionCheckExitCode
is inserted at all of theloop
instructions and each time we call a Go function.FailIfClosed
function checks the exit code atomically, but it is not necessary as in anyway the implementation is not synchronous (e.g. we don't check the code until the Wasm VM reaches loop instruction even when the context reaches timeout 10 years ago in extreme case).Given that assumption we do not need to check it synchronously, we could optimize the translation of
BuiltinFunctionCheckExitCode
by simply checking the exit code natively.The proposed change should come with
ExitCode
incompiler.compileBuiltinFunctionCheckExitCode
function for both arm64 and amd64callEngine.moduleInstance
The text was updated successfully, but these errors were encountered: