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

Optimization: pre-load default memory bytes upon Instance reset in executor #756

Closed
3 tasks
Robbepop opened this issue Sep 6, 2023 · 2 comments
Closed
3 tasks
Labels
good first issue Good for newcomers optimization An performance optimization issue.

Comments

@Robbepop
Copy link
Member

Robbepop commented Sep 6, 2023

Currently when executing wasmi bytecode there is the so-called InstanceCache which caches data frequently used during wasmi bytecode execution such as the default Memory bytes.
Whenever calling a function that originates from a different Instance this InstanceCache and all of its cached data is reset.
These default Memory bytes are loaded upon their first use after such an InstanceCache reset. The upside is that default Memory query is not done if no instructions interacting with the default Memory are executed. The downside is that this incurs a minor dispatch for every such instruction.

The idea behind this issue is to pre-load the default Memory bytes upon resetting the InstanceCache and when there is no default Memory to simply use a static [] as placeholder default memory bytes.

The downside of this approach is that resetting the InstanceCache becomes slightly more expensive, however, instructions interacting with the default Memory become a bit cheaper.

A wasmi execution that calls a lot of functions imported from different Wasm module instances or one that successfully grows the default Memory often (which is unlikely) might regress in their performance, whereas a wasmi execution that has a lot of Memory instructions such as i32.load, f64.store, etc. should see a performance improvement.

Further benchmarks are going to be needed once this has been implemented.

  • Implement pre-loading of the default Memory bytes as described above.
  • Conduct benchmarks and explain the results.
  • If needed: Maybe introduce new benchmarks that properly show the performance improvements.
@Robbepop Robbepop added the optimization An performance optimization issue. label Sep 6, 2023
@Robbepop
Copy link
Member Author

This issue was tackled by this PR: #769

The outcome was not satisfying but maybe the implementation was problematic and could have been improved in order to yield successful results.

@Robbepop Robbepop added the good first issue Good for newcomers label Nov 25, 2023
@Robbepop
Copy link
Member Author

Closed due to bad experimental results: #756 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers optimization An performance optimization issue.
Projects
None yet
Development

No branches or pull requests

1 participant