Skip to content

feat: added a function to track fuel consumption #807

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

Merged
merged 5 commits into from
Dec 17, 2024

Conversation

pwnintended
Copy link
Contributor

This PR adds a function to get the fuel consumed by a plugin. This is useful for systems that want to fairly balance compute. It's my first time doing anything in rust so let me know if something needs improvements!

@pwnintended pwnintended requested a review from zshipko as a code owner December 16, 2024 12:28
@zshipko
Copy link
Contributor

zshipko commented Dec 16, 2024

Thanks for working on this! I think this could be very helpful, one thing worth noting is the fuel is currently reset for before each call - I'm not sure if this will be an issue for your use case.

I have a branch with a slightly simplified implementation here: https://github.com/extism/extism/tree/consumed-fuel-direct - it avoids the extra field on Plugin by just calling store.get_fuel directly in the fuel_consumed - is there a benefit to storing the remaining fuel in the Plugin structure that I'm missing?

@pwnintended
Copy link
Contributor Author

We actually want fuel to be reset for each call, the usecase for us is to see how much fuel is consumed by a call so that we can keep track of this.

I don't see a reason to store it if it's reset after every call. Calling it directly like in your branch is better I think.

@zshipko
Copy link
Contributor

zshipko commented Dec 16, 2024

Great, I will push up my changes to your branch and merge once CI passes!

@zshipko zshipko merged commit 98800fe into extism:main Dec 17, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants