Skip to content

samply - Sampling Profiler with Firefox Profiler UI Cheatsheet

samply - Sampling Profiler with Firefox Profiler UI Cheatsheet

samply is a cross-platform command-line sampling profiler for macOS, Linux, and Windows. It samples stack traces of a command or a running process (default ~1000 Hz) and then serves the results to the Firefox Profiler web UI — a mature, interactive front end with flame graphs, stack charts, a call tree, and per-thread timelines. It profiles native code (C/C++/Rust/Go) and other languages that emit standard stack info, with no code changes required.

Installation

MethodCommand
Cargocargo install --locked samply
Binarydownload from the GitHub Releases page
Linux perf event accessmay need sysctl kernel.perf_event_paranoid=1 (or lower)
Verifysamply --version

Basic Usage

CommandDescription
samply record ./my-program argsProfile a command, then open the UI
samply record -- cargo run --releaseProfile after -- (pass flags through)
samply record --pid 1234Profile an already-running process
samply load profile.json.gzRe-open a saved profile in the UI
samply --helpFull option list

Recording Options

OptionDescription
-r, --rate NSampling rate in Hz (default ~1000)
-o, --output FILESave the profile to a file
--save-onlyRecord without launching the browser UI
-p, --pid PIDAttach to a running process
-d, --duration SECSProfile for a fixed duration
--reuse-threadsThread handling tweak for some workloads
--Everything after is the command + its args

The Firefox Profiler UI

After recording, samply opens a local Firefox Profiler view. Key panels:

PanelShows
Flame graphAggregated stacks (where time is spent)
Stack chartTime on the x-axis, stacks stacked vertically
Call treeTop-down / bottom-up hierarchy with self/total time
Marker chartEvents over time (if present)
TimelinePer-thread activity; select a range to focus
UI actionUse
Select a time rangeFocus analysis on part of the run
Invert call stackFind hot leaf functions (self time)
SearchFilter the call tree by function name
Share/exportSave or upload the profile

Workflow Tips

GoalApproach
Find CPU hot pathsRecord, open flame graph, look for wide frames
Find a specific slow phaseSelect that time range in the timeline
Compare buildsSave profiles and load side by side
Reduce noiseProfile release builds with debug info (debug = true)

Common Workflows

# Profile a Rust release build (keep symbols with debug info)
samply record -- cargo run --release

# Profile a running server for 20 seconds
samply record --pid $(pgrep -n myserver) -d 20

# Record headless in CI, inspect the artifact later
samply record --save-only -o prof.json.gz ./bench
samply load prof.json.gz

samply vs Other Profilers

Aspectsamplyperf + FlameGraphhotspot
PlatformsmacOS/Linux/WindowsLinuxLinux
UIFirefox Profiler (rich)Static SVGQt GUI
SetupSingle binaryMultiple toolsGUI install
Best forCross-platform, interactiveScripted Linux profilingQt/perf GUI users

Resources