597: fix metering benchmark r=MarkMcCaskey a=MarkMcCaskey

resolves #596 

Co-authored-by: Mark McCaskey <mark@wasmer.io>
This commit is contained in:
bors[bot] 2019-07-30 23:55:46 +00:00
commit f778330fed
7 changed files with 50 additions and 19 deletions

View File

@ -115,6 +115,8 @@ jobs:
name: Check
command: |
make check
make compile-bench-singlepass
# TODO: add compile-bench-llvm and compile-bench-clif when they work
- run:
name: Release
command: make release-fast

View File

@ -73,9 +73,23 @@ trace = ["wasmer-runtime-core/trace"]
extra-debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
# This feature will allow cargo test to run much faster
fast-tests = []
backend-cranelift = ["wasmer-runtime-core/backend-cranelift", "wasmer-runtime/cranelift"]
backend-llvm = ["wasmer-llvm-backend", "wasmer-runtime-core/backend-llvm", "wasmer-runtime/llvm"]
backend-singlepass = ["wasmer-singlepass-backend", "wasmer-runtime-core/backend-singlepass", "wasmer-runtime/singlepass"]
backend-cranelift = [
"wasmer-runtime-core/backend-cranelift",
"wasmer-runtime/cranelift",
"wasmer-middleware-common/clif"
]
backend-llvm = [
"wasmer-llvm-backend",
"wasmer-runtime-core/backend-llvm",
"wasmer-runtime/llvm",
"wasmer-middleware-common/llvm"
]
backend-singlepass = [
"wasmer-singlepass-backend",
"wasmer-runtime-core/backend-singlepass",
"wasmer-runtime/singlepass",
"wasmer-middleware-common/singlepass"
]
wasi = ["wasmer-wasi"]
# vfs = ["wasmer-runtime-abi"]

View File

@ -141,8 +141,20 @@ release-singlepass:
release-llvm:
cargo build --release --features backend-llvm
bench:
cargo bench --all
bench-singlepass:
cargo bench --all --no-default-features --features "backend-singlepass"
bench-clif:
cargo bench --all --no-default-features --features "backend-clif"
bench-llvm:
cargo bench --all --no-default-features --features "backend-llvm"
# compile but don't run the benchmarks
compile-bench-singlepass:
cargo bench --all --no-run --no-default-features --features "backend-singlepass"
compile-bench-clif:
cargo bench --all --no-run --no-default-features --features "backend-clif"
compile-bench-llvm:
cargo bench --all --no-run --no-default-features --features "backend-llvm"
# Build utils

View File

@ -220,7 +220,10 @@ Each integration can be tested separately:
Benchmarks can be run with:
```sh
make bench
make bench-[backend]
# for example
make bench-singlepass
```
## Roadmap

View File

@ -164,15 +164,11 @@ fn get_compiler(limit: u64, metering: bool) -> impl Compiler {
}
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler(_limit: u64, metering: bool) -> impl Compiler {
panic!("compiler not specified, activate a compiler via features");
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
compile_error!("compiler not specified, activate a compiler via features");
#[cfg(feature = "clif")]
fn get_compiler(_limit: u64, metering: bool) -> impl Compiler {
panic!("cranelift does not implement metering");
compile_error!("cranelift does not implement metering");
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}

View File

@ -162,15 +162,11 @@ mod tests {
}
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler(_limit: u64) -> impl Compiler {
panic!("compiler not specified, activate a compiler via features");
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
compile_error!("compiler not specified, activate a compiler via features");
#[cfg(feature = "clif")]
fn get_compiler(_limit: u64) -> impl Compiler {
panic!("cranelift does not implement metering");
compile_error!("cranelift does not implement metering");
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}

View File

@ -41,7 +41,12 @@ mod wasmer_wasi {
false
}
pub fn generate_import_object(_args: Vec<Vec<u8>>, _envs: Vec<Vec<u8>>) -> ImportObject {
pub fn generate_import_object(
_args: Vec<Vec<u8>>,
_envs: Vec<Vec<u8>>,
_preopened_files: Vec<String>,
_mapped_dirs: Vec<(String, std::path::PathBuf)>,
) -> ImportObject {
unimplemented!()
}
}
@ -620,11 +625,14 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
if let Err(ref err) = result {
match err {
RuntimeError::Trap { msg } => panic!("wasm trap occured: {}", msg),
#[cfg(feature = "wasi")]
RuntimeError::Error { data } => {
if let Some(error_code) = data.downcast_ref::<wasmer_wasi::ExitCode>() {
std::process::exit(error_code.code as i32)
}
}
#[cfg(not(feature = "wasi"))]
RuntimeError::Error { .. } => (),
}
panic!("error: {:?}", err)
}