-
Notifications
You must be signed in to change notification settings - Fork 80
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
How to set resource limit in wasmtime-go? #101
Comments
Thanks for the report! The main type used for this is a I think the first steps to handling this would be filling out the C API for those constructs, and then it could be mirrored into the Go API as well. |
Thanks for your reply! I think that supporting wasm's resource restriction is an essential condition for wasm to run in a production environment, and the number of users of the wasmtime-go project should be quite large. |
I don't believe anyone is currently signed up specifically for doing this, but if you're interested we're always happy to review PRs for additions to the C API |
OK, although i am new to rust, i will have a try😊 |
Hello, any progress here?.. |
@alexcrichton Hi, can you give an example of a similar merged PR which adds something to the C API? I need the resource limit feature and would like to try to implement it myself. Similar PR would help me to get started, a lot. |
Unfortunately, no, but I would recommend reading over the Rust documentation for this, learning the C API's implementation a bit, and starting there. |
@alexcrichton Hello, If I want to contribute to C API, which sources should I look at? These, right? https://github.com/bytecodealliance/wasmtime/tree/main/crates/c-api |
Indeed! |
Can you please take a look at #171 It looks to me that there is no need to implement anything in C API, but I am not completely sure) |
* How to set resource limit in wasmtime-go? (#101) * Using dev version temporarily --------- Co-authored-by: Vitaly Volkov <[email protected]>
1. background
In my case, i want to limit the max memory that the *.wasm file can use, if it reached the limit, it can crash by OOM.
it's better for me to limit both stack and heap memory.
2. what i have found
In wasmtime, which is written by rust, i found some api to limit the resource:
cpu limit : https://docs.rs/wasmtime/0.29.0/wasmtime/struct.Config.html#method.consume_fuel
stack limit: https://docs.rs/wasmtime/0.29.0/wasmtime/struct.Config.html#method.consume_fuel
memory limit: https://docs.rs/wasmtime/0.29.0/wasmtime/struct.Config.html#method.consume_fuel
these features are so cool and meet my needs, i also found a project named lunatic, it build on wasmtime and allow users to set resource limit as the doc said:
3. my question
my host environment is written by golang, so i want to use wasmtime-go to load and run wasm instance, i know this project uses CGO to consume the C API of the Wasmtime project, but i can't find how to set resource limit in wasmtime-go API.
any ideas about this?
The text was updated successfully, but these errors were encountered: