diff options
author | David M. Lee <dlee@digium.com> | 2013-09-30 18:55:27 +0000 |
---|---|---|
committer | David M. Lee <dlee@digium.com> | 2013-09-30 18:55:27 +0000 |
commit | 2de42c2a257947d0a376d861dbd1ca76923e7930 (patch) | |
tree | a01a063af4857ba99e8fa3f7892dd41c6edf826a /apps | |
parent | db7c8691a06bd896070e1a9c4f90309104509190 (diff) |
Multiple revisions 399887,400138,400178,400180-400181
........
r399887 | dlee | 2013-09-26 10:41:47 -0500 (Thu, 26 Sep 2013) | 1 line
Minor performance bump by not allocate manager variable struct if we don't need it
........
r400138 | dlee | 2013-09-30 10:24:00 -0500 (Mon, 30 Sep 2013) | 23 lines
Stasis performance improvements
This patch addresses several performance problems that were found in
the initial performance testing of Asterisk 12.
The Stasis dispatch object was allocated as an AO2 object, even though
it has a very confined lifecycle. This was replaced with a straight
ast_malloc().
The Stasis message router was spending an inordinate amount of time
searching hash tables. In this case, most of our routers had 6 or
fewer routes in them to begin with. This was replaced with an array
that's searched linearly for the route.
We more heavily rely on AO2 objects in Asterisk 12, and the memset()
in ao2_ref() actually became noticeable on the profile. This was
#ifdef'ed to only run when AO2_DEBUG was enabled.
After being misled by an erroneous comment in taskprocessor.c during
profiling, the wrong comment was removed.
Review: https://reviewboard.asterisk.org/r/2873/
........
r400178 | dlee | 2013-09-30 13:26:27 -0500 (Mon, 30 Sep 2013) | 24 lines
Taskprocessor optimization; switch Stasis to use taskprocessors
This patch optimizes taskprocessor to use a semaphore for signaling,
which the OS can do a better job at managing contention and waiting
that we can with a mutex and condition.
The taskprocessor execution was also slightly optimized to reduce the
number of locks taken.
The only observable difference in the taskprocessor implementation is
that when the final reference to the taskprocessor goes away, it will
execute all tasks to completion instead of discarding the unexecuted
tasks.
For systems where unnamed semaphores are not supported, a really
simple semaphore implementation is provided. (Which gives identical
performance as the original taskprocessor implementation).
The way we ended up implementing Stasis caused the threadpool to be a
burden instead of a boost to performance. This was switched to just
use taskprocessors directly for subscriptions.
Review: https://reviewboard.asterisk.org/r/2881/
........
r400180 | dlee | 2013-09-30 13:39:34 -0500 (Mon, 30 Sep 2013) | 28 lines
Optimize how Stasis forwards are dispatched
This patch optimizes how forwards are dispatched in Stasis.
Originally, forwards were dispatched as subscriptions that are invoked
on the publishing thread. This did not account for the vast number of
forwards we would end up having in the system, and the amount of work it
would take to walk though the forward subscriptions.
This patch modifies Stasis so that rather than walking the tree of
forwards on every dispatch, when forwards and subscriptions are changed,
the subscriber list for every topic in the tree is changed.
This has a couple of benefits. First, this reduces the workload of
dispatching messages. It also reduces contention when dispatching to
different topics that happen to forward to the same aggregation topic
(as happens with all of the channel, bridge and endpoint topics).
Since forwards are no longer subscriptions, the bulk of this patch is
simply changing stasis_subscription objects to stasis_forward objects
(which, admittedly, I should have done in the first place.)
Since this required me to yet again put in a growing array, I finally
abstracted that out into a set of ast_vector macros in
asterisk/vector.h.
Review: https://reviewboard.asterisk.org/r/2883/
........
r400181 | dlee | 2013-09-30 13:48:57 -0500 (Mon, 30 Sep 2013) | 28 lines
Remove dispatch object allocation from Stasis publishing
While looking for areas for performance improvement, I realized that an
unused feature in Stasis was negatively impacting performance.
When a message is sent to a subscriber, a dispatch object is allocated
for the dispatch, containing the topic the message was published to, the
subscriber the message is being sent to, and the message itself.
The topic is actually unused by any subscriber in Asterisk today. And
the subscriber is associated with the taskprocessor the message is being
dispatched to.
First, this patch removes the unused topic parameter from Stasis
subscription callbacks.
Second, this patch introduces the concept of taskprocessor local data,
data that may be set on a taskprocessor and provided along with the data
pointer when a task is pushed using the ast_taskprocessor_push_local()
call. This allows the task to have both data specific to that
taskprocessor, in addition to data specific to that invocation.
With those two changes, the dispatch object can be removed completely,
and the message is simply refcounted and sent directly to the
taskprocessor.
Review: https://reviewboard.asterisk.org/r/2884/
........
Merged revisions 399887,400138,400178,400180-400181 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400186 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_meetme.c | 4 | ||||
-rw-r--r-- | apps/app_queue.c | 30 | ||||
-rw-r--r-- | apps/app_voicemail.c | 4 | ||||
-rw-r--r-- | apps/confbridge/confbridge_manager.c | 9 |
4 files changed, 19 insertions, 28 deletions
diff --git a/apps/app_meetme.c b/apps/app_meetme.c index e1fedb47b..cd6a4f72c 100644 --- a/apps/app_meetme.c +++ b/apps/app_meetme.c @@ -1139,7 +1139,7 @@ STASIS_MESSAGE_TYPE_DEFN_LOCAL(meetme_talking_type); STASIS_MESSAGE_TYPE_DEFN_LOCAL(meetme_talk_request_type); static void meetme_stasis_cb(void *data, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *message); + struct stasis_message *message); static void meetme_stasis_cleanup(void) { @@ -1226,7 +1226,7 @@ static int meetme_stasis_init(void) } static void meetme_stasis_cb(void *data, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *message) + struct stasis_message *message) { struct ast_channel_blob *channel_blob = stasis_message_data(message); struct stasis_message_type *message_type; diff --git a/apps/app_queue.c b/apps/app_queue.c index e0889a5c3..e72997fa8 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -1832,7 +1832,7 @@ STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_agent_dump_type); STASIS_MESSAGE_TYPE_DEFN_LOCAL(queue_agent_ringnoanswer_type); static void queue_channel_manager_event(void *data, - struct stasis_subscription *sub, struct stasis_topic *topic, + struct stasis_subscription *sub, struct stasis_message *message) { const char *type = data; @@ -1858,7 +1858,7 @@ static void queue_channel_manager_event(void *data, } static void queue_multi_channel_manager_event(void *data, - struct stasis_subscription *sub, struct stasis_topic *topic, + struct stasis_subscription *sub, struct stasis_message *message) { const char *type = data; @@ -1902,7 +1902,7 @@ static void queue_multi_channel_manager_event(void *data, } static void queue_member_manager_event(void *data, - struct stasis_subscription *sub, struct stasis_topic *topic, + struct stasis_subscription *sub, struct stasis_message *message) { const char *type = data; @@ -2140,7 +2140,7 @@ static int is_member_available(struct call_queue *q, struct member *mem) } /*! \brief set a member's status based on device state of that member's interface*/ -static void device_state_cb(void *unused, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg) +static void device_state_cb(void *unused, struct stasis_subscription *sub, struct stasis_message *msg) { struct ao2_iterator miter, qiter; struct ast_device_state_message *dev_state; @@ -5185,7 +5185,7 @@ static void send_agent_complete(const char *queuename, struct ast_channel_snapsh } static void queue_agent_cb(void *userdata, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *msg) + struct stasis_message *msg) { struct ast_channel_blob *agent_blob; @@ -5401,7 +5401,7 @@ static void log_attended_transfer(struct queue_stasis_data *queue_data, struct a * \param msg The stasis message for the bridge enter event */ static void handle_bridge_enter(void *userdata, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *msg) + struct stasis_message *msg) { struct queue_stasis_data *queue_data = userdata; struct ast_bridge_blob *enter_blob = stasis_message_data(msg); @@ -5434,7 +5434,7 @@ static void handle_bridge_enter(void *userdata, struct stasis_subscription *sub, * \param msg The stasis message for the blind transfer event */ static void handle_blind_transfer(void *userdata, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *msg) + struct stasis_message *msg) { struct queue_stasis_data *queue_data = userdata; struct ast_bridge_blob *blind_blob = stasis_message_data(msg); @@ -5503,7 +5503,7 @@ static void handle_blind_transfer(void *userdata, struct stasis_subscription *su * \param msg The stasis message for the attended transfer event. */ static void handle_attended_transfer(void *userdata, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *msg) + struct stasis_message *msg) { struct queue_stasis_data *queue_data = userdata; struct ast_attended_transfer_message *atxfer_msg = stasis_message_data(msg); @@ -5558,7 +5558,7 @@ static void handle_attended_transfer(void *userdata, struct stasis_subscription * subroutines for further processing. */ static void queue_bridge_cb(void *userdata, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *msg) + struct stasis_message *msg) { if (stasis_subscription_final_message(sub, msg)) { ao2_cleanup(userdata); @@ -5578,7 +5578,7 @@ static void queue_bridge_cb(void *userdata, struct stasis_subscription *sub, * \param msg The stasis message for the local optimization begin event */ static void handle_local_optimization_begin(void *userdata, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *msg) + struct stasis_message *msg) { struct queue_stasis_data *queue_data = userdata; struct ast_multi_channel_blob *optimization_blob = stasis_message_data(msg); @@ -5630,7 +5630,7 @@ static void handle_local_optimization_begin(void *userdata, struct stasis_subscr * \param msg The stasis message for the local optimization end event */ static void handle_local_optimization_end(void *userdata, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *msg) + struct stasis_message *msg) { struct queue_stasis_data *queue_data = userdata; struct ast_multi_channel_blob *optimization_blob = stasis_message_data(msg); @@ -5695,7 +5695,7 @@ static void handle_local_optimization_end(void *userdata, struct stasis_subscrip * \param msg The stasis message for the hangup event. */ static void handle_hangup(void *userdata, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *msg) + struct stasis_message *msg) { struct queue_stasis_data *queue_data = userdata; struct ast_channel_blob *channel_blob = stasis_message_data(msg); @@ -5756,7 +5756,7 @@ static void handle_hangup(void *userdata, struct stasis_subscription *sub, * subroutines for further processing. */ static void queue_channel_cb(void *userdata, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *msg) + struct stasis_message *msg) { if (stasis_subscription_final_message(sub, msg)) { ao2_cleanup(userdata); @@ -10336,7 +10336,7 @@ static const struct ast_data_entry queue_data_providers[] = { }; static struct stasis_message_router *agent_router; -static struct stasis_subscription *topic_forwarder; +static struct stasis_forward *topic_forwarder; static int unload_module(void) { @@ -10364,7 +10364,7 @@ static int unload_module(void) stasis_message_router_remove(message_router, queue_agent_ringnoanswer_type()); } stasis_message_router_unsubscribe_and_join(agent_router); - topic_forwarder = stasis_unsubscribe(topic_forwarder); + topic_forwarder = stasis_forward_cancel(topic_forwarder); STASIS_MESSAGE_TYPE_CLEANUP(queue_caller_join_type); STASIS_MESSAGE_TYPE_CLEANUP(queue_caller_leave_type); diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index c32b78184..1ab164511 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -12606,7 +12606,7 @@ static void mwi_sub_event_cb(struct stasis_subscription_change *change) } } -static void mwi_event_cb(void *userdata, struct stasis_subscription *sub, struct stasis_topic *topic, struct stasis_message *msg) +static void mwi_event_cb(void *userdata, struct stasis_subscription *sub, struct stasis_message *msg) { struct stasis_subscription_change *change; /* Only looking for subscription change notices here */ @@ -12629,7 +12629,7 @@ static void mwi_event_cb(void *userdata, struct stasis_subscription *sub, struct static int dump_cache(void *obj, void *arg, int flags) { struct stasis_message *msg = obj; - mwi_event_cb(NULL, NULL, NULL, msg); + mwi_event_cb(NULL, NULL, msg); return 0; } diff --git a/apps/confbridge/confbridge_manager.c b/apps/confbridge/confbridge_manager.c index 57bf64b7c..1b8eab24b 100644 --- a/apps/confbridge/confbridge_manager.c +++ b/apps/confbridge/confbridge_manager.c @@ -224,63 +224,54 @@ static void confbridge_publish_manager_event( } static void confbridge_start_cb(void *data, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *message) { confbridge_publish_manager_event(message, "ConfbridgeStart", NULL); } static void confbridge_end_cb(void *data, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *message) { confbridge_publish_manager_event(message, "ConfbridgeEnd", NULL); } static void confbridge_leave_cb(void *data, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *message) { confbridge_publish_manager_event(message, "ConfbridgeLeave", NULL); } static void confbridge_join_cb(void *data, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *message) { confbridge_publish_manager_event(message, "ConfbridgeJoin", NULL); } static void confbridge_start_record_cb(void *data, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *message) { confbridge_publish_manager_event(message, "ConfbridgeRecord", NULL); } static void confbridge_stop_record_cb(void *data, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *message) { confbridge_publish_manager_event(message, "ConfbridgeStopRecord", NULL); } static void confbridge_mute_cb(void *data, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *message) { confbridge_publish_manager_event(message, "ConfbridgeMute", NULL); } static void confbridge_unmute_cb(void *data, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *message) { confbridge_publish_manager_event(message, "ConfbridgeUnmute", NULL); } static void confbridge_talking_cb(void *data, struct stasis_subscription *sub, - struct stasis_topic *topic, struct stasis_message *message) { RAII_VAR(struct ast_str *, extra_text, NULL, ast_free); |