]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
some priority queuing tweaks for performance
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 1 Oct 2012 16:47:26 +0000 (11:47 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 1 Oct 2012 16:47:26 +0000 (11:47 -0500)
src/mod/applications/mod_conference/mod_conference.c
src/mod/endpoints/mod_sofia/sofia.c
src/switch_core.c
src/switch_core_io.c
src/switch_core_sqldb.c
src/switch_event.c
src/switch_time.c

index 0bdf28822b216353e94dc9354fb689cd72a42160..d84f3b6f7d077e079d8f3ddee32c8a2ab90db9ee 100644 (file)
@@ -7748,6 +7748,7 @@ static void launch_conference_thread(conference_obj_t *conference)
        switch_set_flag_locked(conference, CFLAG_RUNNING);
        switch_threadattr_create(&thd_attr, conference->pool);
        switch_threadattr_detach_set(thd_attr, 1);
+       switch_threadattr_priority_increase(thd_attr);
        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
        switch_mutex_lock(globals.hash_mutex);
        switch_mutex_unlock(globals.hash_mutex);
index f7f7bddead52b74e613fcfb4305ef8d0450a889a..2793cd73540db9e788ff95c4212f8cc43d736379 100644 (file)
@@ -1599,7 +1599,7 @@ void *SWITCH_THREAD_FUNC sofia_msg_thread_run(switch_thread_t *thread, void *obj
        msg_queue_threads++;
        switch_mutex_unlock(mod_sofia_globals.mutex); 
 
-       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MSG Thread %d Started\n", my_id);
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "MSG Thread %d Started\n", my_id);
 
 
        for(;;) {
@@ -1612,12 +1612,13 @@ void *SWITCH_THREAD_FUNC sofia_msg_thread_run(switch_thread_t *thread, void *obj
                if (pop) {
                        sofia_dispatch_event_t *de = (sofia_dispatch_event_t *) pop;
                        sofia_process_dispatch_event(&de);
+                       switch_os_yield();
                } else {
                        break;
                }
        }
 
-       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "MSG Thread Ended\n");
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "MSG Thread Ended\n");
 
        switch_mutex_lock(mod_sofia_globals.mutex); 
        msg_queue_threads--;
@@ -1934,6 +1935,8 @@ void sofia_event_callback(nua_event_t event,
 
        if (profile->pres_type) {
                switch_cond_next();
+       } else {
+               switch_os_yield();
        }
 
 
index 6cce3560613f23fd9a0e470c136aa8b11b81da3d..488b7552326541767a8789a9e98823bd76c501f7 100644 (file)
@@ -736,7 +736,7 @@ SWITCH_DECLARE(int32_t) set_realtime_priority(void)
        char data[] = "-1\n";
        struct sched_param sched = { 0 };
        sched.sched_priority = 1;
-       if (sched_setscheduler(0, SCHED_FIFO, &sched)) {
+       if (sched_setscheduler(0, SCHED_RR, &sched)) {
                sched.sched_priority = 0;
                if (sched_setscheduler(0, SCHED_OTHER, &sched)) {
                        return -1;
index 8978306adb0b722c0caeb64e1dca0226baea8f54..7b9580c0bbd79f1cd4c774576962e78b3982436a 100644 (file)
@@ -112,6 +112,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
        switch_assert(session != NULL);
 
 
+       switch_os_yield();
+
        if (switch_mutex_trylock(session->codec_read_mutex) == SWITCH_STATUS_SUCCESS) {
                switch_mutex_unlock(session->codec_read_mutex);
        } else {
index d77b432c9022ca27afb8eb2c0aa94db4fdaf9e25..2e3e71f204927bc1fc48ea7e433005ea976a3bed 100644 (file)
@@ -2539,7 +2539,7 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
 
                switch_threadattr_create(&thd_attr, sql_manager.memory_pool);
                switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-
+               switch_threadattr_priority_increase(thd_attr);
                switch_core_sqldb_start_thread();
                switch_thread_create(&sql_manager.db_thread, thd_attr, switch_core_sql_db_thread, NULL, sql_manager.memory_pool);
 
@@ -2641,6 +2641,7 @@ SWITCH_DECLARE(void) switch_core_sqldb_start_thread(void)
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Starting SQL thread.\n");
                        switch_threadattr_create(&thd_attr, sql_manager.memory_pool);
                        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+                       switch_threadattr_priority_increase(thd_attr);
                        switch_thread_create(&sql_manager.thread, thd_attr, switch_core_sql_thread, NULL, sql_manager.memory_pool);
                } else {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL thread is already running\n");
index 3a02e3a449f5740fe829b6a33b4e5b934e31a77b..175dadf5cfee2471c4cc0e5f3b0b4152391f6d5e 100644 (file)
@@ -276,6 +276,7 @@ static void *SWITCH_THREAD_FUNC switch_event_dispatch_thread(switch_thread_t *th
 
                event = (switch_event_t *) pop;
                switch_event_deliver(&event);
+               switch_os_yield();
        }
 
 
index fb9fea1de008740b6f773251bbdc0bbeb2df568f..54bf9338ef730b7657470bb26ecee4ca428a74e7 100644 (file)
@@ -150,6 +150,7 @@ SWITCH_DECLARE(void) switch_os_yield(void)
 #if defined(WIN32)
        SwitchToThread();
 #else
+       usleep(1);
        sched_yield();
 #endif
 }
@@ -672,8 +673,10 @@ static switch_status_t timer_next(switch_timer_t *timer)
        while (globals.RUNNING == 1 && private_info->ready && TIMER_MATRIX[timer->interval].tick < private_info->reference) {
                check_roll();
 
+               switch_os_yield();
+
+
                if (runtime.tipping_point && globals.timer_count >= runtime.tipping_point) {
-                       switch_os_yield();
                        globals.use_cond_yield = 0;
                } else {
                        if (globals.use_cond_yield == 1) {