wasmi-labs / wasmi

WebAssembly (Wasm) interpreter.
https://wasmi-labs.github.io/wasmi/
Apache License 2.0
1.63k stars 290 forks source link

Benching system #89

Closed NikVolf closed 2 years ago

NikVolf commented 6 years ago

to address lack of benchmarks, we might want to use special wasm binaries which utilize specific benching api

it should consist of:

  1. start benchmark (extern "C" fn start_bench(name_ptr: *const u8, name_len: u32))
  2. start iteration (extern "C" fn start_iter())
  3. end iteration (extern "C" fn end_iter())
  4. blackbox/observe (extern "C" fn bb_observe(ptr: *mut u8, len: u32)) (can be replaced by test::black_box on nightly)

each start_iter should follow end_iter sequentally so there should be no nested iterations or overlaps (higher-level utility library should enforce it via closures/ownership)

bb_observe is used to avoid compiler optimisations

eira-fransham commented 6 years ago

AAIU bb_observe is unnecessary, you can use any function that's unreadable by LLVM (including the test::black_box function).

NikVolf commented 6 years ago

test::black_box

is it available in no-std?

eira-fransham commented 6 years ago

Yes, it is

eira-fransham commented 6 years ago

I'm trying to work on a relatively-transparent benchmarking harness that compiles normal Rust benchmarks to a format that could work when compiled with wasm32-unknown-unknown.

eira-fransham commented 6 years ago

Implemented here

NikVolf commented 6 years ago

Great! Should we utilize it here, on the CI also?

eira-fransham commented 6 years ago

I think so, although I'd have to make it work properly on test failure - i.e., report the actual reason for test failure. Currently I haven't implemented any of the exception mechanisms so the interpreter just panicks complaining about unimplemented functions.

Robbepop commented 2 years ago

We moved to Criterion based benchmarks that allow for more flexibility. I do not agree with a fixed benchmarking API as proposed in the initial comment since benchmarks are way too different to unify them under a single Wasm based API.