From 741fffedb0de85f5c3acb3268ddf69b438c3bb21 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Tue, 30 Jul 2019 15:59:21 +0900 Subject: [PATCH 1/2] fix metering benchmark --- Cargo.toml | 20 ++++++++++++++++--- Makefile | 8 ++++++-- .../benches/metering_benchmark.rs | 8 ++------ lib/middleware-common/src/metering.rs | 8 ++------ src/bin/wasmer.rs | 10 +++++++++- 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fd7d5d10f..df444a5df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] diff --git a/Makefile b/Makefile index 2d9af1cf2..3ffa46857 100644 --- a/Makefile +++ b/Makefile @@ -141,8 +141,12 @@ 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" # Build utils diff --git a/lib/middleware-common/benches/metering_benchmark.rs b/lib/middleware-common/benches/metering_benchmark.rs index 20759ed01..4c5f689f4 100644 --- a/lib/middleware-common/benches/metering_benchmark.rs +++ b/lib/middleware-common/benches/metering_benchmark.rs @@ -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() } diff --git a/lib/middleware-common/src/metering.rs b/lib/middleware-common/src/metering.rs index 024a1c7cd..e0d392cb6 100644 --- a/lib/middleware-common/src/metering.rs +++ b/lib/middleware-common/src/metering.rs @@ -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() } diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index bc84c6c99..91895a4fe 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -41,7 +41,12 @@ mod wasmer_wasi { false } - pub fn generate_import_object(_args: Vec>, _envs: Vec>) -> ImportObject { + pub fn generate_import_object( + _args: Vec>, + _envs: Vec>, + _preopened_files: Vec, + _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::() { std::process::exit(error_code.code as i32) } } + #[cfg(not(feature = "wasi"))] + RuntimeError::Error { .. } => (), } panic!("error: {:?}", err) } From 229254fd04cb9066741acad3baa63d319746563a Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Wed, 31 Jul 2019 08:53:33 +0900 Subject: [PATCH 2/2] Update bench part of readme, add benchmark compilation to CI --- .circleci/config.yml | 2 ++ Makefile | 8 ++++++++ README.md | 5 ++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e6fc97ec7..3098187ed 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/Makefile b/Makefile index 3ffa46857..4bb5df974 100644 --- a/Makefile +++ b/Makefile @@ -148,6 +148,14 @@ bench-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 build-install: diff --git a/README.md b/README.md index 356ad826b..129b5452f 100644 --- a/README.md +++ b/README.md @@ -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