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

Handle host function calls the same as other instructions in the Wasmi executor #970

Closed
Robbepop opened this issue Mar 27, 2024 · 1 comment · Fixed by #1041
Closed

Handle host function calls the same as other instructions in the Wasmi executor #970

Robbepop opened this issue Mar 27, 2024 · 1 comment · Fixed by #1041
Labels
cleanup Cleans up some region of the codebase. enhancement New feature or request

Comments

@Robbepop
Copy link
Member

Robbepop commented Mar 27, 2024

Currently the Wasmi executor treats host function calls different to any other Wasmi bytecode instruction execution. The reason for that is simple: In order to invoke host functions the executor needs to know about the generic host state type T of the Store<T>.
One design principle of the current Wasmi executor is to make it non-generic and thus we introduced the non-generic StoreInner and made the Wasmi executor work on it instead of Store<T>. The obvious downside is that we need special treatment for host function calls which is ugly. Also it necessitates returning a large struct from the Wasmi executor which is not perfect for the optimizer to handle well and might be the performance issue we see on some platforms.

As an aside this refactoring will also greatly help if we are ever going to use tail call dispatch for the Wasmi executor once explicit tail calls become a thing in Rust.

@Robbepop Robbepop added enhancement New feature or request cleanup Cleans up some region of the codebase. labels Mar 27, 2024
@Robbepop
Copy link
Member Author

I performed some local benchmarks with an experimental branch that simply removes host function calls and all their related handlers in the Wasmi executor to emulate what would happen if we were to implement this PR naively. The benchmarks showed no significant change indicating that either the experiment is flawed or that the optimizer can do a good enough job to reduce both cases to roughly the same assembly via aggressive inlining etc.

Further investigation needed.

The experimental branch can be found here: https://github.com/wasmi-labs/wasmi/tree/rf-experiment-host-fn-calls-nop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Cleans up some region of the codebase. enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant