You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+57-9Lines changed: 57 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -2,16 +2,58 @@
2
2
3
3
samply is a command line CPU profiler which uses the [Firefox profiler](https://profiler.firefox.com/) as its UI.
4
4
5
-
At the moment it runs on macOS and Linux. Windows support is planned. samply is still under development and far from finished, but works quite well already.
5
+
samply works on macOS and Linux. Windows support is planned.
6
6
7
-
Give it a try:
7
+
In order to profile the execution of `./my-application`, prepend `samply record` to the command invocation:
8
8
9
+
```sh
10
+
samply record ./my-application my-arguments
9
11
```
10
-
% cargo install samply
11
-
% samply record ./your-command your-arguments
12
+
13
+
On Linux, samply uses perf events. You can grant temporary access by running:
14
+
15
+
```sh
16
+
echo'1'| sudo tee /proc/sys/kernel/perf_event_paranoid
17
+
```
18
+
19
+
## Installation
20
+
21
+
You have the following options to install samply:
22
+
23
+
### Install prebuilt binaries via shell script
24
+
25
+
```sh
26
+
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/mstange/samply/releases/download/samply-v0.12.0/samply-installer.sh | sh
27
+
```
28
+
29
+
### Install prebuilt binaries via powershell script
This spawns `./your-command your-arguments` in a subprocess and records a profile of its execution. When the command finishes, samply opens
35
+
### Install from crates.io with cargo
36
+
37
+
```sh
38
+
cargo install --locked samply
39
+
```
40
+
41
+
### Build from source
42
+
43
+
```sh
44
+
git clone https://github.com/mstange/samply
45
+
cd samply
46
+
cargo build --release
47
+
./target/release/samply ...
48
+
```
49
+
50
+
## Description
51
+
52
+
```sh
53
+
samply record ./my-application my-arguments
54
+
```
55
+
56
+
This spawns `./my-application my-arguments` in a subprocess and records a profile of its execution. When the command finishes, samply opens
15
57
[profiler.firefox.com](https://profiler.firefox.com/) in your default browser, loads the recorded profile in it, and starts a local webserver which serves symbol information and source code.
16
58
17
59
Then you can inspect the profile. And you can upload it.
@@ -32,16 +74,22 @@ samply is a sampling profiler and collects stack traces, per thread, at some sam
32
74
33
75
On Linux, samply needs access to performance events system for unprivileged users. For this, you can either:
34
76
35
-
-if using Linux 5.8 or later, set the `CAP_PERFMON` capability as effective and permitted for samply (recommended):
77
+
-Grant access until reboot:
36
78
79
+
```sh
80
+
echo'1'| sudo tee /proc/sys/kernel/perf_event_paranoid
37
81
```
38
-
sudo setcap 'cap_perfmon+ep' `which samply`
82
+
83
+
- Grant access more permanently:
84
+
85
+
```sh
86
+
sudo sysctl kernel.perf_event_paranoid=1
39
87
```
40
88
41
-
-allow use of (almost) all events by changing the `perf_event_paranoid` kernel variable (not recommended):
89
+
-If using Linux 5.8 or later, you can try setting the `CAP_PERFMON` capability as effective and permitted for samply, though people have reported mixed results with this approach:
42
90
43
91
```
44
-
sudo sysctl kernel.perf_event_paranoid=-1
92
+
sudo setcap 'cap_perfmon+ep' `which samply`
45
93
```
46
94
47
95
If you still get a `mmap failed` error (an `EPERM`), you might also need to increase the `mlock` limit, e.g.:
0 commit comments