Git Product home page Git Product logo

Comments (7)

Somfic avatar Somfic commented on June 12, 2024 3

running with —release brings my loading time from ~45sec to ~200ms

from extism.

mhmd-azeez avatar mhmd-azeez commented on June 12, 2024 1

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.

nilslice avatar nilslice commented on June 12, 2024 1

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.

mhmd-azeez avatar mhmd-azeez commented on June 12, 2024

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:

repro.zip

from extism.

mhmd-azeez avatar mhmd-azeez commented on June 12, 2024

cc @zshipko

from extism.

zshipko avatar zshipko commented on June 12, 2024

Rust: ~12 seconds

@mhmd-azeez how does cargo run --release compare?

from extism.

mhmd-azeez avatar mhmd-azeez commented on June 12, 2024

@zshipko 2 notes:

  1. 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
  1. 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.