Stream: general

Topic: ✔ Help?


view this post on Zulip Sahil Garg (Jun 14 2022 at 07:48):

Hi Folks,

I am new to wasmtime. So was trying to find a way to calculate the CPU consumption per module for metering purposes. I saw something related to "FUEL" (https://docs.wasmtime.dev/api/wasmtime/struct.Config.html#method.consume_fuel ), but is there a direct way to calculate [ Ghz-seconds]? Alternatively, Is there a way to map FUEL to [Ghz-seconds]?

view this post on Zulip bjorn3 (Jun 14 2022 at 09:27):

No, fuel is deterministic and roughly corresponds to amount of wasm instructions executed. You seem to want the amount of cycles the cpu used to execute it which is highly dependent on the exact cpu, what the result is of the compilation, the exact state of the caches and a dozen other factors. The only way to get that is to use the cpu profiling functionality of the OS. For example perf_event_open on Linux (doesn't work with the default perf paranoid level config unless you are root)

view this post on Zulip Jorge Silva (Jun 21 2022 at 15:15):

Hello,
quick question regarding Fuel:

A list of all available opcodes for the Ethereum virtual machine.

view this post on Zulip Alex Crichton (Jun 21 2022 at 16:24):

Currently almost all opcodes are cost "1" with some being cost "0", although we don't provide a strong guarantee about what opcodes "cost" at this time

view this post on Zulip Jorge Silva (Jun 21 2022 at 17:29):

okay, thank you Alex! Are there plans to document/customize different opcodes costs?

view this post on Zulip Alex Crichton (Jun 21 2022 at 17:36):

I don't believe anyone's currently working on that, but it seems like a reasonable-enough feature to add to me. I think there was some historical discussion about adding it but now I forget where that happened...

view this post on Zulip Shivam (Jun 30 2022 at 03:49):

In the release build , is it possible to generate .wasm file in the target folder using cargo build --target wasm32-wasi ? I want the component model wasm file.

view this post on Zulip Shivam (Jul 05 2022 at 08:15):

Is there any way that I can generate .wasm file from .wat based on component model?

view this post on Zulip Shivam (Jul 05 2022 at 08:26):

@Alex Crichton

view this post on Zulip bjorn3 (Jul 05 2022 at 10:58):

In the release build , is it possible to generate .wasm file in the target folder using cargo build --target wasm32-wasi ? I want the component model wasm file.

Wasi doesn't yet use the component model.

view this post on Zulip bjorn3 (Jul 05 2022 at 10:59):

Is there any way that I can generate .wasm file from .wat based on component model?

A .wat file describes the interface of a .wasm file. You have to compile the .wasm file from another language that supports compiling to wasm.

view this post on Zulip Shivam (Jul 05 2022 at 13:51):

I'm interested in wasm file which is based on component model . so I'm compiling the the component model module but I'm not sure how to compile component model module?

view this post on Zulip Peter Huene (Jul 05 2022 at 18:19):

Hi @Shivam. Currently there's a tool called wit-component in the wit-bindgen repository (https://github.com/bytecodealliance/wit-bindgen/tree/main/crates/wit-component) that can create a component based on the component model from a core wasm module that was built with wit-bindgen. There's also a cargo-component tool for Rust component development that should be available very soon to easily create components (it automates bindings generation and using wit-component to create a wasm component). As WASI preview2 (which is based on the component model) isn't yet ready, these tools are expecting you to target wasm32-unknown-unknown (in the case of cargo-component, the target is implicitly set for you).

A language binding generator for WebAssembly interface types - wit-bindgen/crates/wit-component at main · bytecodealliance/wit-bindgen

view this post on Zulip bjorn3 (Jul 06 2022 at 06:30):

@Peter Huene Note that wasm32-unknown-unknown's call conv is not compatible with C.

view this post on Zulip Peter Huene (Jul 06 2022 at 06:32):

The intention is to default to WASI once it does support the component model

view this post on Zulip Shivam (Jul 06 2022 at 08:03):

I'm not sure that if i can generate a .wasm from the .wat file? I checked it , it depending on the .wit format and generates a .rs file. Is there any way that I can generate .wasm file from .wat format of component model?

view this post on Zulip Shivam (Jul 06 2022 at 08:22):

Also where i can find the binary ? for testing a .wat format?

view this post on Zulip Peter Huene (Jul 06 2022 at 17:06):

wasm-tools parse can be used to convert a .wat file to a .wasm file and it supports the component model; it can be installed from here: https://github.com/bytecodealliance/wasm-tools

Low level tooling for WebAssembly in Rust. Contribute to bytecodealliance/wasm-tools development by creating an account on GitHub.

view this post on Zulip Peter Huene (Jul 06 2022 at 17:07):

if by testing you mean executing your component defined in either wat or wasm, wasmtime has under-development support for executing components (under the component-model feature), but you need to use the Wasmtime Rust API to instantiate the component

view this post on Zulip Cwasi4wasm (Jul 06 2022 at 18:04):

Hello everyone first time here, I was wondering if it is possible to add import functions to a wasm module using wasmtime. I want the user to give me some code which I can essentially add to at runtime

view this post on Zulip Cwasi4wasm (Jul 06 2022 at 18:15):

Woops I meant exports * get the naming confused sometimes

view this post on Zulip Dan Gohman (Jul 06 2022 at 18:16):

You want to add functions to a wasm module at runtime?

view this post on Zulip Dan Gohman (Jul 06 2022 at 18:17):

Dynamically adding code to a running instance is not currently possible.

view this post on Zulip Cwasi4wasm (Jul 06 2022 at 18:22):

Ahh I see thank you, I might use some code generation on the client side instead. Thank you

view this post on Zulip Shivam (Jul 06 2022 at 18:51):

Thanks Peter!

view this post on Zulip Klim Tsoutsman (Jul 07 2022 at 03:41):

Hi, I'm using the wasmtime::component module to load in a WASM file, define some functions that it can use, and then run some functions that it exports. The WASM file is another rust crate that I compile to the wasm32-wasi target. I'm getting the error attempted to parse a wasm module with a component parser which I assume means that the Rust compiler outputs a WASM module rather than a WASM component. Is it possible for the Rust compiler to generate a component? If not, how can I create a WASM component? The reason I'm using components in the first place is because I'd like to use structs across the FFI boundary between the Rust runner and WASM file.

view this post on Zulip Notification Bot (Jul 07 2022 at 08:11):

Klim Tsoutsman has marked this topic as resolved.

view this post on Zulip Klim Tsoutsman (Jul 07 2022 at 08:15):

Klim Tsoutsman said:

Hi, I'm using the wasmtime::component module to load in a WASM file, define some functions that it can use, and then run some functions that it exports. The WASM file is another rust crate that I compile to the wasm32-wasi target. I'm getting the error attempted to parse a wasm module with a component parser which I assume means that the Rust compiler outputs a WASM module rather than a WASM component. Is it possible for the Rust compiler to generate a component? If not, how can I create a WASM component? The reason I'm using components in the first place is because I'd like to use structs across the FFI boundary between the Rust runner and WASM file.

Sorry, I probably should have scrolled up in the chat to see if my question has already been answered. Peter Huene literally answered the same question yesterday :)

view this post on Zulip Alex Crichton (Jul 07 2022 at 15:05):

Is it possible for the Rust compiler to generate a component? If not, how can I create a WASM component?

To answer this, the Rust compiler does not generate components at this time, only core wasm modules. We're working on tooling like cargo component to generate components

A Cargo subcommand for creating WebAssembly components based on the component model proposal. - GitHub - bytecodealliance/cargo-component: A Cargo subcommand for creating WebAssembly components bas...

view this post on Zulip Jens Gåsemyr Magnus (Jul 08 2022 at 08:18):

(deleted)


Last updated: Nov 22 2024 at 17:03 UTC