-
Notifications
You must be signed in to change notification settings - Fork 173
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
WASM instances support resource limit #607
Comments
/assign |
Cool ! |
进展: |
action:
stack 和memory再说 |
进展:测试中 |
action:
|
我们的wasm shim里面集成了一个global的wasmtime,这样或许可以解决你们的concurrency run multiple wasm module的问题。不过问题是 |
/good-first-issue cancel |
This issue has been automatically marked as stale because it has not had recent activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue or help wanted) or other activity occurs. Thank you for your contributions. |
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue or help wanted. Thank you for your contributions. |
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue or help wanted. Thank you for your contributions. |
1. Background
In a FaaS scenario, Layotto supports loading and running multiple wasm-based functions at the same time. WebAssembly ensures that multiple functions run in the same process without affecting each other. However, currently Layotto does not support configuring the maximum used resources for each function, so we hope to add this capability.
2. Why is this needed?
If you can set available resources (such as heap, stack, CPU, etc.) for the function, then on the one hand, you can better pre-allocate resources, and on the other hand, you can lay a solid foundation for the function platform's ability to pay on demand.
3. What can we try?
Regarding how to limit the resources that can be used by a wasm instance, the possible directions are as follows:
A. At compile time
View the source code of the wasm file and you will find a declaration about memory. For details, please refer to the WebAssembly spec.
The value here represents the number of pages that can be used, 1 page = 64K
For Rust, you can use the following command to set the available memory size at compile time:
B. At run time
The running of wasm instances depends on the runtime. Some runtimes support setting available resources for loading and running wasm instances. As for wasmtime:
Result:
4. Goals
This is a direction that requires long-term construction, and some features of it may not be supported at this stage or not supported perfectly. Therefore, our goal is to do it little by little, and then develop step by step.
A few sub-items I can think of for now:
5. Other references
中文
一、背景
在 FaaS 场景中, Layotto 支持同时加载并运行多个以 wasm 为载体的函数。WebAssembly 可以保证多个函数虽然运行在同一个进程中,但互相之间不受影响。不过目前 Layotto 还不支持为每个函数配置最大使用的资源,因此我们希望建设这块能力。
二、意义&价值
如果能为函数设置可使用的资源(如堆、栈、CPU等),那么一方面可以更好的预分配资源,另一方面可以为函数平台按需付费等能力打好基础。
三、可尝试的方向
关于如何对 wasm 实例可使用的资源进行限制,可能尝试的方向如下:
A、编译期
查看 wasm 文件的源码会发现有关于 memory 的声明,详细信息可以参考 WebAssembly spec.
这里的值表示可使用的页数,1页 = 64K
以 Rust 为例,可以使用如下命令在编译期设置可使用的内存大小:
B、运行期
wasm 实例的运行依赖运行时,一些运行时支持为加载运行的 wasm 实例设置可使用资源,以 wasmtime 为例:
运行结果:
四、目标
这是一个需要长期建设的方向,现阶段不一定都能支持,比如可能只支持某些能力,或者支持的不够完善,因此我们的目标是一点点做,当前能做到什么程度就做到什么程度,后续再逐步迭代。
暂时能想到的几个子项:
五、其他参考资料
The text was updated successfully, but these errors were encountered: