Browse Source

MT#55283 add timer-accuracy= option

Change-Id: I32eb05a5eaacccd2ef3e553a90a1eada33a9f50d
coverity_scan
Richard Fuchs 9 months ago
parent
commit
082f3f91cf
4 changed files with 18 additions and 1 deletions
  1. +5
    -0
      daemon/main.c
  2. +4
    -1
      daemon/timerthread.c
  3. +8
    -0
      docs/rtpengine.md
  4. +1
    -0
      include/main.h

+ 5
- 0
daemon/main.c View File

@ -121,6 +121,7 @@ struct rtpengine_config rtpe_config = {
}, },
.max_recv_iters = MAX_RECV_ITERS, .max_recv_iters = MAX_RECV_ITERS,
.kernel_player_media = 128, .kernel_player_media = 128,
.timer_accuracy = 500,
}; };
struct interface_config_callback_arg { struct interface_config_callback_arg {
@ -738,6 +739,7 @@ static void options(int *argc, char ***argv, charp_ht templates) {
{ "http-threads", 0,0, G_OPTION_ARG_INT, &rtpe_config.http_threads,"Number of worker threads for HTTP and WS","INT"}, { "http-threads", 0,0, G_OPTION_ARG_INT, &rtpe_config.http_threads,"Number of worker threads for HTTP and WS","INT"},
{ "software-id", 0,0, G_OPTION_ARG_STRING, &rtpe_config.software_id,"Identification string of this software presented to external systems","STRING"}, { "software-id", 0,0, G_OPTION_ARG_STRING, &rtpe_config.software_id,"Identification string of this software presented to external systems","STRING"},
{ "poller-per-thread", 0,0, G_OPTION_ARG_NONE, &rtpe_config.poller_per_thread, "Use poller per thread", NULL }, { "poller-per-thread", 0,0, G_OPTION_ARG_NONE, &rtpe_config.poller_per_thread, "Use poller per thread", NULL },
{ "timer-accuracy", 0,0,G_OPTION_ARG_INT, &rtpe_config.timer_accuracy,"Minimum number of microseconds to sleep","INT"},
#ifdef WITH_TRANSCODING #ifdef WITH_TRANSCODING
{ "dtx-delay", 0,0, G_OPTION_ARG_INT, &rtpe_config.dtx_delay, "Delay in milliseconds to trigger DTX handling","INT"}, { "dtx-delay", 0,0, G_OPTION_ARG_INT, &rtpe_config.dtx_delay, "Delay in milliseconds to trigger DTX handling","INT"},
{ "max-dtx", 0,0, G_OPTION_ARG_INT, &rtpe_config.max_dtx, "Maximum duration of DTX handling", "INT"}, { "max-dtx", 0,0, G_OPTION_ARG_INT, &rtpe_config.max_dtx, "Maximum duration of DTX handling", "INT"},
@ -1280,6 +1282,9 @@ static void options(int *argc, char ***argv, charp_ht templates) {
die("Number of CPU cores is unknown, cannot auto-set socket CPU affinity"); die("Number of CPU cores is unknown, cannot auto-set socket CPU affinity");
} }
if (rtpe_config.timer_accuracy < 0)
die("Invalid --timer-accuracy value (%d)", rtpe_config.timer_accuracy);
// everything OK, do post-processing // everything OK, do post-processing
} }


+ 4
- 1
daemon/timerthread.c View File

@ -3,6 +3,7 @@
#include "helpers.h" #include "helpers.h"
#include "log_funcs.h" #include "log_funcs.h"
#include "poller.h" #include "poller.h"
#include "main.h"
static int tt_obj_cmp(const void *a, const void *b) { static int tt_obj_cmp(const void *a, const void *b) {
@ -55,6 +56,8 @@ static void timerthread_run(void *p) {
struct thread_waker waker = { .lock = &tt->lock, .cond = &tt->cond }; struct thread_waker waker = { .lock = &tt->lock, .cond = &tt->cond };
thread_waker_add(&waker); thread_waker_add(&waker);
long long accuracy = rtpe_config.timer_accuracy;
mutex_lock(&tt->lock); mutex_lock(&tt->lock);
while (!rtpe_shutdown) { while (!rtpe_shutdown) {
@ -76,7 +79,7 @@ static void timerthread_run(void *p) {
// scheduled to run? if not, then we remember this object/reference and go to sleep // scheduled to run? if not, then we remember this object/reference and go to sleep
sleeptime = timeval_diff(&tt_obj->next_check, &rtpe_now); sleeptime = timeval_diff(&tt_obj->next_check, &rtpe_now);
if (sleeptime > 0) {
if (sleeptime > accuracy) {
tt->obj = tt_obj; tt->obj = tt_obj;
goto sleep; goto sleep;
} }


+ 8
- 0
docs/rtpengine.md View File

@ -1322,6 +1322,14 @@ call to inject-DTMF won't be sent to __\-\-dtmf-log-dest=__ or __\-\-listen-tcp-
thus maintaining the order of the packets. Might help when having issues with thus maintaining the order of the packets. Might help when having issues with
DTMF packets (RFC 2833). DTMF packets (RFC 2833).
- __\-\-timer-accuracy=__*INT*
Minimum number of microseconds that a timer thread is allowed to sleep. In
other words, if a timed event is scheduled sooner than this many
microseconds in the future, then the event will be executed immediately.
Set to zero for highest accuracy. Default is 500 microseconds (half a
millisecond).
- __\-\-io-uring__ - __\-\-io-uring__
Enable **experimental** support for `io_uring`. Requires Linux kernel 6.0 Enable **experimental** support for `io_uring`. Requires Linux kernel 6.0


+ 1
- 0
include/main.h View File

@ -99,6 +99,7 @@ enum endpoint_learning {
X(media_expire) \ X(media_expire) \
X(db_expire) \ X(db_expire) \
X(cache_expire) \ X(cache_expire) \
X(timer_accuracy) \
#define RTPE_CONFIG_UINT64_PARAMS \ #define RTPE_CONFIG_UINT64_PARAMS \
X(bw_limit) X(bw_limit)


Loading…
Cancel
Save