]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
speed improvements: change scheduler to SCHED_FIFO, Disable realtime throttling,...
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 25 Sep 2012 21:12:23 +0000 (16:12 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 25 Sep 2012 21:12:58 +0000 (16:12 -0500)
src/include/switch_core.h
src/switch_core.c
src/switch_core_sqldb.c

index 4f26719d32580bb0e8572388c4fe56e4181e8162..507f18a166f614b01cc4fca2a17261872353c4bb 100644 (file)
@@ -2303,6 +2303,9 @@ SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t
 SWITCH_DECLARE(switch_status_t) _switch_core_recovery_db_handle(switch_cache_db_handle_t ** dbh, const char *file, const char *func, int line);
 #define switch_core_recovery_db_handle(_a) _switch_core_recovery_db_handle(_a, __FILE__, __SWITCH_FUNC__, __LINE__)
 
+SWITCH_DECLARE(switch_status_t) _switch_core_persist_db_handle(switch_cache_db_handle_t ** dbh, const char *file, const char *func, int line);
+#define switch_core_persist_db_handle(_a) _switch_core_persist_db_handle(_a, __FILE__, __SWITCH_FUNC__, __LINE__)
+
 SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_handle_t *db,
                                                                                                                        const char *test_sql, const char *drop_sql, const char *reactive_sql);
 SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_db_handle_t *dbh, const char *sql, uint32_t retries);
index 86804f09b7360a8f4a5524b9cc00191450dd0fc2..257c37a6469801420af1954b9c0f279d70b0a512 100644 (file)
@@ -731,16 +731,36 @@ SWITCH_DECLARE(int32_t) set_realtime_priority(void)
         * Try to use a round-robin scheduler
         * with a fallback if that does not work
         */
+       int fd;
+       const char *rt = "/proc/sys/kernel/sched_rt_runtime_us";
+       char data[] = "-1\n";
        struct sched_param sched = { 0 };
        sched.sched_priority = 1;
-       if (sched_setscheduler(0, SCHED_RR, &sched)) {
+       if (sched_setscheduler(0, SCHED_FIFO, &sched)) {
                sched.sched_priority = 0;
                if (sched_setscheduler(0, SCHED_OTHER, &sched)) {
                        return -1;
                }
        }
+
+       if ((fd = open(rt, O_WRONLY)) > 0) {
+               int r;
+               
+               if (!(r = write(fd, data, sizeof(data)))) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error Disablling RT limits [%s][%d]\n", rt, r);
+               } else {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Disabling RT throttling.\n");
+               }
+               close(fd);
+       } else {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error opening %s\n", rt);
+       }
+
+       
 #endif
 
+       
+
 #ifdef HAVE_SETPRIORITY
        /*
         * setpriority() works on FreeBSD (6.2), nice() doesn't
index 200ed3507e1bbce82e0d826a08bd051a24a0c08a..b0f52b6150c0d5c764a20c8e2ff50fec5acc7fbc 100644 (file)
@@ -176,7 +176,7 @@ static switch_cache_db_handle_t *get_handle(const char *db_str, const char *user
 }
 
 
-#define SWITCH_CORE_DB "core"
+#define SWITCH_CORE_DB "file:scoreboard?mode=memory&cache=shared"
 /*!
   \brief Open the default system database
 */
@@ -218,6 +218,49 @@ SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t
        return r;
 }
 
+#define SWITCH_CORE_PERSIST_DB "core"
+/*!
+  \brief Open the default system database
+*/
+SWITCH_DECLARE(switch_status_t) _switch_core_persist_db_handle(switch_cache_db_handle_t **dbh, const char *file, const char *func, int line)
+{
+       switch_cache_db_connection_options_t options = { {0} };
+       switch_status_t r;
+       
+       if (!sql_manager.manage) {
+               return SWITCH_STATUS_FALSE;
+       }
+
+       if (zstr(runtime.odbc_dsn)) {
+               if (switch_test_flag((&runtime), SCF_CORE_ODBC_REQ)) {
+                       return SWITCH_STATUS_FALSE;
+               }
+
+               if (runtime.dbname) {
+                       options.core_db_options.db_path = runtime.dbname;
+               } else {
+                       options.core_db_options.db_path = SWITCH_CORE_PERSIST_DB;
+               }
+               r = _switch_cache_db_get_db_handle(dbh, SCDB_TYPE_CORE_DB, &options, file, func, line);
+               
+       } else {
+               options.odbc_options.dsn = runtime.odbc_dsn;
+               options.odbc_options.user = runtime.odbc_user;
+               options.odbc_options.pass = runtime.odbc_pass;
+
+               r = _switch_cache_db_get_db_handle(dbh, SCDB_TYPE_ODBC, &options, file, func, line);
+       }
+
+       /* I *think* we can do without this now, if not let me know 
+          if (r == SWITCH_STATUS_SUCCESS && !(*dbh)->io_mutex) {
+          (*dbh)->io_mutex = sql_manager.io_mutex;
+          }
+       */
+
+       return r;
+}
+
+
 #define SWITCH_CORE_RECOVERY_DB "core_recovery"
 SWITCH_DECLARE(switch_status_t) _switch_core_recovery_db_handle(switch_cache_db_handle_t **dbh, const char *file, const char *func, int line)
 {