support for stats static userspace probes via systemtap

We currently only have probes for the logging sub-system.

This patch adds two tracepoints for tracing the performance
impact of statistics reporting: stat_start and stat_done.

They can be used to trace the amount of time a libosmocore-using
application spends in reporting/exporting statistics.  This includes
both the CPU time for encoding the statistics, as well as the system
calls for sending them.

Change-Id: I7208c45f6d051505dd2435305c67b4d26c0b1dd2
Related: OS#4311
Related: SYS#4877
This commit is contained in:
Harald Welte 2021-02-18 14:56:46 +01:00
parent 6e9dd02bf8
commit 3217d5187f
3 changed files with 26 additions and 0 deletions

View File

@ -1,4 +1,6 @@
provider libosmocore { provider libosmocore {
probe log_start(); probe log_start();
probe log_done(); probe log_done();
probe stats_start();
probe stats_done();
}; };

View File

@ -90,6 +90,17 @@
#include <osmocom/core/counter.h> #include <osmocom/core/counter.h>
#include <osmocom/core/msgb.h> #include <osmocom/core/msgb.h>
#ifdef HAVE_SYSTEMTAP
/* include the generated probes header and put markers in code */
#include "probes.h"
#define TRACE(probe) probe
#define TRACE_ENABLED(probe) probe ## _ENABLED()
#else
/* Wrap the probe to allow it to be removed when no systemtap available */
#define TRACE(probe)
#define TRACE_ENABLED(probe) (0)
#endif /* HAVE_SYSTEMTAP */
#define STATS_DEFAULT_INTERVAL 5 /* secs */ #define STATS_DEFAULT_INTERVAL 5 /* secs */
#define STATS_DEFAULT_BUFLEN 256 #define STATS_DEFAULT_BUFLEN 256
@ -781,6 +792,7 @@ static void flush_all_reporters()
int osmo_stats_report() int osmo_stats_report()
{ {
/* per group actions */ /* per group actions */
TRACE(LIBOSMOCORE_STATS_START());
osmo_counters_for_each(handle_counter, NULL); osmo_counters_for_each(handle_counter, NULL);
rate_ctr_for_each_group(rate_ctr_group_handler, NULL); rate_ctr_for_each_group(rate_ctr_group_handler, NULL);
osmo_stat_item_for_each_group(osmo_stat_item_group_handler, NULL); osmo_stat_item_for_each_group(osmo_stat_item_group_handler, NULL);
@ -788,6 +800,7 @@ int osmo_stats_report()
/* global actions */ /* global actions */
osmo_stat_item_discard_all(&current_stat_item_index); osmo_stat_item_discard_all(&current_stat_item_index);
flush_all_reporters(); flush_all_reporters();
TRACE(LIBOSMOCORE_STATS_DONE());
return 0; return 0;
} }

View File

@ -16,3 +16,14 @@ probe libosmocore_log_done = process("libosmocore").mark("log_done")
{ {
probestr = sprintf("%s", $$name); probestr = sprintf("%s", $$name);
} }
probe libosmocore_stats_start = process("libosmocore").mark("statsd_start")
{
count = $arg1;
probestr = sprintf("%s(count=%d), $$name, count);
}
probe libosmocore_stats_done = process("libosmocore").mark("statsd_done")
{
probestr = sprintf("%s", $$name);
}