Add a V8 engine
This change adds the beginnings of a new V8 engine to Sightglass. It uses V8's libwee8 library as the backing engine and constructs a libengine.so in C++ that is compatible with Sightglass. As-is, it has some limitations (discussed below), but the current change can run benchmarks under very specific circumstances and represents a significant effort to make this all work. I do not expect to include this as a part of CI until some of these limitations are resolved.
Limitations, in order of importance:
- V8 expects only one engine to be instantiated in any process; to fix this, I would expect that we would need a safe way to create a static reference to the engine in the shared library (?). To get around this now, the example
make test-libwill only run a single iteration. - The WASI support for this library is minimal and merely stubbed out; this allows running only the simplest of benchmarks. We should consider integrating an existing WASI implementation, e.g.,
uvwasi; the challenge is that some of the WASI calls are modified, i.e., to collect all stdout and stderr into files. To avoid this limitation for now, this change adds a--no-output-checkto skip checking for collected output. - The
libwee8build is slow: it takes approximately 27 minutes on my machine. Much of the time is spent retrieving the various dependencies of V8. It is not clear to me that all of these are needed and it may be possible to compilelibwee8with less fetching.
For now, though, this library is functional:
$ make test-lib
RUST_LOG=trace cargo run -- benchmark ../../benchmarks-next/noop/benchmark.wasm \
--engine build/libengine.so --processes 1 --iterations-per-process 1 \
--skip-output-check
Compiling sightglass-cli v0.1.0 (/home/abrown/Code/sightglass/crates/cli)
Finished dev [unoptimized + debuginfo] target(s) in 1.77s
Running `/home/abrown/Code/sightglass/target/debug/sightglass-cli benchmark ../../benchmarks-next/noop/benchmark.wasm --engine build/libengine.so --processes 1 --iterations-per-process 1 --skip-output-check`
TRACE sightglass_cli > Executing command: Benchmark(BenchmarkCommand { engines: ["build/libengine.so"], processes: 1, iterations_per_process: 1, raw: false, output_format: Json, output_file: None, measure: WallCycles, small_workloads: false, working_dir: None, wasm_files: ["../../benchmarks-next/noop/benchmark.wasm"], stop_after_phase: None, significance_level: 0.01, skip_output_check: true })
DEBUG sightglass_artifact::engine > Using already-built engine path: build/libengine.so
INFO sightglass_cli::benchmark > Using benchmark engine: build/libengine.so
INFO sightglass_cli::benchmark > Using Wasm benchmark: ../../benchmarks-next/noop/benchmark.wasm
INFO sightglass_cli::benchmark > Using working directory: ../../benchmarks-next/noop
DEBUG sightglass_cli::benchmark > Wasm benchmark size: 3871 bytes
INFO sightglass_recorder::bench_api > Starting new measurement
INFO sightglass_recorder::bench_api > Finished measuring compilation
INFO sightglass_recorder::benchmark > Compiled successfully
INFO sightglass_recorder::bench_api > Starting new measurement
INFO sightglass_recorder::bench_api > Finished measuring instantiation
INFO sightglass_recorder::benchmark > Instantiated successfully
fd_write
bench_start
INFO sightglass_recorder::bench_api > Starting new measurement
INFO sightglass_recorder::bench_api > Finished measuring execution
bench_end
fd_write
proc_exit
INFO sightglass_recorder::benchmark > Executed successfully
compilation
../../benchmarks-next/noop/benchmark.wasm
cycles
[91751789 91751789.00 91751789] build/libengine.so
nanoseconds
[28786700 28786700.00 28786700] build/libengine.so
instantiation
../../benchmarks-next/noop/benchmark.wasm
cycles
[57176762 57176762.00 57176762] build/libengine.so
nanoseconds
[17938945 17938945.00 17938945] build/libengine.so
execution
../../benchmarks-next/noop/benchmark.wasm
cycles
[4219 4219.00 4219] build/libengine.so
nanoseconds
[1323 1323.00 1323] build/libengine.so
The
libwee8build is slow: it takes approximately 27 minutes on my machine. Much of the time is spent retrieving the various dependencies of V8. It is not clear to me that all of these are needed and it may be possible to compilelibwee8with less fetching.
Do they publish prebuilt .sos or something we could use, instead of building from source?