mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
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/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@400138 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -100,6 +100,9 @@ int stasis_message_router_is_done(struct stasis_message_router *router);
|
||||
* updates for types not handled by routes added with
|
||||
* stasis_message_router_add_cache_update().
|
||||
*
|
||||
* Adding multiple routes for the same message type results in undefined
|
||||
* behavior.
|
||||
*
|
||||
* \param router Router to add the route to.
|
||||
* \param message_type Type of message to route.
|
||||
* \param callback Callback to forard messages of \a message_type to.
|
||||
@@ -121,6 +124,9 @@ int stasis_message_router_add(struct stasis_message_router *router,
|
||||
* These are distinct from regular routes, so one could have both a regular
|
||||
* route and a cache route for the same \a message_type.
|
||||
*
|
||||
* Adding multiple routes for the same message type results in undefined
|
||||
* behavior.
|
||||
*
|
||||
* \param router Router to add the route to.
|
||||
* \param message_type Subtype of cache update to route.
|
||||
* \param callback Callback to forard messages of \a message_type to.
|
||||
@@ -138,6 +144,11 @@ int stasis_message_router_add_cache_update(struct stasis_message_router *router,
|
||||
/*!
|
||||
* \brief Remove a route from a message router.
|
||||
*
|
||||
* If a route is removed from another thread, there is no notification that
|
||||
* all messages using this route have been processed. This typically means that
|
||||
* the associated \c data pointer for this route must be kept until the
|
||||
* route itself is disposed of.
|
||||
*
|
||||
* \param router Router to remove the route from.
|
||||
* \param message_type Type of message to route.
|
||||
*
|
||||
@@ -149,6 +160,11 @@ void stasis_message_router_remove(struct stasis_message_router *router,
|
||||
/*!
|
||||
* \brief Remove a cache route from a message router.
|
||||
*
|
||||
* If a route is removed from another thread, there is no notification that
|
||||
* all messages using this route have been processed. This typically means that
|
||||
* the associated \c data pointer for this route must be kept until the
|
||||
* route itself is disposed of.
|
||||
*
|
||||
* \param router Router to remove the route from.
|
||||
* \param message_type Type of message to route.
|
||||
*
|
||||
|
Reference in New Issue
Block a user