| 1 |
<page xmlns="http://projectmallard.org/1.0/" |
| 2 |
xmlns:its="http://www.w3.org/2005/11/its" |
| 3 |
type="topic" |
| 4 |
id="profiling"> |
| 5 |
<info> |
| 6 |
<link type="guide" xref="index#profiling"/> |
| 7 |
</info> |
| 8 |
<title>Profiling</title> |
| 9 |
<section id="system-profiling"> |
| 10 |
<title>How to profile your system</title> |
| 11 |
<p>When <app>Sysprof</app> profiles your system, it records stack |
| 12 |
information for all applications executing, including the Linux kernel. This |
| 13 |
can sometimes be confusing if you only want to look at a single process. If |
| 14 |
your application does not interact much with the host system, you may have more |
| 15 |
success by using <app>Sysprof</app> to |
| 16 |
<link href="profiling#new-process-profiling">spawn a new process</link>.</p> |
| 17 |
|
| 18 |
<p>To profile your entire system, ensure the target button is set to |
| 19 |
<em>All Processes</em> and click <em>Record</em>.</p> |
| 20 |
|
| 21 |
<p>At this point, you may be asked to <em>authorize</em> access to |
| 22 |
profile the system. This is required as the Linux kernel's perf |
| 23 |
implementation requires root to perform whole-system profiling.</p> |
| 24 |
|
| 25 |
<p>During the profiling session, you will see the number of |
| 26 |
seconds the profile has been active. Clicking the <em>Record</em> |
| 27 |
button again will stop the profiling session. Afterwhich, the callgraph |
| 28 |
will be displayed.</p> |
| 29 |
|
| 30 |
<note> |
| 31 |
<p>If you find that the <app>sysprof</app> application is showing up in |
| 32 |
your profiling callgraph, you might consider recording the profiling session |
| 33 |
with <cmd>sysprof-cli</cmd>. This is a command line program that will capture |
| 34 |
your profiling session to disk to be viewed at a later time.</p> |
| 35 |
</note> |
| 36 |
|
| 37 |
<p>See <link href="profiling#interpreting-results">interpreting |
| 38 |
results</link> for more guidance.</p> |
| 39 |
|
| 40 |
</section> |
| 41 |
|
| 42 |
<section id="new-process-profiling"> |
| 43 |
<info> |
| 44 |
<link type="guide" xref="index#profiling"/> |
| 45 |
</info> |
| 46 |
<title>Profile a new process</title> |
| 47 |
|
| 48 |
<p>Often times, you may need to spawn a new process to profile. |
| 49 |
First, select the <em>Application</em> button next at the top of the |
| 50 |
recording window. Fill in your command and working directory, and optionally |
| 51 |
specify any environment variables you need. Your process will be started |
| 52 |
when recording begins.</p> |
| 53 |
|
| 54 |
<note> |
| 55 |
<p>If you are spawning a process that requires access to your current |
| 56 |
display, such as a GTK+ application, you will want to make sure <em>Inherit |
| 57 |
current environment</em> is set.</p> |
| 58 |
</note> |
| 59 |
|
| 60 |
</section> |
| 61 |
|
| 62 |
<section id="sysprof-cli"> |
| 63 |
<info> |
| 64 |
<link type="guide" xref="index#profiling"/> |
| 65 |
</info> |
| 66 |
<title>Profiling with the sysprof-cli command line tool</title> |
| 67 |
|
| 68 |
<p>For minimal overhead, you might consider using the <cmd>sysprof-cli</cmd> |
| 69 |
command line tool. When run without any arguments, it will record your entire |
| 70 |
system and save the output to <file>capture.syscap</file>. This file can be |
| 71 |
opened with the <app>Sysprof</app> application to view the callgraph.</p> |
| 72 |
|
| 73 |
<p>If you would like to spawn a new process, use <cmd>sysprof-cli -- |
| 74 |
'command'</cmd> to specify a command to be launched. The command will inherit |
| 75 |
the current environment.</p> |
| 76 |
|
| 77 |
</section> |
| 78 |
|
| 79 |
<section id="interpreting-results"> |
| 80 |
<info> |
| 81 |
<link type="guide" xref="index#profiling"/> |
| 82 |
</info> |
| 83 |
<title>Interpreting results</title> |
| 84 |
|
| 85 |
<p>The profiling results in <app>Sysprof</app> are split into three |
| 86 |
sections. On the top left is a list of all the functions profiled. They |
| 87 |
are sorted by how often they were called during the recording.</p> |
| 88 |
|
| 89 |
<note> |
| 90 |
<p>It is important to note that the amount of time spent in each function |
| 91 |
is not captured. That would require a tracing profiler to accurately record. |
| 92 |
The percentage is calculated by determining how often that function showed |
| 93 |
up in the current stacktrace when a sample was recorded.</p> |
| 94 |
</note> |
| 95 |
|
| 96 |
<p>After selecting a function from the functions list, all of the recorded |
| 97 |
callers of that function will be displayed on the bottom left. They are also |
| 98 |
sorted by the percentage of samples that included that function in the |
| 99 |
stacktrace.</p> |
| 100 |
|
| 101 |
<p>On the right, are all of the decendants of a selected function. You can |
| 102 |
select a function either from the functions list, or the callers list.</p> |
| 103 |
|
| 104 |
<note> |
| 105 |
<p>If you see <em>- - Context Switch - -</em> in your results, that means that the |
| 106 |
application transitioned into or from the Linux kernel. There can be many reasons |
| 107 |
for this such as a <em>syscall</em> or <em>signal</em>.</p> |
| 108 |
</note> |
| 109 |
|
| 110 |
</section> |
| 111 |
|
| 112 |
</page> |