samply records a profile, then hands it to the Firefox profiler
Command-line sampling profiler for macOS, Linux, and Windows
At a glance
- What is it?
- samply is a command line sampling profiler for macOS, Linux and Windows that uses the Firefox profiler as its UI. It is a good fit when you want flame graphs without a desktop IDE attached, and a poor fit when you need off-CPU samples on Linux.
- Who is it for?
- Adopt samply if you want to profile a plain command line and read the result as a flame graph in a browser you already trust with performance work, and if you can live with a profiler that needs two sysctl knobs on Linux. Do not adopt it if your conclusions depend on off-CPU samples on Linux, or if the first target is an Apple-signed system binary such as sleep or the system python, because DYLD_INSERT_LIBRARIES is blocked there and samply cannot attach.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 20 days ago.
- What is it written in?
- Mainly Rust, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.
Star history
- mstange/samply4,498 ★ · +72
| Repository | 2026-09-23 | 2026-11-22 |
|---|---|---|
| mstange/samply | 4.4k | 4.5k |
72 Stars in the last 60 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Prepending one word to a command gives you a profile
The decision this tool asks you to make is a small one. You take a command you already run, put `samply record` in front of it, and later get a flame graph in a browser tab. That is the whole interface. There is no daemon to install, no project file to configure, and no GUI to launch first.
The audience is engineers who profile a one-off command rather than a long-lived server, and who would rather click through a call tree in Firefox Profiler than learn a desktop profiler's layout. The mechanism is a subprocess spawn: samply starts your program as a child, samples its stacks, waits for it to exit, and only then does anything visible happen. When the command finishes, samply opens profiler.firefox.com in your default browser, loads the recorded profile into it, and starts a local webserver that serves symbol information and source code to that page.
That last detail is the reason this is not a text-only tool. The Firefox Profiler front end is what makes the samples readable, with flame graphs, timelines and a source view. Data stays on disk and in RAM until you choose to upload the profile yourself.
On Linux the kernel decides whether you get samples at all
Samply reads stack traces on Linux through perf events, and the kernel gates those for unprivileged users through `kernel.perf_event_paranoid`. Until you change it, the profiler starts and then produces nothing useful. The temporary option, which lasts until reboot, is one line:
echo '1' | sudo tee /proc/sys/kernel/perf_event_paranoidThe permanent equivalent writes the sysctl directly:
sudo sysctl kernel.perf_event_paranoid=1A third route exists on Linux 5.8 and later, granting the capability to the samply binary so that no runtime change is needed. The project is candid about it: people have reported mixed results with this approach.
sudo setcap 'cap_perfmon+ep' `which samply`There is a second gate behind the first. If you still hit an `mmap failed` error with an `EPERM`, the buffer being locked in memory is the suspect, and raising that limit to 2048 is the fix:
sudo sysctl kernel.perf_event_mlock_kb=2048Two sysctl knobs and an optional capability grant is the real setup cost of samply on Linux.
1000Hz on-CPU sampling, and off-CPU only off Linux
The sampler collects stack traces per thread at a sampling interval, default 1000Hz, which is one sample every 1 ms. Above that default, the cost to the profiled program rises; below it, short-lived functions disappear from the call tree.
The asymmetry that matters is platform coverage. On macOS and Windows, both on-CPU and off-CPU samples are collected, so the profile shows not just where time was burned but where a thread was blocked, for example waiting on a lock. On Linux, only on-CPU samples are collected at the moment. A program that spends its life blocked in a kernel wait, such as an event loop or a futex, will look almost empty in a samply profile taken on Linux, and will look busy on macOS. Any conclusion you draw about lock contention is a conclusion about your operating system as much as about your program.
The repository is a Rust workspace with thirteen members, and the profiling code is spread across them: among them `samply`, `samply-symbols`, `wholesym`, `samply-api` and `gecko_profile`, with an API.md document at the top level. The `etw-reader` member is excluded from the workspace because it should not be compiled on non-Windows, which is a fair hint about where the Event Tracing path lives.
Symbols arrive through config.toml and a local webserver
Unsymbolicated frames are the usual reason a sampling profile is unreadable, and samply treats symbol lookup as a first-class problem rather than an afterthought. Symbol servers are configured in a TOML file at `~/.config/samply/config.toml`, which is `%APPDATA%\samply\config.toml` on Windows. The same file sets the maximum size of the symbol cache and of the profile store, so an engineer profiling on a shared machine can bound disk use instead of discovering it later.
By default, output from `samply record` and `samply import` lands in `~/.local/share/samply/profiles/`, or `%LOCALAPPDATA%\samply\profiles\` on Windows. Nothing leaves the machine at write time.
On Windows the Microsoft Symbol Server is pre-configured, so Windows library symbols resolve without any setup. Adding further servers is a command line flag. On Windows, recording all processes rather than one child is `-a`, and the README's example adds symbol servers for Firefox and Chrome to it:
samply record -a --breakpad-symbol-server https://symbols.mozilla.org/try/ --windows-symbol-server https://chromium-browser-symsrv.commondatastorage.googleapis.comSamply pulls symbols from whatever servers you name in the config file or on the command line. The cost is that symbol server configuration is your job; the benefit is that the same command works on a binary no vendor instrumented.
Without debug info the source view stays empty
Debug info is the switch that decides whether samply can show you lines. Profile a Rust binary that was built without it and you get function names without inline stacks, and a source view that cannot resolve. The project recommends a dedicated cargo profile rather than reusing your normal optimised build, which keeps profiling binaries out of the way of the ones you ship.
Create `~/.cargo/config.toml` and add:
[profile.profiling]
inherits = "release"
debug = trueThen build with `cargo build --profile profiling` and point samply at `./target/profiling/yourrustprogram`. The `dist` profile in the workspace `Cargo.toml` is a separate case: it is what `cargo dist` builds with, and it turns on thin LTO while adding no debug info, so it is not a substitute.
For C++ the equivalent requirement is that `-g` appears in the compiler invocation.
macOS system binaries block the injection samply depends on
The clearest documented failure is on macOS, and it is not a bug report, it is a hard boundary. Samply cannot profile system commands such as `sleep` or the system `python`. Those executables are signed in a way that blocks the `DYLD_INSERT_LIBRARIES` environment variable, and without that injection samply cannot siphon out the `mach_port` of the process. The result is that a command that works on your own build fails on a command you did not build.
Binaries you compiled yourself are fine, as are unsigned or locally signed ones, which covers anything installed by `cargo install` or by Homebrew. Attaching to an already running process on macOS needs one extra step: run `samply setup` once, and again every time samply is updated, to self-sign the samply binary.
The same installation story applies on the other two platforms. Prebuilt binaries come from a shell script, and the download URL names the version explicitly:
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/mstange/samply/releases/download/samply-v0.13.1/samply-installer.sh | shWindows uses a PowerShell equivalent.
Three install routes, and the code block each one pins
The prebuilt script fetches a release asset by URL, which means the binary you get is the one that asset was built from, not the current state of `main`. That is the predictable choice on a work machine, and the most recent push to `main` landed on 2026-10-24.
The crates.io route is one command, and it compiles samply on your machine against the published crate:
cargo install --locked samplyBuilding from source is four lines, and it is the only route that gives you the code currently on `main`:
git clone https://github.com/mstange/samply
cd samply
cargo build --release
./target/release/samply ...Pick the third route when you need to see what a fix actually does, or when your platform has no published asset. Either way, record the same way afterwards, and on macOS run `samply setup` once (and after every update) before attaching to running processes.
Editorial conclusion
Adopt samply if you want to profile a plain command line and read the result as a flame graph in a browser you already trust with performance work, and if you can live with a profiler that needs two sysctl knobs on Linux. Do not adopt it if your conclusions depend on off-CPU samples on Linux, or if the first target is an Apple-signed system binary such as sleep or the system python, because DYLD_INSERT_LIBRARIES is blocked there and samply cannot attach. Before anything else, check what your kernel already allows: read /proc/sys/kernel/perf_event_paranoid and see whether you can write to it without sudo. If you cannot, that is your first afternoon's work, not a footnote.
Frequently asked questions
How do you use samply to profile a program?
Put `samply record` in front of the command you would run anyway, for example `samply record ./my-application my-arguments`. When the command finishes, samply opens profiler.firefox.com in your default browser with the profile loaded, and serves symbols and source code from a local webserver. All data stays on disk and in RAM until you upload it yourself.
Does samply need special permissions on Linux?
Yes. It reads perf events, so you either lower `kernel.perf_event_paranoid` with sudo, or on Linux 5.8 and later try granting the `CAP_PERFMON` capability to the binary, an approach the project says has produced mixed results. If you still hit an `mmap failed` error with an `EPERM`, raising `kernel.perf_event_mlock_kb` is the next step.
Why does my samply profile show no source lines for Rust code?
The binary was not compiled with debug info, or it was not the one you recorded. The recommended fix is a cargo profile that sets `debug = true`, then building with `cargo build --profile profiling` and recording that binary. For C++ the equivalent is including the `-g` flag in the compiler invocation.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/mstange-samply)Star history chart for your README
[](https://hysenlabs.com/projects/mstange-samply)Was this useful?