|
| 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 | +More information on `Debug Symbol Packages`_ for Ubuntu. |
| 37 | + |
| 38 | +.. _`Debug Symbol Packages`: https://documentation.ubuntu.com/server/reference/debugging/debug-symbol-packages/ |
| 39 | + |
| 40 | +It is possible that SELinux prevents ``perf`` from monitoring your process. |
| 41 | +If that happens, you can create the required rules or temporarily disable selinux: |
| 42 | + |
| 43 | +.. code-block:: console |
| 44 | +
|
| 45 | + # setenforce Permissive |
| 46 | +
|
| 47 | +
|
| 48 | +Profiling |
| 49 | +********* |
| 50 | + |
| 51 | +The simplest way to profile one of the SSSD's daemons is to attach the profiler |
| 52 | +to the process while it is running. |
| 53 | + |
| 54 | +Once SSSD is running and ready to be profiled, identify the PID of the process |
| 55 | +you want to monitor (``sssd_ssh``, ``sssd_nss``, ``sssd_be``, etc.), start the |
| 56 | +``perf`` command in the background, launch the operation you want to profile |
| 57 | +and stop the profiling after the operation completes: |
| 58 | + |
| 59 | +.. code-block:: console |
| 60 | +
|
| 61 | + # PID=$(pgrep -f 'sssd_be --domain LDAP') |
| 62 | + # perf record --pid=$PID --call-graph=dwarf -e cycles:u & |
| 63 | + # id user1002@LDAP |
| 64 | + # kill %% |
| 65 | +
|
| 66 | +This will create a ``perf.data`` file in your current directory. It is |
| 67 | +recommended to process this file in the same machine, so that the debug |
| 68 | +information matches perfectly the installed binaries. You can later move the |
| 69 | +results to another host. |
| 70 | + |
| 71 | +The ``-e cycles:u`` argument tells ``perf`` to only monitor the CPU cycles the |
| 72 | +application consumes in user space. The kernel will not be profiled. Check the |
| 73 | +``perf-record(1)`` man page for more options that might be useful in you |
| 74 | +particular case. |
| 75 | + |
| 76 | +Generating the Reports |
| 77 | +********************** |
| 78 | + |
| 79 | +We will create two types of reports: a text report and a flame graph to be seen |
| 80 | +in a web browser. But before doing that, it is necessary to update ``perf``'s |
| 81 | +cache of debug information: |
| 82 | + |
| 83 | +.. code-block:: console |
| 84 | +
|
| 85 | + # perf buildid-list |
| 86 | + # perf report -g > report.txt |
| 87 | + # perf script report flamegraph |
| 88 | +
|
| 89 | +The files ``report.txt`` and ``flamegraph.html`` contain the reports, are |
| 90 | +self-containerd, and can safely be moved to another host. |
| 91 | + |
| 92 | +Other reports are available. You can learn about them in the ``perf-script(1)`` |
| 93 | +man page. |
| 94 | + |
0 commit comments