Test/adjust fuel consumption in bulk ops#13448
Conversation
This commit is the final step of bytecodealliance#13387 to add tests for all bulk operations and ensure that everything stays in sync. Notably all instructions have tests that their "infinite" version traps on out-of-fuel and additionally each version consumes a set amount of fuel. This required adjusting the fuel consumption loops as to where fuel was tweaked/flushed to ensure that fuel wasn't double-counted during loops and to also ensure that 1 fuel was consumed per-loop. This does surface some slightly odd behavior where sometimes fuel is counted as a per-byte operation and sometimes it's counted as a per-element operation. This happens due to how the code is structured where sometimes `array.fill`, for example, is a `memset` and sometimes it's per-element. The fuel consumption of `memset` is byte-based, for example, while it's per-element based for the manual loop. Regardless though it's still always deterministic for a particular wasm, and notably execution will still be limited by the dynamic operation size of these instructions. Closes bytecodealliance#13387
cfallin
left a comment
There was a problem hiding this comment.
Looks good!
This does surface some slightly odd behavior where sometimes fuel is counted as a per-byte operation and sometimes it's counted as a per-element operation. This happens due to how the code is structured where sometimes array.fill, for example, is a memset and sometimes it's per-element. The fuel consumption of memset is byte based, for example, while it's per-element based for the manual loop. Regardless though it's still always deterministic for a particular wasm, and notably execution will still be limited by the dynamic operation size of these instructions.
That seems fine to me; we've never made any guarantees about what one unit of fuel means (so we're free to increase or decrease "fuel efficiency1" as our needs require that...)
Footnotes
-
drive an electric Wasmtime today for incredible fuel efficiency! inquire inside for conditions of offer ↩
This commit is the final step of #13387 to add tests for all bulk operations and ensure that everything stays in sync. Notably all instructions have tests that their "infinite" version traps on out-of-fuel and additionally each version consumes a set amount of fuel. This required adjusting the fuel consumption loops as to where fuel was tweaked/flushed to ensure that fuel wasn't double-counted during loops and to also ensure that 1 fuel was consumed per-loop.
This does surface some slightly odd behavior where sometimes fuel is counted as a per-byte operation and sometimes it's counted as a per-element operation. This happens due to how the code is structured where sometimes
array.fill, for example, is amemsetand sometimes it's per-element. The fuel consumption ofmemsetis byte-based, for example, while it's per-element based for the manual loop. Regardless though it's still always deterministic for a particular wasm, and notably execution will still be limited by the dynamic operation size of these instructions.Closes #13387