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

Question: Why does ResourceLimiter not provide a limit for global variables and functions? #6668

Closed
Robbepop opened this issue Jun 29, 2023 · 3 comments

Comments

@Robbepop
Copy link
Contributor

As can be seen in the docs (https://docs.rs/wasmtime/10.0.1/wasmtime/trait.ResourceLimiter.html) the ResourceLimiter provides limits for Instance, Memory and Table instance counts but not for Global and Func.

This question came up in wasmi-labs/wasmi#737 and we were wondering about the rationals behind this design.

Clarifications would be very welcome. :)

@Robbepop Robbepop changed the title Question: Why does ResourceLimiter not provide a limit for global variables? Question: Why does ResourceLimiter not provide a limit for global variables and functions? Jun 29, 2023
@alexcrichton
Copy link
Member

I don't think there's a main principle behind this per se, but I can attempt to retcon it a bit by saying that one difference between memories/tables vs funcs/globals is that the former have runtime lengths associated with them where the latter have a static size which doesn't change. Not to say functions/globals couldn't be limited, however.

In Wasmtime at least the number of functions/globals factors into the size of a VMContext which is where limits would be placed, but the limit there is somewhat abstract where you'd say, for example, "instances should get at most 1MB of state" but what exactly is in that 1MB is up to Wasmtime (but globals/funcs fit in there and factor into that)

@Robbepop
Copy link
Contributor Author

Robbepop commented Jun 29, 2023

Thank you a lot for providing me with the rationals behind the design @alexcrichton !

Given that Wasmtime has a multitude of users compared to wasmi I was wondering why this was not asked before by users. At least for embedded systems were wasmi is used primarily I see a potential for users who want to limit globals and funcs as well. However, at the same time wasmi tries its best to stay as close to the Wasmtime API as possible for the benefit of all users only having to learn a single, reasonable API.

I guess this issue can be closed. If people actually need this they can open another issue with the request.

@alexcrichton
Copy link
Member

Ok, sounds reasonable!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants