-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add Config::fuel_cost to customize fuel cost func #5111
Conversation
Subscribe to Label Actioncc @peterhuene
This issue or pull request has been labeled: "wasmtime:api", "wasmtime:config"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
Label Messager: wasmtime:configIt looks like you are changing Wasmtime's configuration options. Make sure to
To modify this label's message, edit the To add new label messages or remove existing label messages, edit the |
Hmm, should I use saturating_add for adding |
I wonder how this interacts with the AOT compilation. Consider that the user creates the engine with a specific fuel cost function, then loads a module, and then serializes it into a file. Then, perhaps in another version of the program, changes the fuel cost function and loads the previously serialized module. However, the fuel behavior that the loaded module exhibits will be different from the configured fuel costs. I would argue that this is an unexpected behavior. At the very least, I would expect to get an error during the module loading. To do so, the metadata for the compiled artifact should embed the module costs, but that's not really possible with a closure. It seems to me that the costs schedule would better be represented, conceptually, by a |
Thanks for the PR here! Could you expand a bit more on the use case that you're envisioning for this? This is a pretty low-level degree of control to give from an embedding API around fuel and feels like a relatively large addition with the enum addition here (not that there's a better way to model this that I know of). I'm curious though if there's perhaps an alternative solution which doesn't expose such low-level control of the fuel costs, but there may not be. I would also be slightly concerned about the AOT-story here since in theory the costs all need to be equivalent, but that can also be "patched" by returning an error and disabling serialization if this |
Oh, I missed that In any case, the motivating use case was switching an existing runtime from wasmer, which has cost customization by default as part of its metering instrumentation and so we were utilizing that. I suppose it is worth looking into how valuable that actually is, when obviously the wasm doesn't map one-to-one to machine code anyway... |
Ok makes sense. I think we could have a compiled representation of the costs but that's somewhat overkill and probably not worth implementing. That's one reason why I was wondering what the purpose was for changing costs because if the default wasn't suitable for your use case one option is to either change the defaults or otherwise have various discrete cost modes which would avoid serializing large maps. |
That makes sense, I'll look at sketching out a simpler (configuration-wise) solution to this or probably just reworking fuel usage in our codebase. Thank you for your help! |
In case you haven't already seen it, I'll mention that Wasmtime's "epoch interruption" may be a good alternative to fuel, depending on what you're using it for. From the documentation:
|
Adds
Config::fuel_cost
as described in #5109. I'm not sure where test cases for fuel are, if they exist?