Comments (7)
Thanks for the swift response. Applying codegen-units and other common settings to wasmi
and wasmi_core
doesn't seem to make any difference. This may be the root cause:
The downside of this change though was that the executor's implementation is now generic over a T
If substantial parts of the executor are not codegen's in wasmi but in my code, then that would explain why the overrides that I've tried don't help. Increasing the optimization level on the host crate fixes the regression for the minimized example. I'll check how this shakes out in the actual code base.
from wasmi.
Hi @hanna-kruppe ,
thank you for reporting the issue.
The only significant change since v0.32.0-beta.16
was #1041.
This change was important to improve execution performance of host function calls significantly amongst others.
The downside of this change though was that the executor's implementation is now generic over a T
which was avoided. We avoided this before because the executor's inner loop is the hot-path when executing instructions via Wasmi and thus the main target for optimizations. It is very fragile to the correct optimization settings as you figured and it might be that with the recent change the fragility got bigger despite the overall performance wins.
It probably comes down to codegen-units=1
because with this setting the optimizer has awareness of the entirety of the inner loop and thus can apply optimizations it otherwise could not. (suspicion) You could try to see if thing improve significantly with configs like codegen-units=2
or 4
etc. The default with 16
is quite high.
Also you could try to disable debug assertions if you only care about fast compilation.
Unfortunately massive performance regressions are common with projects that highly depend on the Rust/LLVM optimizer doing its job. Explicit tail calls in Rust are probably the feature request hill I am going to die on ...
You could also try to solve your performance issues by only compiling the Wasmi dependency with the required optimization flags and everything else on default debug mode: https://doc.rust-lang.org/cargo/reference/profiles.html#overrides
In case you can carve out the Wasmi usage into its own sub-crate you could profit from incremental builds a lot so Wasmi only gets recompiled if its wrapper-crate changes but not if the main crate that you are working on a lot does.
from wasmi.
Thanks for the swift response. Applying codegen-units and other common settings to
wasmi
andwasmi_core
doesn't seem to make any difference. This may be the root cause:The downside of this change though was that the executor's implementation is now generic over a T
If substantial parts of the executor are not codegen's in wasmi but in my code, then that would explain why the overrides that I've tried don't help. Increasing the optimization level on the host crate fixes the regression for the minimized example. I'll check how this shakes out in the actual code base.
Yes, this indeed is the issue that you are facing due to the mentioned change.
One way to fix this is if you are able to carve out the Wasmi usage into its own crate. However, this crate needs to provide a non-generic API to the Wasmi implementation that is to be consumed by your main crate. This way your main crate would profit from incremental builds and your problem is likely gone. The effect is that a much smaller and more isolated part of your codebase is build with those high optimization levels.
from wasmi.
I'll check how this shakes out in the actual code base.
Please keep me updated about it. :)
from wasmi.
Yeah, setting opt-level = 2 for dev builds of the real crate that uses wasmi largely fixes my performance problems. I'll still have to shuffle some code around to avoid repeated rebuilds of that crate, and fine-tune the trade-off between build time and edit-compile-test cycles, but neither will be a problem. So I consider this issue solved. Thanks again for the swift and helpful responses!
You might want to consider adding a note about this somewhere in the documentation (e.g., next to the "production builds" section in README). If I hadn't already tried beta.16 and noticed the performance difference when upgrading, I might never have figured out that the performance I get from the profile overrides I tried was very far from optimal.
from wasmi.
Yeah, setting opt-level = 2 for dev builds of the real crate that uses wasmi largely fixes my performance problems. I'll still have to shuffle some code around to avoid repeated rebuilds of that crate, and fine-tune the trade-off between build time and edit-compile-test cycles, but neither will be a problem. So I consider this issue solved. Thanks again for the swift and helpful responses!
You might want to consider adding a note about this somewhere in the documentation (e.g., next to the "production builds" section in README). If I hadn't already tried beta.16 and noticed the performance difference when upgrading, I might never have figured out that the performance I get from the profile overrides I tried was very far from optimal.
Thank you for the update. Glad your problem is kinda fixed. Yes, a note is probably required here.
from wasmi.
@hanna-kruppe Thank you for the recommendation to mention this footgun somewhere. This is now documented in the new Wasmi usage guide: https://github.com/wasmi-labs/wasmi/blob/master/docs/usage.md
from wasmi.
Related Issues (20)
- Add customizable `wasmi::Engine` limits
- Reconsider proper fuel charging for lazily compiled functions
- Reduce `wasmi::Engine` memory consumption for storing function artifacts HOT 3
- Try to put the Wasmi engine internals into its own crate
- Wasmi v0.32 stable release preparations
- Wasmi `v0.32.0-beta.13` seems to have broken linking HOT 13
- CLI: cannot find definition for imported function HOT 4
- Optimize `Instance` handling in the `CallStack` HOT 1
- Thoughts on js-promise-integration HOT 4
- Redundant `local.tee` instruction with overwriting semantics causes miscompilation HOT 13
- Add `Store::call_hook` API HOT 4
- Add way to access unknown custom sections in `Module`
- Implement stable fuel metering HOT 6
- Implement support for `wasi-nn` HOT 1
- Failed to install `wasmi_cli`: `raw mutable pointers are not allowed in statics` (Rust 1.77.1) HOT 4
- How does the executor calculate i32 binary opcodes? HOT 2
- Prepare Wasmi bytecode, translator and executor for tail-call based instruction dispatch
- CI: fuzzing CI seems to not cache the corpus
- Make `CodeMap` lock-free
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wasmi.