Files
wasmtime/docs/examples-profiling.md
Rik Huijzer 310e6677dc Reorder book-based documentation (#8130)
On a high level, this is what this PR changed:

1. Move the CLI chapter before the API chapter.
    I think this makes sense because the CLI is more high-level.
    The same change was proposed in
    https://github.com/bytecodealliance/wasmtime/pull/7987.
1. Move some Rust and C examples from the "Examples" chapter into the API chapter.
1. Remove the original main C and Rust chapter introduction files.
    They contained mostly outdated or duplicate information.
1. Rename the "Examples" chapter to "Further Examples".
    (For lack of a better name.)
1. Rename "Embedding" to "API" at some places since API is a more generally known term.
    The term "embedding" is also slightly more confusing, I think,
    because the term nowadays also used a lot in LLM-related communication.
1. Read through the entire document and fix some outdated links and information.
1. Fix a missing subheading for Elixir (it was mentioned on the lang page, but not in the menu).
2024-03-14 17:41:27 +00:00

1.5 KiB

Profiling WebAssembly

One of WebAssembly's major goals is to be quite close to native code in terms of performance, so typically when executing Wasm you'll be quite interested in how well your Wasm module is performing! From time to time you might want to dive a bit deeper into the performance of your Wasm, and this is where profiling comes into the picture.

For best results, ideally you'd use hardware performance counters for your timing measurements. However, that requires special support from your CPU and operating system. Because Wasmtime is a JIT, that also requires hooks from Wasmtime to your platform's native profiling tools.

As a result, Wasmtime support for native profiling is limited to certain platforms. See the following sections of this book if you're using these platforms:

The native profilers can measure time spent in WebAssembly guest code as well as time spent in the Wasmtime host and potentially even time spent in the kernel. This provides a comprehensive view of performance.

The cross-platform-profiler can only measure time spent in WebAssembly guest code, and its timing measurements are not as precise as the native profilers. However, it works on every platform that Wasmtime supports.