Summary:ASTERISK-24533: 2 threads created per chan_sip entry
Reporter:xrobau (xrobau)Labels:
Date Opened:2014-11-17 15:01:45.000-0600Date Closed:2014-12-01 09:55:22.000-0600
Versions:13.0.0 Frequency of
Environment:FreePBX Distro standard 13Attachments:( 0) backtrace-with-mailbox.txt
( 1) backtrace-without-mailbox.txt
( 2) sip_additional.conf
( 3) stasis-threadpool-13.diff
( 4) stasis-threadpool-13-take2.diff
Description:When creating a chan_sip entry, it appears that in 13, a thread is being created for each entry, as well as a thread for every mailbox.

This is unexpectedly large, and is a regression from 11 and 12, where the thread count was around 40 to 60 for the same number of entries.
Comments:By: xrobau (xrobau) 2014-11-17 15:10:20.142-0600

The 'backtrace-without-mailbox' has 642 threads. The 'backtrace-with-mailbox' has 1147 threads.

By: xrobau (xrobau) 2014-11-17 15:11:28.078-0600

sip_additional.conf (freepbx generated) of the extensions in question

This is a randomly generated series, and does not contain any confidential information.

By: Matt Jordan (mjordan) 2014-11-17 17:25:01.725-0600

[~xrobau]: attached is a preliminary patch, {{stasis-threadpool-13.diff}}, that should address this for {{chan_sip}}. It uses a threadpool for what I think should have been the cause of this in {{chan_sip}} - although there are other culprits. Let me know how much this knocks the threads down.

By: xrobau (xrobau) 2014-11-17 20:35:44.856-0600


Asterisk SVN-branch-13-r428145
[root@localhost asterisk]# ps -eLf | grep /usr/sbin/ast | wc -l
[root@localhost asterisk]#

Asterisk SVN-branch-13-r428145 WITH STASIS-THREADPOOL
[root@localhost asterisk]# ps -eLf | grep /usr/sbin/ast | wc -l
[root@localhost asterisk]#

Note that enabling/disabling mailbox makes no difference to the threadcount now, it stays at 577 with or without the mailbox= line in sip.conf.

By: Matt Jordan (mjordan) 2014-11-17 21:00:52.460-0600

Hm. I wonder who the other subscriber is. I'll look through {{chan_sip}} some more.

By: Matt Jordan (mjordan) 2014-11-17 21:09:24.177-0600

Pretty sure I found it. Compiling.

By: Matt Jordan (mjordan) 2014-11-17 21:15:54.405-0600

Take 2 attached. Pretty sure it was subscriptions for endpoints...

By: xrobau (xrobau) 2014-11-17 21:55:18.254-0600

That's much better!
[root@localhost asterisk]# asterisk -rx 'sip show peers' | grep peers
499 sip peers [Monitored: 0 online, 499 offline Unmonitored: 0 online, 0 offline]
[root@localhost asterisk]# ps -eLf | grep /usr/sbin/aster | wc -l
[root@localhost asterisk]#

By: Matt Jordan (mjordan) 2014-11-18 12:41:06.943-0600

Updated reviewboard link.