Skip to content

Commit 818551d

Browse files
committed
Adding a profiling page
1 parent e2a2b1a commit 818551d

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-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

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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 SSSD's and its dependencies' debug information is available, either
26+
by using ``debuginfod``, or by manually installing the debug information packages:
27+
28+
.. code-tabs::
29+
30+
.. fedora-tab::
31+
32+
# dnf -y --enable-repo=fedora-debuginfo --enable-repo=updates-debuginfo \
33+
install sssd*debuginfo libsss_*-debuginfo samba-client-libs-debuginfo \
34+
libldb-debuginfo libtevent-debuginfo libtalloc-debuginfo glibc-debuginfo
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+
It is possible that SELinux prevents ``perf`` from monitoring your process.
54+
If that happens, you can create the required rules or temporarily disable
55+
selinux:
56+
57+
.. code-block:: console
58+
59+
# setenforce Permissive
60+
61+
62+
Profiling
63+
*********
64+
65+
The simplest way to profile one of the SSSD's daemons is to attach the profiler
66+
to the process while it is running.
67+
68+
Once SSSD is running and ready to be profiled, identify the PID of the process
69+
you want to monitor (``sssd_ssh``, ``sssd_nss``, ``sssd_be``, etc.), start the
70+
``perf`` command in the background, launch the operation you want to profile
71+
and stop the profiling after the operation completes:
72+
73+
.. code-block:: console
74+
75+
# PID=$(pgrep -f 'sssd_be --domain LDAP')
76+
# perf record --pid=$PID --call-graph=dwarf -e cycles:u &
77+
# id user1002@LDAP
78+
# kill %%
79+
80+
This will create a ``perf.data`` file in your current directory. It is
81+
recommended to process this file in the same machine, so that the debug
82+
information matches perfectly the installed binaries. You can later move the
83+
results to another host.
84+
85+
The ``-e cycles:u`` argument tells ``perf`` to only monitor the CPU cycles the
86+
application consumes in user space. The kernel will not be profiled. Check the
87+
``perf-record(1)`` man page for more options that might be useful in you
88+
particular case.
89+
90+
Generating the Reports
91+
**********************
92+
93+
We will create two types of reports: a text report and a flame graph to be seen
94+
in a web browser. But before doing that, it is necessary to update ``perf``'s
95+
cache of debug information:
96+
97+
.. code-block:: console
98+
99+
# perf buildid-list
100+
# perf report -g > report.txt
101+
# perf script report flamegraph
102+
103+
The files ``report.txt`` and ``flamegraph.html`` contain the reports, are
104+
self-containerd, and can safely be moved to another host.
105+
106+
Other reports are available. You can learn about them in the ``perf-script(1)``
107+
man page.
108+

0 commit comments

Comments
 (0)