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

Improve FuelConsumptionMode::Lazy #874

Closed
Robbepop opened this issue Jan 4, 2024 · 0 comments · Fixed by #877
Closed

Improve FuelConsumptionMode::Lazy #874

Robbepop opened this issue Jan 4, 2024 · 0 comments · Fixed by #877
Assignees
Labels
enhancement New feature or request

Comments

@Robbepop
Copy link
Member

Robbepop commented Jan 4, 2024

Currently FuelConsumptionMode::Lazy leads to pre-checking if enough fuel is available for a full memory.grow or table.grow operation, even though it is clear that this operation will fail and thus won't be expensive at all.

We implemented this to be conservative.

However, this led us to requiring the FuelConsumptionMode::Eager in order to properly estimate required fuel for Wasm blob execution since with FuelConsumptionMode::Lazy the returned estimated fuel would be lower than what the same mode needed for execution with pre-checking.

The idea now is to remove pre-checking fuel for full execution and instead have an O(1) check to see whether the memory or table can actually grow and only afterwards charge for the full amount and do the operation assuming success.

This way we can remove the FuelConsumptionMode::Eager and thus FuelConsumptionMode entirely since FuelConsumptionMode::Lazy (which will become the default behavior) can handle both execution as well as fuel estimation.

Note: Pre-checking applies to all affected instructions, namely:

  1. memory.{grow, copy, fill}
  2. data.init
  3. table.{grow, copy, fill}
  4. elem.init
@Robbepop Robbepop added the enhancement New feature or request label Jan 4, 2024
@Robbepop Robbepop self-assigned this Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant