bytecodealliance / bytecodealliance/javy

Add support for profiling execution of JS on Wasm

Open
#1,206 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
2.7k
Forks
135
Avg merge
1d 44m
Merged PRs (30d)
11

Description

This issue is meant to track the implementation progress of an _experimental_ profiler for Javy.

#### High-level goals

* Allow developers to understand the behavior of JS programs running on Wasm.
* Output traces and an estimated instruction cost per JS opcode, per JS program
* Allow Javy developers to understand the behavior of JS programs running on Wasm to derive future optimizations.

This work is the materialization of the research work done in collaboration with the Carnegie Mellon WebAssembly Research Center around execution and optimization of dynamic languages on Wasm.

#### Work to be done

- [x] Add a new `javy-profiler` crate, which will be called from CLI
- [x] Add a new `javy-profiler-lib` crate, containing the necessary heuristics to perform bytecode rewriting and instrumentation. This crate will be compiled to `wasm32-wasip1` and will be used by [whamm](https://github.com/ejrgilbert/whamm) as a user-defined library.
- [ ] Upstream the necessary crates to parse and transform QuickJS bytecode
- [ ] Upstream the crates to analyze execution traces
- [ ] Add new commands to the CLI (behind a feature flag) to enable profiling

#### Using the profiler from the CLI

First, build the WebAssemlby, optionally providing a plugin:

```sh
javy build index.js -o index.wasm
```
Next, use the `profile inject` subcommand:

```sh
javy profile inject index.wasm -o index.injected.wasm
```

Next, run the injected Wasm through Wasmtime or your custom
embedding and retrieve the profile results.

Finally, run the analysis command to retrieve the results:

```sh
javy profile analyze index.analysis.bin
```

Optionally we can have a single flow that injects and performs the
analysis in a single step when the default plugin is used.

```
javy profile run index.js
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.