Stream: git-wasmtime

Topic: wasmtime / Issue #2644 How do I enable JIT compilation in...


view this post on Zulip Wasmtime GitHub notifications bot (Feb 07 2021 at 03:49):

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

view this post on Zulip Wasmtime GitHub notifications bot (Feb 07 2021 at 03:51):

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

view this post on Zulip Wasmtime GitHub notifications bot (Feb 07 2021 at 03:53):

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

view this post on Zulip Wasmtime GitHub notifications bot (Feb 07 2021 at 03:54):

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

view this post on Zulip Wasmtime GitHub notifications bot (Feb 07 2021 at 03:55):

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

view this post on Zulip Wasmtime GitHub notifications bot (Feb 07 2021 at 04:15):

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

view this post on Zulip Wasmtime GitHub notifications bot (Feb 07 2021 at 04:46):

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

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

view this post on Zulip Wasmtime GitHub notifications bot (Feb 07 2021 at 04:46):

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

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)))
  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  --example hello
//use Time: 852.04292ms ,each:852 ns/op

Last updated: Oct 23 2024 at 20:03 UTC