<div dir="ltr"><div>Hi again</div><div> </div><div>A bit more information on reproducing it: each call using test_transfer will fully occupy one CPU, so on a 4 core machine you need to start 4 of these calls to tie it up, then audio on other calls is broken or completely stopped, CLI stops responding etc. As a workaround I have commented out from switch_ivr.c line 1808 near end of switch_ivr_session_transfer:</div>
<div> </div><div><font face="Consolas"><font color="#008000" face="Consolas"><font color="#008000" face="Consolas"><font color="#008000" face="Consolas">/*switch_channel_add_variable_var_check(channel, SWITCH_TRANSFER_HISTORY_VARIABLE, new_profile->transfer_source, SWITCH_FALSE, SWITCH_STACK_PUSH);*/</font></font></font></font></div>
<div>
</div><div>Of course that means transfer_history is no longer populated, but it does remove the performance problem, the test_transfer calls now run through so fast I had to start the loop off at 9999 and although they do use a bit of CPU (it is a tight loop with no sleep/IO etc after all) 4 simultaneously do not tie up the server and other calls continue fine. I can think of a few more complete solutions:</div>
<ol><li>Improve the performance of appending to variables with big values - I think this is ultimately done in switch_event_base_add_header in switch_event.c, though that looks like quite a complex function. In the end, repeated appending to long strings is never going to be efficient.</li>
<li>Maintain the transfer history as a stack/list/array structure and either render it to the variable string whenever it is changed (still expensive?) or generate the string only on demand - though I'm not sure how that would work with info, uuid_dump and verbose events in event sockets etc.</li>
<li>Allow channels to opt out of having transfer_history tracked, perhaps by setting it to "suppress" or "false", this could be checked before the line above. Would put the onus on the dialplan to know if it was going to do lots of transfers, but it would be backward-compatible with anyone who needs this variable. Out of interest why was it added?</li>
</ol><div>Once I have managed to log in to Jira I will raise all this there.</div><div> </div><div>Cheers</div><div> </div><div>David</div><div> </div><div> </div><div class="gmail_extra"><div class="gmail_quote">On Thu, Jan 17, 2013 at 12:57 AM, David Brazier <span dir="ltr"><<a href="mailto:davidjbrazier@gmail.com" target="_blank">davidjbrazier@gmail.com</a>></span> wrote:<br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote"><div dir="ltr"><div>Hi</div><div> </div><div>Our application makes use of long-running calls with a lot of diaplan transfers to bridge them to other calls, put them on hold etc. We've noticed a slow down in performance (high CPU, audio dropped, delayed) after several hours. I can reproduce it with some dialplan that does 1000 transfers: </div>
<div><br><extension name="test_transfer"><br> <condition field="destination_number" expression="^test_transfer$"><br> <action application="set" data="max_forwards=9999"/><br>
<action application="transfer" data="test_transfer_999"/><br> </condition><br></extension></div><div><extension name="test_transfer_0" continue="false"><br>
<condition field="destination_number" expression="^test_transfer_0$"><br> <action application="hangup"/><br> </condition><br></extension></div><div><extension name="test_transfer_n"><br>
<condition field="destination_number" expression="^test_transfer_(\d+)$"><br> <!--<action application="info"/>--><br> <action application="transfer" data="test_transfer_${expr $1-1}"/><br>
</condition><br></extension><br></div><div>and then</div><div> </div><div>originate user/1000 test_transfer XML blah</div><div> </div><div>On a Windows laptop (git head) it slows down to more than 1 sec per iteration after it gets past 800, on a bigger Linux server (FS 1.2.5.1) it gets a bit futher but not much. On a server with an old version (git-1086cba 2011-05-23 22-51-43 -0500) it zips through to the end with no slow down. If you put the info call in you can see that variable_transfer_history is growing, and I think this is the source of the problem - this variable is missing from the older version but the newer ones are apparently appending to it on each iteration which becomes a very expensive operation.</div>
<div> </div><div>I'll raise a Jira. Any suggestion for a workaround? (Apart from rewriting our dialplan!)</div><span><font color="#888888"><div> </div><div>David</div><div> </div><div><br> </div></font></span></div>
</blockquote></div><br></div><div class="gmail_extra"> </div></div>