Metering is not correct in presence of divergent control flow #4256
Labels
bug
Something isn't working
📦 lib-middlewares
About wasmer-middlewares
⏱ metering
priority-medium
Medium priority issue
Milestone
Describe the bug
Metering instrumentation does not work for if-else statements.
Because the instrumentation is injected naively when the change on control flow is detected, for if-else statements the cost of preceding instructions is only included for the if branch.
Example of a program which has incorrect costs.
The instrumented code produced by Wasmer:
We can see that the else branch has lower cost than it should.
Additional context
To fix the issue, the metering has to account for diverging control flow, or a different algorithm should be used.
The text was updated successfully, but these errors were encountered: