Merge pull request #2574 from fitzgen/randomize-location-of-heap-objects

wasmtime-bench-api: Randomize the locations of heap objects
This commit is contained in:
Nick Fitzgerald
2021-01-13 09:35:46 -08:00
committed by GitHub
3 changed files with 25 additions and 1 deletions

13
Cargo.lock generated
View File

@@ -1964,6 +1964,18 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
[[package]]
name = "shuffling-allocator"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "848c0a454373d16ebfaa740c99d4faebe25ea752a35e0c6e341168fe67f987f8"
dependencies = [
"cfg-if 1.0.0",
"libc",
"rand",
"winapi",
]
[[package]]
name = "smallvec"
version = "1.6.1"
@@ -2430,6 +2442,7 @@ name = "wasmtime-bench-api"
version = "0.19.0"
dependencies = [
"anyhow",
"shuffling-allocator",
"wasi-common",
"wasmtime",
"wasmtime-wasi",

View File

@@ -16,10 +16,13 @@ crate-type = ["rlib", "cdylib"]
[dependencies]
anyhow = "1.0"
shuffling-allocator = { version = "1.1.1", optional = true }
wasmtime = { path = "../wasmtime", default-features = false }
wasmtime-wasi = { path = "../wasi" }
wasi-common = { path = "../wasi-common" }
[dev-dependencies]
wat = "1.0"
[features]
default = ["shuffling-allocator"]

View File

@@ -83,6 +83,14 @@ pub type ExitCode = c_int;
pub const OK: ExitCode = 0;
pub const ERR: ExitCode = -1;
// Randomize the location of heap objects to avoid accidental locality being an
// uncontrolled variable that obscures performance evaluation in our
// experiments.
#[cfg(feature = "shuffling-allocator")]
#[global_allocator]
static ALLOC: shuffling_allocator::ShufflingAllocator<std::alloc::System> =
shuffling_allocator::wrap!(&std::alloc::System);
/// Exposes a C-compatible way of creating the engine from the bytes of a single
/// Wasm module.
///