Comments (7)
running with —release
brings my loading time from ~45sec to ~200ms
from extism.
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:
2024-05-07 10:24:09.336664200 UTC: loading plugin
2024-05-07 10:24:21.305236100 UTC: done
This is not normal, I will take a deeper look
from extism.
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 :)
from extism.
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
PS D:\x\dotnet\readmeapp> dotnet publish
PS D:\x\dotnet\readmeapp> Measure-Command { extism call .\bin\Release\net8.0\wasi-wasm\AppBundle\readmeapp.wasm _start --wasi }
Days : 0
Hours : 0
Minutes : 0
Seconds : 0
Milliseconds : 406
Ticks : 4068725
TotalDays : 4.7091724537037E-06
TotalHours : 0.000113020138888889
TotalMinutes : 0.00678120833333333
TotalSeconds : 0.4068725
TotalMilliseconds : 406.8725
Rust: ~12 seconds
PS D:\x\rust\rust-host> cargo run
warning: unused manifest key: depdendencies
Compiling rust-host v0.1.0 (D:\x\rust\rust-host)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.26s
Running `target\debug\rust-host.exe`
2024-05-07 13:54:05.870944900 UTC: loading plugin
2024-05-07 13:54:17.159347400 UTC: done
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:
from extism.
cc @zshipko
from extism.
Rust: ~12 seconds
@mhmd-azeez how does cargo run --release
compare?
from extism.
@zshipko 2 notes:
- subsequent runs are much faster, guessing it's the caching layer doing its job:
PS D:\x\rust\rust-host> cargo run
warning: unused manifest key: depdendencies
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.17s
Running `target\debug\rust-host.exe`
2024-05-07 14:00:31.754239900 UTC: loading plugin
2024-05-07 14:00:44.102130 UTC: done
PS D:\x\rust\rust-host> cargo run
warning: unused manifest key: depdendencies
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.18s
Running `target\debug\rust-host.exe`
2024-05-07 14:00:46.274649600 UTC: loading plugin
2024-05-07 14:00:46.529963 UTC: done
- Release is faster, but still slower than wazero:
PS D:\x\rust\rust-host> cargo run --release
warning: unused manifest key: depdendencies
Finished `release` profile [optimized] target(s) in 0.19s
Running `target\release\rust-host.exe`
2024-05-07 14:05:57.543549900 UTC: loading plugin
2024-05-07 14:05:58.283204300 UTC: done
from extism.
Related Issues (20)
- feat: add manifest field to limit the size of Extism vars HOT 1
- Extism gem fails to load on Ruby 3.3.0 on macOS HOT 6
- Async / Await / Generators / Coroutines in Plugins HOT 4
- How to unload a plugin? HOT 4
- Could we get access to the `id` on `CurrentPlugin`
- add a feature to control which wasm backend is enabled? HOT 4
- getting a list of a plugin’s exported functions HOT 8
- ZMQ with Extism Plugins HOT 7
- allowlist WASI features/interfaces HOT 2
- Improve the libextism story on mac
- Update manifest properties w/ recently added fields HOT 1
- Limit manifest:`allowed_paths` to a single file HOT 2
- Support for Running Java Host Application on Windows HOT 15
- Missing `.so` file in `libextism-x86_64-unknown-linux-musl-v1.4.1.tar.gz`
- Host functions returning f32/f64 aren't working correctly
- Document error messages that can be returned by the runtime
- Expose LogTrace on Rust SDK HOT 1
- Scala plug-ins HOT 7
- reduce third-party github actions HOT 2
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 extism.