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
wasm files are very slow to load (C# PDK, Rust SDK) #710
Comments
Hello @Somfic, thanks for reporting the issue. I was able to reproduce it: use extism::*;
host_fn!(log(userData: (), line: String) -> i64 {
println!("log: {}", line);
return Ok(0);
});
fn main() {
// let file = Wasm::file("D:\\x\\dotnet\\readmeapp\\bin\\Debug\\net8.0\\wasi-wasm\\AppBundle\\readmeapp.wasm");
let file = Wasm::file("D:\\x\\dotnet\\readmeapp\\bin\\Release\\net8.0\\wasi-wasm\\AppBundle\\readmeapp.wasm");
let manifest = Manifest::new([file]);
let x = UserData::new(());
println!("{}: loading plugin", chrono::Utc::now());
let plugin = PluginBuilder::new(manifest)
.with_wasi(true)
.with_function("log", [PTR], [PTR], x, |plugin, inputs, outputs, user_data| {
log(plugin, inputs, outputs, user_data)
})
.build();
println!("{}: done", chrono::Utc::now());
} This is the output:
This is not normal, I will take a deeper look |
A minimal repro: use extism::*;
fn main() {
let file = Wasm::file(
"D:\\x\\dotnet\\readmeapp\\bin\\Release\\net8.0\\wasi-wasm\\AppBundle\\readmeapp.wasm",
);
let manifest = Manifest::new([file]);
println!("{}: loading plugin", chrono::Utc::now());
let _plugin = Plugin::new(manifest, [], true);
println!("{}: done", chrono::Utc::now());
} namespace MyPlugin;
public static class Plugin
{
static void Main()
{
}
} wazero: 406ms
Rust: ~12 seconds
cargo.toml [package]
name = "rust-host"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[depdendencies]
[dependencies]
chrono = "0.4.38"
extism = "1.2.0" compiled wasm: |
cc @zshipko |
@mhmd-azeez how does |
@zshipko 2 notes:
|
running with |
Going to close this as completed -- feel free to re-open if there are any further issues related to load time of a module though :) |
Hi!
New to WASM but excited to start. I am creating a plugin system for my application that’s written in Rust. I wrote a test plugin in C# and compiled it to a wasm file (~25mb for 1 import & 1 export). When I load the compiled wasm in my Rust application it takes ~45 seconds to load the wasm (M1 MacBook). Am I doing something wrong or is this expected performance?
C# plugin code:
Rust code:
My test case that loads the wasm generated by the plugin takes ~45 seconds to complete.
I feel like something is not right. Is my compiled plugin bloated by C#?
count_vowels.wasm
is 1.7mb and is around the same complexity, but loads <1 sec.The text was updated successfully, but these errors were encountered: