[asterisk-dev] [Code Review] 4193: Stasis: allow for subscriptions to dictate message delivery on a threadpool for certain situations
reviewboard at asterisk.org
Mon Dec 1 09:53:19 CST 2014
This is an automatically generated e-mail. To reply, visit:
(Updated Dec. 1, 2014, 3:53 p.m.)
This change has been marked as submitted.
Review request for Asterisk Developers.
Committed in revision 428681
Note: don't be fooled by the size of this review. Most of the changes are small and are in stasis.c/stasis_message_router.c.
Rob (and CDR on the asterisk-users list, although he never followed up when we asked for more information) discovered that we were creating two additional threads per SIP peer in chan_sip. This actually would occur for a large variety of 'endpoints' in Asterisk, regardless of the channel driver. The two threads were stasis subscriptions, specifically for MWI and for endpoints detecting the destruction of related channels.
Stasis subscriptions currently get a dedicated thread. In contrast, prior to r400178 (see review https://reviewboard.asterisk.org/r/2881/), the subscriptions shared a thread pool. It was discovered that for a low subscription count with high message throughput, the threadpool was not as performant as simply having a dedicated thread per subscriber.
Since then, our subscription pattern has changed slightly. While we still have plenty of subscriptions that would follow the model just described (AMI, CDRs, CEL, etc.) - there are plenty that also fall into the following two categories:
* Large number of subscriptions, specifically those tied to endpoints/peers.
* Low number of messages. Some subscriptions exist specifically to coordinate a single message - the subscription is created, a message is published, the delivery is synchronized, and the subscription is destroyed.
In both of the latter two cases, creating a dedicated thread is wasteful (and in the case of a large number of peers/endpoints, harmful).
This patch adds the ability of a subscriber to Stasis to choose whether or not their messages are dispatched on a dedicated thread or on a threadpool. The threadpool is currently hard coded in this patch; if configuration is necessary, we could re-add the configuration options in r2881. Pre-mature optimization and all that led me to simply go with a simpler model for now.
Note that the approach taken here was to add additional API calls rather than modify existing ones. If we'd rather the thread dispatch model be dictated by a parameter, the new API calls can be removed in trunk and the old API calls modified appropriately.
New unit tests were written to cover the new subscription types. This tests receiving messages sent using the threadpool.
The MWI tests and channel driver tests in the Test Suite were run and passed.
For the new configuration options:
* Tested under valgrind; confirmed no memory leaks with/without the config file
* Tested that the lack of stasis.conf did not preclude loading and that the defaults were applied
* Tested with an invalid config file; defaults still applied
* Tested with a valid config file; custom values applied
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the asterisk-dev