genode/repos/gems/src/server/cpu_sampler
Martin Stein 181c78d482 timeout: use uint64_t for all plain time values
This enforces the use of unsigned 64-bit values for time in the duration type,
the timeout framework, the timer session, the userland timer-drivers, and the
alarm framework on all platforms. The commit also adapts the code that uses
these tools accross all basic repositories (base, base-*, os. gems, libports,
ports, dde_*) to use unsigned 64-bit values for time as well as far as this
does not imply profound modifications.

Fixes #3208
2019-05-06 16:15:26 +02:00
..
README cpu_sampler component for statistical profiling 2016-08-29 17:29:37 +02:00
cpu_root.h Adjust file headers to refer to the AGPLv3 2017-02-28 12:59:29 +01:00
cpu_session_component.cc Fix some deprecated warnings 2017-03-24 16:20:03 +01:00
cpu_session_component.h Adjust file headers to refer to the AGPLv3 2017-02-28 12:59:29 +01:00
cpu_thread_component.cc Fix some deprecated warnings 2017-03-24 16:20:03 +01:00
cpu_thread_component.h gems: remove the use of deprecated APIs 2019-01-30 13:49:54 +01:00
main.cc timeout: use uint64_t for all plain time values 2019-05-06 16:15:26 +02:00
target.mk Exclude higher-level repos from strict warnings 2018-01-17 12:14:36 +01:00
thread_list_change_handler.h Adjust file headers to refer to the AGPLv3 2017-02-28 12:59:29 +01:00

README

This component implements a CPU service which samples the instruction pointer
of the configured threads on a regular basis for the purpose of statistical
profiling.

The collected samples are written to the LOG session with an individual label
for each thread. By using the 'fs_log' component, the sample data can be
written into separate files if desired.

Configuration options
---------------------

! <config sample_interval_ms="100" sample_duration_s="1">
!   <policy label="init -> test-cpu_sampler -> ep" />
! </config>

The 'sample_interval_ms' attribute configures the time between two samples in
milliseconds.

The 'sample_duration_s' attribute configures the overall duration of the
sampling activity in seconds.

The policy configures the threads to be sampled.

The clients of the CPU sampler component must be at least grand children of the
initial init process to have their CPU sessions routed correctly. An example
configuration using a sub-init process can be found in the 'cpu_sampler.run'
script.

Evaluation
----------

Currently, some basic tools for the evaluation of the sampled addresses are
available at

[https://github.com/cproc/genode_stuff/tree/cpu_sampler-16.08]

* Filtering the sampled addresses from the Genode log output

  ! filter_sampled_addresses_from_log <file containing the Genode log output>

  This script extracts the sampled addresses from a file containing the Genode
  log output and saves them in the file 'sampled_addresses.txt'. It is not
  needed when the addresses have already been written into a separate file by
  the 'fs_log' component. The match string (label) in the script might need to
  be adapted for the specific scenario.

* Filtering the shared library load addresses from the Genode log output

  ! filter_ldso_addresses_from_log <file containing the Genode log output>

  This script extracts the shared library load addresses from a file containing
  the Genode log output and saves them in the file 'ldso_addresses.txt'. To have
  these addresses appear in the Genode log output, the sampled component should
  be configured with the 'ld_verbose="yes"' XML attribute if it uses shared
  libraries. If multiple components in a scenario are configured with this
  attribute, the script needs to be adapted to match a specific label.

* Generating statistics

  ! generate_statistics <ELF image> <file with sampled addresses> [<file with ldso addresses>]

  This script generates the files 'statistics_by_function.txt' and
  'statistics_by_address.txt'.

  The first argument is the name of the ELF image of the sampled component.
  The second argument is the name of a file containing the sampled addresses.
  The third argument is the name of a file containing the shared library load
  addresses. It is only needed if the sampled component uses shared libraries.

  The 'statistics_by_function.txt' file lists the names of the sampled
  functions, sorted by the highest sample count. Each line comprehends
  all sampled addresses which belong to the particular function.

  The 'statistics_by_address.txt' file is more detailed than the
  'statistics_by_function.txt' file. It lists the sampled addresses, sorted by
  the highest sample count, together with the name and file location of the
  function the particular address belongs to.

The 'generate_statistics' script uses the 'backtrace' script to determine the
function names and file locations. The best location to use the scripts is
the 'build/.../bin' directory, where all the shared libraries can be found.