Skip to content

Add support for profiling execution of JS on Wasm #1206

@saulecabrera

Description

@saulecabrera

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

  • Add a new javy-profiler crate, which will be called from CLI
  • 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 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:

javy build index.js -o index.wasm

Next, use the profile inject subcommand:

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions