Skip to content

Commit 5f96b83

Browse files
committed
Create PROFILING.md
1 parent cf6e0bd commit 5f96b83

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Framework/Core/PROFILING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Profiling using perf
2+
3+
## Setup
4+
5+
the perf suite is a great profiler suite which is part of the Linux kernel itself. It provides very fine grained view of the state of a running system. By default, however the result you get on Ubuntu or Centos are not particulary good due to security reasons. However if the workstation you are running perf is your own, those defaults can probably be relaxed to provide a better profile expirience. First of all, allow profiling at all:
6+
7+
```bash
8+
echo -1 > /proc/sys/kernel/perf_event_paranoid
9+
```
10+
11+
then allow users to see the addres of kernel functions:
12+
13+
```bash
14+
echo 0 > /proc/sys/kernel/kptr_restrict
15+
```
16+
17+
In order to profile one needs to either run a command prefixing it with:
18+
19+
```
20+
perf record -F 999 -g --call-graph dwarf
21+
```
22+
23+
or the PID of the running process must be provided via
24+
25+
```
26+
-p <PID>
27+
```
28+
29+
alternatively you can profile all the processes on a given box using `-a`.
30+
31+
The above will accumulate results in a file called `perf.data`. Make sure you remove `perf.data` between runs, because they will otherwise accumulate.
32+
33+
In order to view the results, one must run `perf script`. e.g.:
34+
35+
```
36+
perf script -i perf.data --no-inline | c++filt -r -t > profile.linux-perf.txt
37+
```
38+
39+
results can then be visualised by drag and dropping them at <https://speedscope.app>.

0 commit comments

Comments
 (0)