From: Anthony Minessale Date: Tue, 22 Mar 2011 18:27:37 +0000 (-0500) Subject: improve some defaults to tune performance if you use -heavy_timer, try not using it X-Git-Tag: v1.2-rc1~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d7831348bb01de33eedee972828c0a4f5d76360;p=thirdparty%2Ffreeswitch.git improve some defaults to tune performance if you use -heavy_timer, try not using it --- diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 37c672334f..e54de72027 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -1940,6 +1940,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_management_exec(char *relative_oid, \return 0 on success */ SWITCH_DECLARE(int32_t) set_high_priority(void); +SWITCH_DECLARE(int32_t) set_normal_priority(void); /*! \brief Change user and/or group of the running process diff --git a/src/switch.c b/src/switch.c index 33e7fb6336..ad9cdf8e6e 100644 --- a/src/switch.c +++ b/src/switch.c @@ -824,6 +824,8 @@ int main(int argc, char *argv[]) if (high_prio) { set_high_priority(); + } else { + set_normal_priority(); } switch_core_setrlimits(); diff --git a/src/switch_apr.c b/src/switch_apr.c index 3ca3c63f77..495e0605a8 100644 --- a/src/switch_apr.c +++ b/src/switch_apr.c @@ -630,7 +630,7 @@ SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_increase(switch_threa struct apr_threadattr_t *myattr = attr; pthread_attr_getschedparam(&myattr->attr, ¶m); - param.sched_priority = 50; + param.sched_priority = 1; stat = pthread_attr_setschedparam(&myattr->attr, ¶m); if (stat == 0) { diff --git a/src/switch_core.c b/src/switch_core.c index 03b3d1c8d0..87bea30777 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -606,16 +606,8 @@ SWITCH_DECLARE(void) switch_core_set_globals(void) switch_assert(SWITCH_GLOBAL_dirs.temp_dir); } -SWITCH_DECLARE(int32_t) set_high_priority(void) +static int32_t set_priority(void) { -#ifdef WIN32 - SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); -#else - -#ifdef USE_SETRLIMIT - struct rlimit lim = { RLIM_INFINITY, RLIM_INFINITY }; -#endif - #ifdef USE_SCHED_SETSCHEDULER /* * Try to use a round-robin scheduler @@ -637,13 +629,40 @@ SWITCH_DECLARE(int32_t) set_high_priority(void) */ if (setpriority(PRIO_PROCESS, getpid(), -10) < 0) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not set nice level\n"); + return -1; } #else if (nice(-10) != -10) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not set nice level\n"); + return -1; } #endif + return 0; +} + + +SWITCH_DECLARE(int32_t) set_normal_priority(void) +{ + return set_priority(); +} + +SWITCH_DECLARE(int32_t) set_high_priority(void) +{ + int pri; + +#ifdef WIN32 + SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); +#else + +#ifdef USE_SETRLIMIT + struct rlimit lim = { RLIM_INFINITY, RLIM_INFINITY }; +#endif + + if ((pri = set_priority())) { + return pri; + } + #ifdef USE_SETRLIMIT /* * The amount of memory which can be mlocked is limited for non-root users.