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-bindgenor it's command line interfacewit-bindgen-clito generate bindings for your programming language. For example, if you useRustto develop your wasm component, you can either:
- add
wit-bindgenas a dependency to your project bycargo add wit-bindgen - use the
wit_bindgen::generatemacro to dynamically generate bindings.
wit_bindgen::generate!({
world: "bindings",
path: "<path/to/wit>",
generate_all,
// ...
});or:
- install
wit-bindgen-clibycargo 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 -rThis 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>