Skip to content

Commit

Permalink
Cleanup workspace organization & benchmarks (#466)
Browse files Browse the repository at this point in the history
* cleanup benchmark code

This removes the superflous `_v1` suffix from all benchmarks.
Also this renames `compile_and_validate` to just `translate` and also adds what exactly it `translates` or `instantiates` to allow for future additions.

* move ci.sh script into scripts folder and rename for clarity

* move workspace crates under crates folder

Also rename "wasmi_v1" folder to just "wasmi".

* adjust GitLab benchmark CI

* GitLab bench CI: add popd after benchmarking PR branch

* fix gitlab-ci.yml script paths
  • Loading branch information
Robbepop authored Sep 23, 2022
1 parent 78c93be commit c88185d
Show file tree
Hide file tree
Showing 112 changed files with 106 additions and 105 deletions.
20 changes: 13 additions & 7 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ criterion-benchmark:
script:
- cargo install cargo-criterion
- git fetch
- git submodule update --init --recursive
# Benchmark Branch: `master`
- git checkout master
- git pull
- git submodule update --init --recursive
- mkdir -p ./target/ci
- cd ./wasmi_v1
# benchmark master
- cargo criterion --message-format=json | tee -a ../target/ci/benchmarks.json
# benchmark PR
- pushd ./crates/wasmi/
- cargo criterion --message-format=json | tee -a ../../target/ci/benchmarks.json
- popd
- git submodule deinit --all -f
# Benchmark Branch: PR
- git checkout $CI_COMMIT_SHA
- cargo criterion --message-format=json | tee -a ../target/ci/benchmarks.json
- bash ../scripts/ci/benchmarks-report.sh ../target/ci/benchmarks.json
- git submodule update --init --recursive
- pushd ./crates/wasmi/
- cargo criterion --message-format=json | tee -a ../../target/ci/benchmarks.json
- popd
# Evaluates Benchmark Results
- bash ./scripts/ci/benchmarks-report.sh ./target/ci/benchmarks.json
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "wasmi_v1/tests/spec/testsuite"]
path = wasmi_v1/tests/spec/testsuite
[submodule "crates/wasmi/tests/spec/testsuite"]
path = crates/wasmi/tests/spec/testsuite
url = https://github.com/WebAssembly/testsuite.git
[submodule "wasmi_v1/benches/wasm_kernel"]
path = wasmi_v1/benches/wasm/wasm_kernel
[submodule "crates/wasmi/benches/wasm_kernel"]
path = crates/wasmi/benches/wasm/wasm_kernel
url = https://github.com/robbepop/wasm_kernel.git
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["core", "wasmi_v1", "cli"]
members = ["crates/cli", "crates/core", "crates/wasmi"]
exclude = []
resolver = "2"

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The following list states some of the distinct features of `wasmi`.

## WebAssembly Proposals

The new `wasmi_v1` engine supports a variety of WebAssembly proposals and will support even more of them in the future.
The new `wasmi` engine supports a variety of WebAssembly proposals and will support even more of them in the future.

| WebAssembly Proposal | Status | Comment |
|:--|:--:|:--|
Expand Down Expand Up @@ -101,7 +101,7 @@ cargo test --workspace
## Development

Before pushing a PR to our repository we would like you to execute the
`ci.sh` script that can be found in the repository's root folder.
`scripts/run-local-ci.sh` script that can be found in the repository's root folder.

## Supported Platforms

Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml → crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ keywords = ["wasm", "webassembly", "bytecode", "interpreter"]

[dependencies]
clap = { version = "3.2", features = ["derive"] }
wasmi = { path = "../wasmi_v1" }
wasmi = { path = "../wasmi" }
wat = "1"
anyhow = "1"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::{fs::File, io::Read as _};

use wasmi::{Config, StackLimits};

/// Returns the Wasm binary at the given `file_name` as `Vec<u8>`.
Expand Down Expand Up @@ -37,7 +36,7 @@ fn bench_config() -> Config {
/// # Panics
///
/// If the benchmark Wasm file could not be opened, read or parsed.
pub fn load_module_from_file_v1(file_name: &str) -> wasmi::Module {
pub fn load_module_from_file(file_name: &str) -> wasmi::Module {
let wasm = load_wasm_from_file(file_name);
let engine = wasmi::Engine::new(&bench_config());
wasmi::Module::new(&engine, &wasm[..]).unwrap_or_else(|error| {
Expand All @@ -48,7 +47,7 @@ pub fn load_module_from_file_v1(file_name: &str) -> wasmi::Module {
})
}

/// Parses the Wasm binary from the given `file_name` into a `wasmi` `v1` module.
/// Parses the Wasm binary from the given `file_name` into a `wasmi` module.
///
/// # Note
///
Expand All @@ -57,8 +56,8 @@ pub fn load_module_from_file_v1(file_name: &str) -> wasmi::Module {
/// # Panics
///
/// If the benchmark Wasm file could not be opened, read or parsed.
pub fn load_instance_from_file_v1(file_name: &str) -> (wasmi::Store<()>, wasmi::Instance) {
let module = load_module_from_file_v1(file_name);
pub fn load_instance_from_file(file_name: &str) -> (wasmi::Store<()>, wasmi::Instance) {
let module = load_module_from_file(file_name);
let mut linker = <wasmi::Linker<()>>::default();
let mut store = wasmi::Store::new(module.engine(), ());
let instance = linker
Expand All @@ -74,7 +73,7 @@ pub fn wat2wasm(bytes: &[u8]) -> Vec<u8> {
wat::parse_bytes(bytes).unwrap().into_owned()
}

/// Parses the Wasm source from the given `.wat` bytes into a `wasmi` `v0` module.
/// Parses the Wasm source from the given `.wat` bytes into a `wasmi` module.
///
/// # Note
///
Expand All @@ -83,7 +82,7 @@ pub fn wat2wasm(bytes: &[u8]) -> Vec<u8> {
/// # Panics
///
/// If the benchmark Wasm file could not be opened, read or parsed.
pub fn load_instance_from_wat_v1(wat_bytes: &[u8]) -> (wasmi::Store<()>, wasmi::Instance) {
pub fn load_instance_from_wat(wat_bytes: &[u8]) -> (wasmi::Store<()>, wasmi::Instance) {
let wasm = wat2wasm(wat_bytes);
let engine = wasmi::Engine::new(&bench_config());
let module = wasmi::Module::new(&engine, &wasm[..]).unwrap();
Expand Down
Loading

0 comments on commit c88185d

Please sign in to comment.