Skip to content
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

Generate default wazero.RuntimeConfig from Fx. #104

Merged
merged 1 commit into from
Apr 3, 2023
Merged

Conversation

lthibault
Copy link
Collaborator

@lthibault lthibault commented Mar 31, 2023

Creates a wazero.RuntimeConfig in Fx (pkg/runtime) that enables two features:

  • Shared compilaton cache across all wazero.Runtime instances
  • WithCloseOnContextDone
// WithCloseOnContextDone ensures the executions of functions to be closed under one of the following circumstances:
//
// 	- context.Context passed to the Call method of api.Function is canceled during execution. (i.e. ctx by context.WithCancel)
// 	- context.Context passed to the Call method of api.Function reaches timeout during execution. (i.e. ctx by context.WithTimeout or context.WithDeadline)
// 	- Close or CloseWithExitCode of api.Module is explicitly called during execution.
//
// This is especially useful when one wants to run untrusted Wasm binaries since otherwise, any invocation of
// api.Function can potentially block the corresponding Goroutine forever. Moreover, it might block the
// entire underlying OS thread which runs the api.Function call. See "Why it's safe to execute runtime-generated
// machine codes against async Goroutine preemption" section in internal/engine/compiler/RATIONALE.md for detail.
//
// Note that this comes with a bit of extra cost when enabled. The reason is that internally this forces
// interpreter and compiler runtimes to insert the periodical checks on the conditions above. For that reason,
// this is disabled by default.
//
// See examples in context_done_example_test.go for the end-to-end demonstrations.
//
// When the invocations of api.Function are closed due to this, sys.ExitError is raised to the callers and
// the api.Module from which the functions are derived is made closed.

@lthibault lthibault added the enhancement New feature or request label Mar 31, 2023
@lthibault lthibault requested a review from mikelsr March 31, 2023 19:38
@lthibault lthibault self-assigned this Mar 31, 2023
Copy link
Contributor

@mikelsr mikelsr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking some time to do this Louis. There are some tests failing but they don't seem to be related to this PR... I'm approving this but keeping an eye on them

@lthibault
Copy link
Collaborator Author

@mikelsr Yeah, that test has been a bit flaky lately. I'm going to re-run CI and make sure we eventually get a run where all tests pass.

@lthibault
Copy link
Collaborator Author

There we go!

I've noticed that I get random failures when the different Go versions are run in parallel, and that running CI for each version sequentially usually fixes things. I suspect GitHub is doing something weird.

Anyway, merging. Thanks for the review!

@lthibault lthibault merged commit 710fcdb into master Apr 3, 2023
@lthibault lthibault deleted the feat/fx-wasm branch April 3, 2023 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants