zhuxiujia opened Issue #2644:
How do I enable JIT compilation in the code under Example?
default = ["jitdump", "wasmtime/wat", "wasmtime/parallel-compilation","experimental_x64"]
(module (func $sum_f (param $x i32) (param $y i32) (result i32) local.get $x local.get $y i32.add) (export "run" (func $sum_f)))
let now=std::time::Instant::now(); let total=1000000; for _ in 0..total{ run(1,1)?; } let time = self.elapsed(); println!( "use Time: {:?} ,each:{} ns/op", &time, time.as_nanos() / (total as u128) );
cargo run --release --package wasmtime-cli --example hello //use Time: 852.04292ms ,each:852 ns/op
zhuxiujia edited Issue #2644:
How do I enable JIT compilation in the code under Example?
default = ["jitdump", "wasmtime/wat", "wasmtime/parallel-compilation","experimental_x64"]
(module (func $sum_f (param $x i32) (param $y i32) (result i32) local.get $x local.get $y i32.add) (export "run" (func $sum_f)))
//example/hello.rs println!("Instantiating module..."); let instance = Instance::new(&store, &module, &[])?; // Next we poke around a bit to extract the `run` function from the module. println!("Extracting export..."); let run = instance .get_func("run") .ok_or(anyhow::format_err!("failed to find `run` function export"))? .get2::<i32,i32,i32>()?; let now=std::time::Instant::now(); let total=1000000; for _ in 0..total{ run(1,1)?; } let time = self.elapsed(); println!( "use Time: {:?} ,each:{} ns/op", &time, time.as_nanos() / (total as u128) );
cargo run --release --package wasmtime-cli --example hello //use Time: 852.04292ms ,each:852 ns/op
zhuxiujia edited Issue #2644:
How do I enable JIT compilation in the code under Example?
default = ["jitdump", "wasmtime/wat", "wasmtime/parallel-compilation","experimental_x64"]
(module (func $sum_f (param $x i32) (param $y i32) (result i32) local.get $x local.get $y i32.add) (export "run" (func $sum_f)))
//example/hello.rs println!("Instantiating module..."); let instance = Instance::new(&store, &module, &[])?; // Next we poke around a bit to extract the `run` function from the module. println!("Extracting export..."); let run = instance .get_func("run") .ok_or(anyhow::format_err!("failed to find `run` function export"))? .get2::<i32,i32,i32>()?; let now=std::time::Instant::now(); let total=1000000; for _ in 0..total{ run(1,1)?; } let time = now.elapsed(); println!( "use Time: {:?} ,each:{} ns/op", &time, time.as_nanos() / (total as u128) );
cargo run --release --package wasmtime-cli --example hello //use Time: 852.04292ms ,each:852 ns/op
zhuxiujia edited Issue #2644:
How do I enable JIT compilation in the code under Example?
- toml
default = ["jitdump", "wasmtime/wat", "wasmtime/parallel-compilation","experimental_x64"]
- wat
(module (func $sum_f (param $x i32) (param $y i32) (result i32) local.get $x local.get $y i32.add) (export "run" (func $sum_f)))
- example/hello.rs
println!("Instantiating module..."); let instance = Instance::new(&store, &module, &[])?; // Next we poke around a bit to extract the `run` function from the module. println!("Extracting export..."); let run = instance .get_func("run") .ok_or(anyhow::format_err!("failed to find `run` function export"))? .get2::<i32,i32,i32>()?; let now=std::time::Instant::now(); let total=1000000; for _ in 0..total{ run(1,1)?; } let time = now.elapsed(); println!( "use Time: {:?} ,each:{} ns/op", &time, time.as_nanos() / (total as u128) );
- cargo run result
cargo run --release --package wasmtime-cli --example hello //use Time: 852.04292ms ,each:852 ns/op
zhuxiujia edited Issue #2644:
How do I enable JIT compilation in the code under Example?
- toml
default = ["jitdump", "wasmtime/wat", "wasmtime/parallel-compilation","experimental_x64"]
- wat
(module (func $sum_f (param $x i32) (param $y i32) (result i32) local.get $x local.get $y i32.add) (export "run" (func $sum_f)))
- example/hello.rs
println!("Instantiating module..."); let instance = Instance::new(&store, &module, &[])?; // Next we poke around a bit to extract the `run` function from the module. println!("Extracting export..."); let run = instance .get_func("run") .ok_or(anyhow::format_err!("failed to find `run` function export"))? .get2::<i32,i32,i32>()?; let now=std::time::Instant::now(); let total=1000000; for _ in 0..total{ run(1,1)?; } let time = now.elapsed(); println!( "use Time: {:?} ,each:{} ns/op", &time, time.as_nanos() / (total as u128) );
- cargo run result
cargo run --release --package wasmtime-cli --example hello //use Time: 852.04292ms ,each:852 ns/op
zhuxiujia edited Issue #2644:
How do I enable JIT compilation in the code under Example?
- toml
default = ["jitdump", "wasmtime/wat", "wasmtime/parallel-compilation","experimental_x64"]
- wat
(module (func $sum_f (param $x i32) (param $y i32) (result i32) local.get $x local.get $y i32.add) (export "run" (func $sum_f)))
- example/hello.rs
println!("Instantiating module..."); let instance = Instance::new(&store, &module, &[])?; // Next we poke around a bit to extract the `run` function from the module. println!("Extracting export..."); let run = instance .get_func("run") .ok_or(anyhow::format_err!("failed to find `run` function export"))? .get2::<i32,i32,i32>()?; let now=std::time::Instant::now(); let total=1000000; for _ in 0..total{ run(1,1)?; } let time = now.elapsed(); println!( "use Time: {:?} ,each:{} ns/op", &time, time.as_nanos() / (total as u128) );
- cargo run result(This is very slow, even though I'm using --release,it should be 1ns/op)
cargo run --release --package wasmtime-cli --example hello //use Time: 852.04292ms ,each:852 ns/op
zhuxiujia edited Issue #2644:
How do I enable JIT compilation in the code under Example?
Hi, I'm trying to use the code in Example to perform a JIT operation,But the performance is very slow
- toml
default = ["jitdump", "wasmtime/wat", "wasmtime/parallel-compilation","experimental_x64"]
- wat
(module (func $sum_f (param $x i32) (param $y i32) (result i32) local.get $x local.get $y i32.add) (export "run" (func $sum_f)))
- example/hello.rs
println!("Instantiating module..."); let instance = Instance::new(&store, &module, &[])?; // Next we poke around a bit to extract the `run` function from the module. println!("Extracting export..."); let run = instance .get_func("run") .ok_or(anyhow::format_err!("failed to find `run` function export"))? .get2::<i32,i32,i32>()?; let now=std::time::Instant::now(); let total=1000000; for _ in 0..total{ run(1,1)?; } let time = now.elapsed(); println!( "use Time: {:?} ,each:{} ns/op", &time, time.as_nanos() / (total as u128) );
- cargo run result(This is very slow, even though I'm using --release,it should be 1ns/op)
cargo run --release --package wasmtime-cli --example hello //use Time: 852.04292ms ,each:852 ns/op
zhuxiujia edited Issue #2644:
How do I enable JIT compilation in the code under Example?
Hi, I'm trying to use the code in Example to perform a JIT operation,But the performance is very slow
- toml
default = ["jitdump", "wasmtime/wat", "wasmtime/parallel-compilation","experimental_x64"]
- wat
(module (func $sum_f (param $x i32) (param $y i32) (result i32) local.get $x local.get $y i32.add) (export "run" (func $sum_f)))
- example/hello.rs
println!("Instantiating module..."); let instance = Instance::new(&store, &module, &[])?; // Next we poke around a bit to extract the `run` function from the module. println!("Extracting export..."); let run = instance .get_func("run") .ok_or(anyhow::format_err!("failed to find `run` function export"))? .get2::<i32,i32,i32>()?; let now=std::time::Instant::now(); let total=1000000; for _ in 0..total{ run(1,1)?; } let time = now.elapsed(); println!( "use Time: {:?} ,each:{} ns/op", &time, time.as_nanos() / (total as u128) );
- cargo run result(This is very slow, even though I'm using --release,it should be 1ns/op)
cargo run --release --example hello //use Time: 852.04292ms ,each:852 ns/op
Last updated: Dec 23 2024 at 12:05 UTC