Stream: general

Topic: ✔ Overhead of linked functions


view this post on Zulip Ari Seyhun (Nov 17 2022 at 05:36):

I am calling some linked functions provided by the host from my guest wasm (all in Rust), and I've put some timers around the functions, and it seems like the overhead of calling a host function is 30ms?

I time my host function with this:

linker.func_wrap5_async("myapp", "execute",  Box::new(async move {
    let start = Instant::now();
    { ... }
    let end = Instant::now();
    println!("Host function time: {}ms", (end - start).as_millis());
}));

And my guest code does the same:

let start = Instant::now();
host::myapp::execute();
let end = Instant::now();
println!("Guest function time: {}ms", (end - start).as_millis());

And I get the output of:

Host function time: 0ms
Guest function time: 32ms

Is there some crazy overhead for calling host functions like this?

Nevermind :man_facepalming: I had start - end in the host. Should've been end - start

view this post on Zulip Notification Bot (Nov 17 2022 at 05:38):

Ari Seyhun has marked this topic as resolved.


Last updated: Nov 22 2024 at 16:03 UTC