Distinguish between two different types of "gauge" type metrics: Actual
gauges which (at least conceptually) have a single continuous value, and
metrics which are comprised of discretely sampled values, possibly from
multiple sources.
Real gauges with continuous values don't have mean/average/deviation
values directly associated with them, as calculating these requires
sampling or some other analysis.
Sampled metrics on the other hand do have these associated values.
Clarify which function does what and where each value comes from.
Change-Id: Iff5dd844b70ff70979b1b8c84dc7734d44b3da20
Perform accumulation of stats only once (i.e. increasing an actual
counter) and report stats based on differences to previous values,
instead of carrying multiple stats counters for each metric and
resetting each counter to zero whenever stats are reported.
`rtpe_stats` is the global master accumulator.
`_intv` variables are intermediate and local storage for values sampled
from `rtpe_stats` at regular intervals.
`_rate` and `_diff` variables hold stats calculated from `rtpe_stats`
and the respective `_intv` variable whenever the sampling and reporting
occurs.
`stats_counters_calc_diff` is used to calculate stats as differences
between `rtpe_stats` and the last sampled `_intv`
`stats_counters_calc_rate` does the same but calculates a per-second
rate, based on a microsecond duration.
Eliminate now-useless struct global_stats_ax
Change-Id: Ic4ca630161787025219b67e49b41995204d60573
On bookworm and later, libasan reports a false positive in combination
with pthread_cleanup_push() (see [1]). Work around this by not using the
thread cleanup handler when running the asan build, and instead use a
shorter thread sleep time.
[1] https://gcc.gnu.org/bugzilla//show_bug.cgi?id=82109
Change-Id: Ieffdc0b13f470445f1f8e1d2448c6af6d8dd68e0
Instead of having each thread sleep only a little while and then
periodically check for the shutdown flag, make them sleep longer and use
pthread_cancel() to interrupt the sleep during a shutdown in the
designated break points.
Change-Id: I13f1872a0176697e064ceef4062db6ca6ccf7a0e
The only reason the wait time in timer threads is capped at 100 ms is to
catch the daemon's shutdown. Since these threads already use a
condition variable to be woken up, we can use the same condition to wake
up the threads during a shutdown, allowing for a much longer (possibly
unlimited) sleep time in timer threads.
Change-Id: I3b5f280a4d502176a731e8b52b1b731022c8db4f
The glib macro for g_atomic_pointer_get() uses typeof() with an
intermediate variable, resulting in a stray compiler warning if the
argument uses `const` as the intermediate variable also ends up being
const. Use an extra non-const intermediate variable to work around this.
closes#1270
Change-Id: I3bf1404240d3b8571aaf40c38b524f578e0fdbd9
When the compiler does not have support for the __error__ attribute,
fallback to use the GCC posion pragma, which works on both gcc and
clang. It ha the advantage of being more portable and working at the
preprocessor level, which means is not affected by symbol redirection
due to builtin conversion or stack-protector remapping, at the cost of
worse diagnostics.
Change-Id: I322396f8a0d1b993637e8aca27f27f6868ecba3c
Warned-by: clang-12
The function argument where the cast is applied is volatile void *,
use the same type on the cast.
Change-Id: I2e39c433962df4f31ff8cad4d7561d358e94928a
Warned-by: clang-12
While these usages are not supposed to be security sensitive, it's still
best to avoid the usage altogether so that we do not need to think about
it. Add a taint macro so that this does not regress in the future.
Change-Id: Ic75861ed1b7ce9dfca4f897de8be2408204ce3cb
Warned-by: coverity