<div dir="ltr"><div>Raised <a href="http://jira.freeswitch.org/browse/FS-5036">http://jira.freeswitch.org/browse/FS-5036</a> - thanks - David</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jan 17, 2013 at 9:36 PM, David Brazier <span dir="ltr">&lt;<a href="mailto:davidjbrazier@gmail.com" target="_blank">davidjbrazier@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">François<br>
<br>
Thanks for the suggestion, will try re-working with execute_extension.<br>
<br>
David<br>
<br>
<br>
From: François Delawarde<br>
Sent: 17/01/2013 11:26<br>
To: <a href="mailto:freeswitch-dev@lists.freeswitch.org">freeswitch-dev@lists.freeswitch.org</a><br>
Subject: Re: [Freeswitch-dev] transfer_history performance<br>
<div class="HOEnZb"><div class="h5">Hi David,<br>
<br>
The &quot;transfer&quot; app is quite heavy to be chained 1000s of times as it<br>
does many things to keep track of what happened (handle max-fw, dup<br>
caller profile, history var, ...). You might end-up with other issues<br>
trying to scale, maybe disk bottleneck writing huge xml-cdr files, ...<br>
<br>
What about making your application use &quot;execute_extension&quot; instead? Note<br>
that I still vote yes for your optimization ideas!<br>
<br>
François.<br>
<br>
<br>
On Thu, 2013-01-17 at 10:48 +0000, David Brazier wrote:<br>
&gt; Hi again<br>
&gt;<br>
&gt; A bit more information on reproducing it: each call using<br>
&gt; test_transfer will fully occupy one CPU, so on a 4 core machine you<br>
&gt; need to start 4 of these calls to tie it up, then audio on other calls<br>
&gt; is broken or completely stopped, CLI stops responding etc.  As a<br>
&gt; workaround I have commented out from switch_ivr.c line 1808 near end<br>
&gt; of switch_ivr_session_transfer:<br>
&gt;<br>
&gt; /*switch_channel_add_variable_var_check(channel,<br>
&gt; SWITCH_TRANSFER_HISTORY_VARIABLE, new_profile-&gt;transfer_source,<br>
&gt; SWITCH_FALSE, SWITCH_STACK_PUSH);*/<br>
&gt;<br>
&gt; Of course that means transfer_history is no longer populated, but it<br>
&gt; does remove the performance problem, the test_transfer calls now run<br>
&gt; through so fast I had to start the loop off at 9999 and although they<br>
&gt; do use a bit of CPU (it is a tight loop with no sleep/IO etc after<br>
&gt; all) 4 simultaneously do not tie up the server and other calls<br>
&gt; continue fine.  I can think of a few more complete solutions:<br>
&gt;      1. Improve the performance of appending to variables with big<br>
&gt;         values - I think this is ultimately done in<br>
&gt;         switch_event_base_add_header in switch_event.c, though that<br>
&gt;         looks like quite a complex function.  In the end, repeated<br>
&gt;         appending to long strings is never going to be efficient.<br>
&gt;      2. Maintain the transfer history as a stack/list/array structure<br>
&gt;         and either render it to the variable string whenever it is<br>
&gt;         changed (still expensive?) or generate the string only on<br>
&gt;         demand - though I&#39;m not sure how that would work with info,<br>
&gt;         uuid_dump and verbose events in event sockets etc.<br>
&gt;      3. Allow channels to opt out of having transfer_history tracked,<br>
&gt;         perhaps by setting it to &quot;suppress&quot; or &quot;false&quot;, this could be<br>
&gt;         checked before the line above.  Would put the onus on the<br>
&gt;         dialplan to know if it was going to do lots of transfers, but<br>
&gt;         it would be backward-compatible with anyone who needs this<br>
&gt;         variable.  Out of interest why was it added?<br>
&gt; Once I have managed to log in to Jira I will raise all this there.<br>
&gt;<br>
&gt; Cheers<br>
&gt;<br>
&gt; David<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Jan 17, 2013 at 12:57 AM, David Brazier<br>
&gt; &lt;<a href="mailto:davidjbrazier@gmail.com">davidjbrazier@gmail.com</a>&gt; wrote:<br>
&gt;         Hi<br>
&gt;<br>
&gt;         Our application makes use of long-running calls with a lot of<br>
&gt;         diaplan transfers to bridge them to other calls, put them on<br>
&gt;         hold etc.  We&#39;ve noticed a slow down in performance (high CPU,<br>
&gt;         audio dropped, delayed) after several hours.  I can reproduce<br>
&gt;         it with some dialplan that does 1000 transfers:<br>
&gt;<br>
&gt;         &lt;extension name=&quot;test_transfer&quot;&gt;<br>
&gt;           &lt;condition field=&quot;destination_number&quot;<br>
&gt;         expression=&quot;^test_transfer$&quot;&gt;<br>
&gt;             &lt;action application=&quot;set&quot; data=&quot;max_forwards=9999&quot;/&gt;<br>
&gt;             &lt;action application=&quot;transfer&quot; data=&quot;test_transfer_999&quot;/&gt;<br>
&gt;           &lt;/condition&gt;<br>
&gt;         &lt;/extension&gt;<br>
&gt;         &lt;extension name=&quot;test_transfer_0&quot; continue=&quot;false&quot;&gt;<br>
&gt;           &lt;condition field=&quot;destination_number&quot;<br>
&gt;         expression=&quot;^test_transfer_0$&quot;&gt;<br>
&gt;             &lt;action application=&quot;hangup&quot;/&gt;<br>
&gt;           &lt;/condition&gt;<br>
&gt;         &lt;/extension&gt;<br>
&gt;         &lt;extension name=&quot;test_transfer_n&quot;&gt;<br>
&gt;           &lt;condition field=&quot;destination_number&quot;<br>
&gt;         expression=&quot;^test_transfer_(\d+)$&quot;&gt;<br>
&gt;             &lt;!--&lt;action application=&quot;info&quot;/&gt;--&gt;<br>
&gt;             &lt;action application=&quot;transfer&quot; data=&quot;test_transfer_${expr<br>
&gt;         $1-1}&quot;/&gt;<br>
&gt;           &lt;/condition&gt;<br>
&gt;         &lt;/extension&gt;<br>
&gt;<br>
&gt;         and then<br>
&gt;<br>
&gt;         originate user/1000 test_transfer XML blah<br>
&gt;<br>
&gt;         On a Windows laptop (git head) it slows down to more than 1<br>
&gt;         sec per iteration after it gets past 800, on a bigger Linux<br>
&gt;         server (FS 1.2.5.1) it gets a bit futher but not much.  On a<br>
&gt;         server with an old version (git-1086cba 2011-05-23 22-51-43<br>
&gt;         -0500) it zips through to the end with no slow down.  If you<br>
&gt;         put the info call in you can see that<br>
&gt;         variable_transfer_history is growing, and I think this is the<br>
&gt;         source of the problem - this variable is missing from the<br>
&gt;         older version but the newer ones are apparently appending to<br>
&gt;         it on each iteration which becomes a very expensive<br>
&gt;         operation.<br>
&gt;<br>
&gt;         I&#39;ll raise a Jira.  Any suggestion for a workaround? (Apart<br>
&gt;         from rewriting our dialplan!)<br>
&gt;<br>
&gt;         David<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _________________________________________________________________________<br>
&gt; Professional FreeSWITCH Consulting Services:<br>
&gt; <a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
&gt; <a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
&gt;<br>
&gt; FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
&gt; <a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
&gt;<br>
&gt; Official FreeSWITCH Sites<br>
&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
&gt; <a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
&gt; <a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
&gt;<br>
&gt; FreeSWITCH-dev mailing list<br>
&gt; <a href="mailto:FreeSWITCH-dev@lists.freeswitch.org">FreeSWITCH-dev@lists.freeswitch.org</a><br>
&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br>
<br>
<br>
_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-dev mailing list<br>
<a href="mailto:FreeSWITCH-dev@lists.freeswitch.org">FreeSWITCH-dev@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
</div></div></blockquote></div><br></div>