Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While trying to figure out #339 I discovered some optimization potential for recursive calls and host calls which led to a fantastic speed up.
This basically reuses the local variable
function_frame
inside a hot loop instead of hot swapping the most recent function frame using the call stack. This behavior was inherited by the oldwasmi
engine (so we could implement an improvement there as well potentially).Benchmarks
Before
After
Summary
We see improvements in
factorial_recursive
:1.4269 us
down to1.2433 us
-> 13% fasterrecursive_ok
:378.03 us
down to320.51 us
-> 16% fasterrecursive_trap
:39.987 us
down to30.745 us
-> 23% fasterhost_calls
:54.743 us
down to47.576 us
-> 13% faster