Skip to content

Commit 5695dfd

Browse files
aplopezalexey-tikhonov
authored andcommitted
Adding a profiling page
1 parent e2a2b1a commit 5695dfd

File tree

2 files changed

+114
-0
lines changed

2 files changed

+114
-0
lines changed

src/contents.rst

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Table of Contents
1212
contrib/debugging-sssd
1313
contrib/coding-style
1414
contrib/running-tests
15+
contrib/profiling-sssd
1516

1617
.. toctree::
1718
:caption: Fundamentals

src/contrib/profiling-sssd.rst

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
Profiling SSSD
2+
##############
3+
4+
Getting Ready
5+
*************
6+
7+
There are several tools allowing us to profile an application. We will focus on
8+
perf_ which seems to be the one that works best with SSSD.
9+
10+
.. _perf: https://perf.wiki.kernel.org
11+
12+
First you need to install the ``perf`` tool:
13+
14+
.. code-tabs::
15+
16+
.. fedora-tab::
17+
18+
# dnf -y install perf js-d3-flame-graph
19+
20+
.. ubuntu-tab::
21+
22+
$ sudo apt install linux-tools-common linux-tools-generic
23+
24+
25+
Make sure the debug information is available for SSSD and all its dependencies
26+
either by using ``debuginfod``, or by manually installing the debug information
27+
packages:
28+
29+
.. code-tabs::
30+
31+
.. fedora-tab::
32+
33+
# dnf debuginfo-install -y sssd* libsss_* samba-client-libs libsmbclient \
34+
libldb libtevent libtalloc libini_config c-ares glibc
35+
36+
.. ubuntu-tab::
37+
38+
$ sudo apt install sssd-ad-common-dbgsym sssd-ad-dbgsym sssd-common-dbgsym \
39+
sssd-dbus-dbgsym sssd-ipa-dbgsym sssd-kcm-dbgsym sssd-krb5-common-dbgsym \
40+
sssd-krb5-dbgsym sssd-ldap-dbgsym sssd-proxy-dbgsym sssd-tools-dbgsym \
41+
libsss-certmap0-dbgsym libsss-idmap0-dbgsym libsss-nss-idmap0-dbgsym \
42+
libsss-simpleifp0-dbgsym libsss-sudo-dbgsym libldb2-dbgsym libtdb1-dbgsym \
43+
libtalloc2-dbgsym libtevent0-dbgsym libc6-dbgsym
44+
45+
.. seealso::
46+
47+
More information on `Debug Symbol Packages`_ for Ubuntu.
48+
49+
.. _`Debug Symbol Packages`: https://documentation.ubuntu.com/server/reference/debugging/debug-symbol-packages/
50+
51+
.. note::
52+
53+
If you are using SELinux, the shipped targeted policy may prevent ``perf``
54+
from interacting with the SSSD process. You can put SELinux into permissive
55+
mode to confirm or look at the audit logs and add the required rules. Rules
56+
can be added using ``audit2allow``.
57+
58+
Profiling
59+
*********
60+
61+
The simplest way to profile one of the SSSD's daemons is to attach the profiler
62+
to the process while it is running.
63+
64+
Once SSSD is running and ready to be profiled, identify the PID of the process
65+
you want to monitor (``sssd_ssh``, ``sssd_nss``, ``sssd_be``, etc.), start the
66+
``perf`` command in the background, launch the command you want to profile
67+
and stop the profiling after the command completes:
68+
69+
.. code-block:: console
70+
:caption: `Profiling the LDAP domain daemon during the id command`
71+
72+
# PID=$(pgrep -f 'sssd_be --domain LDAP')
73+
# perf record --pid=$PID --call-graph=dwarf -e cycles:u &
74+
# id user1002@LDAP
75+
# kill %%
76+
77+
.. code-block:: console
78+
:caption: `Profiling the sssd_nss daemon during the ls command`
79+
80+
# perf record --pid=$(pgrep -f 'sssd_nss') --call-graph=dwarf -e cycles:u &
81+
# ls -l /tmp
82+
# kill %%
83+
84+
85+
This will create a ``perf.data`` file in your current directory. It is
86+
recommended to process this file in the same machine, so that the debug
87+
information matches perfectly the installed binaries. You can later move the
88+
results to another host.
89+
90+
The ``-e cycles:u`` argument tells ``perf`` to only monitor the CPU cycles the
91+
application consumes in user space. The kernel will not be profiled. Check the
92+
``perf-record(1)`` man page for more options that might be useful in you
93+
particular case.
94+
95+
Generating the Reports
96+
**********************
97+
98+
We will create two types of reports: a text report and a flame graph to be seen
99+
in a web browser:
100+
101+
.. code-block:: console
102+
103+
# perf report -g > report.txt
104+
# perf script report flamegraph
105+
106+
The files ``report.txt`` and ``flamegraph.html`` contain the reports, are
107+
self-contained, and can safely be moved to another host.
108+
109+
.. seealso::
110+
111+
Other reports are available. You can learn about them in the
112+
``perf-report(1)`` and ``perf-script(1)`` man pages.
113+

0 commit comments

Comments
 (0)