Browse Source

MT#57335 Move `stats_rate_min_max()` to a separate thread

To do the work more efficiently,
and not be dependent on the call_timer runs by poller,
we should move the `stats_rate_min_max()` to a separate thread,
to make it faster and not be dependent on what happens in the `call_timer` at all.
Since it has nothing to do with the call timers.

Change-Id: I9a39e1b63cb8741377f5af5b2d52d4f8b428a0ad
pull/1646/head
Donat Zenichev 3 years ago
parent
commit
905d584902
4 changed files with 18 additions and 3 deletions
  1. +0
    -3
      daemon/call.c
  2. +4
    -0
      daemon/main.c
  3. +13
    -0
      daemon/statistics.c
  4. +1
    -0
      include/statistics.h

+ 0
- 3
daemon/call.c View File

@ -572,9 +572,6 @@ void call_timer(void *ptr) {
stats_counters_calc_rate(&rtpe_stats, run_diff_us, &rtpe_stats_intv, &rtpe_stats_rate); stats_counters_calc_rate(&rtpe_stats, run_diff_us, &rtpe_stats_intv, &rtpe_stats_rate);
// TODO: should be moved into a separate thread/timer
stats_rate_min_max(&rtpe_rate_graphite_min_max, &rtpe_stats_rate);
// stats derived while iterating calls // stats derived while iterating calls
RTPE_GAUGE_SET(transcoded_media, hlp.transcoded_media); RTPE_GAUGE_SET(transcoded_media, hlp.transcoded_media);


+ 4
- 0
daemon/main.c View File

@ -1350,6 +1350,10 @@ int main(int argc, char **argv) {
thread_create_detach_prio(sockets_releaser, NULL, rtpe_config.idle_scheduling, thread_create_detach_prio(sockets_releaser, NULL, rtpe_config.idle_scheduling,
rtpe_config.idle_priority, "release closed sockets"); rtpe_config.idle_priority, "release closed sockets");
/* separate thread for update of running min/max call counters */
thread_create_detach_prio(call_rate_stats_updater, NULL, rtpe_config.idle_scheduling,
rtpe_config.idle_priority, "call rate stats");
if (!is_addr_unspecified(&rtpe_config.redis_ep.address) && initial_rtpe_config.redis_delete_async) if (!is_addr_unspecified(&rtpe_config.redis_ep.address) && initial_rtpe_config.redis_delete_async)
thread_create_detach(redis_delete_async_loop, NULL, "redis async"); thread_create_detach(redis_delete_async_loop, NULL, "redis async");


+ 13
- 0
daemon/statistics.c View File

@ -1017,3 +1017,16 @@ const char *statistics_ng(bencode_item_t *input, bencode_item_t *output) {
return NULL; return NULL;
} }
/**
* Separate thread for update of running min/max call counters.
*/
void call_rate_stats_updater(void * dummy) {
while (!rtpe_shutdown) {
stats_rate_min_max(&rtpe_rate_graphite_min_max, &rtpe_stats_rate);
thread_cancel_enable();
usleep(1000000); /* sleep for 1 second in each iteration */
thread_cancel_disable();
}
}

+ 1
- 0
include/statistics.h View File

@ -197,6 +197,7 @@ void statistics_update_foreignown_inc(struct call* c);
GQueue *statistics_gather_metrics(struct interface_sampled_rate_stats *); GQueue *statistics_gather_metrics(struct interface_sampled_rate_stats *);
void statistics_free_metrics(GQueue **); void statistics_free_metrics(GQueue **);
const char *statistics_ng(bencode_item_t *input, bencode_item_t *output); const char *statistics_ng(bencode_item_t *input, bencode_item_t *output);
void call_rate_stats_updater(void * dummy);
INLINE void stats_counters_calc_rate(const struct global_stats_counter *stats, long long run_diff_us, INLINE void stats_counters_calc_rate(const struct global_stats_counter *stats, long long run_diff_us,
struct global_stats_counter *intv, struct global_stats_counter *rate) struct global_stats_counter *intv, struct global_stats_counter *rate)


Loading…
Cancel
Save