bench: benchmark several common WASI scenarios (#5274)

In order to properly understand the impact of providing thread-safe
implmentations of WASI contexts (#5235), we need benchmarks that measure
the current performance of WASI calls using Wiggle. This change adds
several common WASI scenarios as WAT files (see `benches/wasi/*.wat`)
and benchmarks them with `criterion`. Using `criterion`'s `iter_custom`,
the WAT file runs the desired number of benchmark iterations internally
and the total duration of the runs is divided to get the average time
for each loop iteration.

Why WAT? When compiling these benchmarks from Rust to `wasm32-wasi`, the
output files are large, contain other WASI imports than the desired
ones, and overall it is difficult to tell if we are measuring what we
expect. By hand-writing the WAT, it is (slightly) more clear what each
benchmark is doing.
This commit is contained in:
Andrew Brown
2022-11-15 17:02:35 -08:00
committed by GitHub
parent a793648eb2
commit 8426904129
6 changed files with 185 additions and 1 deletions

View File

@@ -4,7 +4,7 @@ use std::time::{Duration, Instant};
use wasmtime::*;
fn measure_execution_time(c: &mut Criterion) {
// Baseline performance: a single measurment covers both initializing
// Baseline performance: a single measurement covers both initializing
// thread local resources and executing the first call.
//
// The other two bench functions should sum to this duration.