[asterisk-commits] dlee: branch dlee/performance r399650 - in /team/dlee/performance: configs/ i...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 23 19:50:15 CDT 2013
Author: dlee
Date: Mon Sep 23 19:50:13 2013
New Revision: 399650
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399650
Log:
I'm afraid the switch to taskprocessor will be more involved than I thought. Deferring.
Added:
team/dlee/performance/configs/stasis.conf.sample
- copied unchanged from r399636, branches/12/configs/stasis.conf.sample
team/dlee/performance/main/stasis_config.c
- copied unchanged from r399636, branches/12/main/stasis_config.c
Modified:
team/dlee/performance/include/asterisk/stasis.h
team/dlee/performance/main/stasis.c
Modified: team/dlee/performance/include/asterisk/stasis.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/performance/include/asterisk/stasis.h?view=diff&rev=399650&r1=399649&r2=399650
==============================================================================
--- team/dlee/performance/include/asterisk/stasis.h (original)
+++ team/dlee/performance/include/asterisk/stasis.h Mon Sep 23 19:50:13 2013
@@ -884,6 +884,16 @@
*/
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/performance/main/stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/performance/main/stasis.c?view=diff&rev=399650&r1=399649&r2=399650
==============================================================================
--- team/dlee/performance/main/stasis.c (original)
+++ team/dlee/performance/main/stasis.c Mon Sep 23 19:50:13 2013
@@ -34,6 +34,7 @@
#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"
@@ -133,6 +134,9 @@
/*! 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 */
@@ -282,15 +286,7 @@
ast_uuid_generate_str(sub->uniqueid, sizeof(sub->uniqueid));
if (needs_mailbox) {
- /* 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);
+ sub->mailbox = ast_threadpool_serializer(sub->uniqueid, pool);
if (!sub->mailbox) {
return NULL;
}
@@ -735,6 +731,13 @@
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)
{
@@ -745,14 +748,36 @@
{
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