1# Using the `samply` Profiler on Linux and macOS
2
3One profiler supported by Wasmtime is [`samply`](https://github.com/mstange/samply) for Linux and macOS. As of 17th July 2023, the
4latest version of samply (on crates.io) is 0.11.0 which does not seem to support perfmaps. To use this, you either need a
5newer version of samply, if by the time you read this, a newer version has been released, or you can build samply from source.
6
7## Profiling with `perfmap`
8
9Simple profiling support with `samply` generates a "perfmap" file that the `samply` CLI will
10automatically look for, when running into unresolved symbols. This requires runtime support from
11Wasmtime itself, so you will need to manually change a few things to enable profiling support in
12your application. Enabling runtime support depends on how you're using Wasmtime:
13
14* **Rust API** - you'll want to call the [`Config::profiler`] method with
15  `ProfilingStrategy::PerfMap` to enable profiling of your wasm modules.
16
17* **C API** - you'll want to call the `wasmtime_config_profiler_set` API with a
18  `WASMTIME_PROFILING_STRATEGY_PERFMAP` value.
19
20* **Command Line** - you'll want to pass the `--profile=perfmap` flag on the command
21  line.
22
23Once perfmap support is enabled, you'll use `samply record` like usual to record
24your application's performance.
25
26For example if you're using the CLI, you'll execute:
27
28```console
29samply record wasmtime --profile=perfmap foo.wasm
30```
31
32This will record your application's performance and open the Firefox profiler UI to view the
33results. It will also dump its own profile data to a json file (called `profile.json`) in the current directory.
34
35Note that support for perfmap is still relatively new in Wasmtime, so if you
36have any problems, please don't hesitate to [file an issue]!
37
38[file an issue]: https://github.com/bytecodealliance/wasmtime/issues/new
39