This project contains wit definitions for developing performance engineering wasm component.
For now there are two main packages, perf
and system
. perf
provides wrappers for the Linux perf APIs to collect Linux perf data, system
provides APIs for quering system resources information, i.e., cpus/memory/processes.
These APIs are implemented in PSH project.
There are a few options available (we recommand git submodule
and wit-bindgen
):
- Add this project as a dependency as your wasm component project, i.e., add this project as a submodule or simply copy/paste these files under your project directory.
git submodule add [email protected]:OptimatistOpenSource/psh-sdk-wit.git /path/to/psh-sdk-wit
- use
wit-bindgen
or it's command line interfacewit-bindgen-cli
to generate bindings for your programming language. For example, if you useRust
to develop your wasm component, you can either:
- add
wit-bindgen
as a dependency to your project bycargo add wit-bindgen
- use the
wit_bindgen::generate
macro to dynamically generate bindings.
wit_bindgen::generate!({
world: "bindings",
path: "<path/to/wit>",
generate_all,
// ...
});
or:
- install
wit-bindgen-cli
bycargo install wit-bindgen-cli
- use shell command:
./wit-bindgen rust <path/to/wit> --out-dir <path/to/output>
to statically generate these bindings.
After these steps, you'll able to use these APIs in your Rust project.
We also provided a simple rust example in ./examples/wasm_module/Rust
, to build it, make sure you have installed rustup wasm32-wasi
target toolchain and cargo-component
, then run
cargo component build -r
This will produce a wasm component in target/wasm32-wasi/release/psh-sdk-wit.wasm
, to run it, you'll need to use PSH
./psh -p <pash/to/psh-sdk-wit.wasm>