<p>laforge has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/22958">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">support for stats static userspace probes via systemtap<br><br>We currently only have probes for the logging sub-system.<br><br>This patch adds two tracepoints for tracing the performance<br>impact of statistics reporting: stat_start and stat_done.<br><br>They can be used to trace the amount of time a libosmocore-using<br>application spends in reporting/exporting statistics.  This includes<br>both the CPU time for encoding the statistics, as well as the system<br>calls for sending them.<br><br>Change-Id: I7208c45f6d051505dd2435305c67b4d26c0b1dd2<br>Related: OS#4311<br>Related: SYS#4877<br>---<br>M src/probes.d<br>M src/stats.c<br>M tapset/libosmocore.stp<br>3 files changed, 26 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/58/22958/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/probes.d b/src/probes.d</span><br><span>index c16eb1e..e4150f0 100644</span><br><span>--- a/src/probes.d</span><br><span>+++ b/src/probes.d</span><br><span>@@ -1,4 +1,6 @@</span><br><span> provider libosmocore {</span><br><span>      probe log_start();</span><br><span>   probe log_done();</span><br><span style="color: hsl(120, 100%, 40%);">+     probe stats_start();</span><br><span style="color: hsl(120, 100%, 40%);">+  probe stats_done();</span><br><span> };</span><br><span>diff --git a/src/stats.c b/src/stats.c</span><br><span>index c91a978..a0834d2 100644</span><br><span>--- a/src/stats.c</span><br><span>+++ b/src/stats.c</span><br><span>@@ -90,6 +90,17 @@</span><br><span> #include <osmocom/core/counter.h></span><br><span> #include <osmocom/core/msgb.h></span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#ifdef HAVE_SYSTEMTAP</span><br><span style="color: hsl(120, 100%, 40%);">+/* include the generated probes header and put markers in code */</span><br><span style="color: hsl(120, 100%, 40%);">+#include "probes.h"</span><br><span style="color: hsl(120, 100%, 40%);">+#define TRACE(probe) probe</span><br><span style="color: hsl(120, 100%, 40%);">+#define TRACE_ENABLED(probe) probe ## _ENABLED()</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+/* Wrap the probe to allow it to be removed when no systemtap available */</span><br><span style="color: hsl(120, 100%, 40%);">+#define TRACE(probe)</span><br><span style="color: hsl(120, 100%, 40%);">+#define TRACE_ENABLED(probe) (0)</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* HAVE_SYSTEMTAP */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> #define STATS_DEFAULT_INTERVAL 5 /* secs */</span><br><span> #define STATS_DEFAULT_BUFLEN 256</span><br><span> </span><br><span>@@ -781,6 +792,7 @@</span><br><span> int osmo_stats_report()</span><br><span> {</span><br><span>         /* per group actions */</span><br><span style="color: hsl(120, 100%, 40%);">+       TRACE(LIBOSMOCORE_STATS_START());</span><br><span>    osmo_counters_for_each(handle_counter, NULL);</span><br><span>        rate_ctr_for_each_group(rate_ctr_group_handler, NULL);</span><br><span>       osmo_stat_item_for_each_group(osmo_stat_item_group_handler, NULL);</span><br><span>@@ -788,6 +800,7 @@</span><br><span>     /* global actions */</span><br><span>         osmo_stat_item_discard_all(&current_stat_item_index);</span><br><span>    flush_all_reporters();</span><br><span style="color: hsl(120, 100%, 40%);">+        TRACE(LIBOSMOCORE_STATS_DONE());</span><br><span> </span><br><span>         return 0;</span><br><span> }</span><br><span>diff --git a/tapset/libosmocore.stp b/tapset/libosmocore.stp</span><br><span>index 0ec3c42..a3e8f21 100644</span><br><span>--- a/tapset/libosmocore.stp</span><br><span>+++ b/tapset/libosmocore.stp</span><br><span>@@ -16,3 +16,14 @@</span><br><span> {</span><br><span>  probestr = sprintf("%s", $$name);</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+probe libosmocore_stats_start = process("libosmocore").mark("statsd_start")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ count = $arg1;</span><br><span style="color: hsl(120, 100%, 40%);">+ probestr = sprintf("%s(count=%d), $$name, count);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+probe libosmocore_stats_done = process("libosmocore").mark("statsd_done")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ probestr = sprintf("%s", $$name);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/22958">change 22958</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/22958"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I7208c45f6d051505dd2435305c67b4d26c0b1dd2 </div>
<div style="display:none"> Gerrit-Change-Number: 22958 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>