improve some defaults to tune performance if you use -heavy_timer, try not using it

This commit is contained in:
Anthony Minessale 2011-03-22 13:27:37 -05:00
parent 3b56c119a7
commit 5d7831348b
4 changed files with 32 additions and 10 deletions

View File

@ -1940,6 +1940,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_management_exec(char *relative_oid,
\return 0 on success \return 0 on success
*/ */
SWITCH_DECLARE(int32_t) set_high_priority(void); 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 \brief Change user and/or group of the running process

View File

@ -824,6 +824,8 @@ int main(int argc, char *argv[])
if (high_prio) { if (high_prio) {
set_high_priority(); set_high_priority();
} else {
set_normal_priority();
} }
switch_core_setrlimits(); switch_core_setrlimits();

View File

@ -630,7 +630,7 @@ SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_increase(switch_threa
struct apr_threadattr_t *myattr = attr; struct apr_threadattr_t *myattr = attr;
pthread_attr_getschedparam(&myattr->attr, &param); pthread_attr_getschedparam(&myattr->attr, &param);
param.sched_priority = 50; param.sched_priority = 1;
stat = pthread_attr_setschedparam(&myattr->attr, &param); stat = pthread_attr_setschedparam(&myattr->attr, &param);
if (stat == 0) { if (stat == 0) {

View File

@ -606,16 +606,8 @@ SWITCH_DECLARE(void) switch_core_set_globals(void)
switch_assert(SWITCH_GLOBAL_dirs.temp_dir); 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 #ifdef USE_SCHED_SETSCHEDULER
/* /*
* Try to use a round-robin scheduler * 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) { if (setpriority(PRIO_PROCESS, getpid(), -10) < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not set nice level\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not set nice level\n");
return -1;
} }
#else #else
if (nice(-10) != -10) { if (nice(-10) != -10) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not set nice level\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not set nice level\n");
return -1;
} }
#endif #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 #ifdef USE_SETRLIMIT
/* /*
* The amount of memory which can be mlocked is limited for non-root users. * The amount of memory which can be mlocked is limited for non-root users.