[asterisk-commits] dlee: branch dlee/taskprocessor-optimization r399652 - in /team/dlee/taskproc...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 23 23:41:10 CDT 2013


Author: dlee
Date: Mon Sep 23 23:41:08 2013
New Revision: 399652

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399652
Log:
Port switch from threadpool to taskprocessor from performance branch

Removed:
    team/dlee/taskprocessor-optimization/configs/stasis.conf.sample
    team/dlee/taskprocessor-optimization/main/stasis_config.c
Modified:
    team/dlee/taskprocessor-optimization/include/asterisk/stasis.h
    team/dlee/taskprocessor-optimization/main/stasis.c

Modified: team/dlee/taskprocessor-optimization/include/asterisk/stasis.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/taskprocessor-optimization/include/asterisk/stasis.h?view=diff&rev=399652&r1=399651&r2=399652
==============================================================================
--- team/dlee/taskprocessor-optimization/include/asterisk/stasis.h (original)
+++ team/dlee/taskprocessor-optimization/include/asterisk/stasis.h Mon Sep 23 23:41:08 2013
@@ -884,16 +884,6 @@
  */
 int stasis_wait_init(void);
 
-struct ast_threadpool_options;
-
-/*!
- * \internal
- * \brief Retrieves the Stasis threadpool configuration.
- * \param[out] threadpool_options Filled with Stasis threadpool options.
- */
-void stasis_config_get_threadpool_options(
-	struct ast_threadpool_options *threadpool_options);
-
 /*! @} */
 
 /*!

Modified: team/dlee/taskprocessor-optimization/main/stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/taskprocessor-optimization/main/stasis.c?view=diff&rev=399652&r1=399651&r2=399652
==============================================================================
--- team/dlee/taskprocessor-optimization/main/stasis.c (original)
+++ team/dlee/taskprocessor-optimization/main/stasis.c Mon Sep 23 23:41:08 2013
@@ -34,7 +34,6 @@
 #include "asterisk/astobj2.h"
 #include "asterisk/stasis_internal.h"
 #include "asterisk/stasis.h"
-#include "asterisk/threadpool.h"
 #include "asterisk/taskprocessor.h"
 #include "asterisk/utils.h"
 #include "asterisk/uuid.h"
@@ -134,9 +133,6 @@
 /*! The number of buckets to use for topic pools */
 #define TOPIC_POOL_BUCKETS 57
 
-/*! Threadpool for dispatching notifications to subscribers */
-static struct ast_threadpool *pool;
-
 STASIS_MESSAGE_TYPE_DEFN(stasis_subscription_change_type);
 
 /*! \internal */
@@ -286,7 +282,15 @@
 	ast_uuid_generate_str(sub->uniqueid, sizeof(sub->uniqueid));
 
 	if (needs_mailbox) {
-		sub->mailbox = ast_threadpool_serializer(sub->uniqueid, pool);
+		/* With a small number of subscribers, a thread-per-sub is
+		 * acceptable. If our usage changes so that we have larger
+		 * numbers of subscribers, we'll probably want to consider
+		 * a threadpool. We had that originally, but with so few
+		 * subscribers it was actually a performance loss instead of
+		 * a gain.
+		 */
+		sub->mailbox = ast_taskprocessor_get(sub->uniqueid,
+			TPS_REF_DEFAULT);
 		if (!sub->mailbox) {
 			return NULL;
 		}
@@ -731,13 +735,6 @@
 	ast_log(LOG_ERROR, "Use of %s() before init/after destruction\n", name);
 }
 
-/*! \brief Shutdown function */
-static void stasis_exit(void)
-{
-	ast_threadpool_shutdown(pool);
-	pool = NULL;
-}
-
 /*! \brief Cleanup function for graceful shutdowns */
 static void stasis_cleanup(void)
 {
@@ -748,36 +745,14 @@
 {
 	int cache_init;
 
-	struct ast_threadpool_options opts;
-
 	/* Be sure the types are cleaned up after the message bus */
 	ast_register_cleanup(stasis_cleanup);
-	ast_register_atexit(stasis_exit);
-
-	if (stasis_config_init() != 0) {
-		ast_log(LOG_ERROR, "Stasis configuration failed\n");
-		return -1;
-	}
 
 	if (stasis_wait_init() != 0) {
 		ast_log(LOG_ERROR, "Stasis initialization failed\n");
 		return -1;
 	}
 
-	if (pool) {
-		ast_log(LOG_ERROR, "Stasis double-initialized\n");
-		return -1;
-	}
-
-	stasis_config_get_threadpool_options(&opts);
-	ast_debug(3, "Creating Stasis threadpool: initial_size = %d, max_size = %d, idle_timeout_secs = %d\n",
-		opts.initial_size, opts.max_size, opts.idle_timeout);
-	pool = ast_threadpool_create("stasis-core", NULL, &opts);
-	if (!pool) {
-		ast_log(LOG_ERROR, "Stasis threadpool allocation failed\n");
-		return -1;
-	}
-
 	cache_init = stasis_cache_init();
 	if (cache_init != 0) {
 		return -1;




More information about the asterisk-commits mailing list