[prev in list] [next in list] [prev in thread] [next in thread] 

List:       asterisk-dev
Subject:    Re: [asterisk-dev] A small improvement to the pbx core... Call for
From:       "Clod Patry" <cpatry () gmail ! com>
Date:       2007-10-31 5:40:09
Message-ID: ba3a70d80710302240s656eab1du8e0a52470790ace7 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


speedup is always good Steve.

just a quick question regarding ast_spawn_extension(), why do we have to
pass it the CEP (Context Extension Prioriry), while we are already passing
it the ast_channel struct? Maybe to pass a different CEP? With a grep, i
dont see any place where we pass other CEP then the ast_channel we already
passed to it.
That could be simpler just to pass it the ast_channel no ?



On Oct 30, 2007 2:22 PM, Steve Murphy <murf@digium.com> wrote:

>  In the branch http://svn.digium.com/svn/asterisk/team/murf/fast-ast3 I
> have tweaked the execution loop that runs instructions in the dialplan, to
> eliminate half the find_extension calls, and therefore run more efficiently.
> It results in a solid 9% speedup to trunk.
>
> What I did was this:
>
> /* loop on priorities in this context/exten */
> while (ast_exists_extension(c, c->context, c->exten, c->priority, c->
> cid.cid_num)) {
> found = 1;
> if ((res = ast_spawn_extension(c, c->context, c->exten, c->priority, c->
> cid.cid_num))) {
> /* Something bad happened, or a hangup has been requested. */
>                                          ................
>
> to this:
>
>
> /* loop on priorities in this context/exten */
> while ( !(res = ast_spawn_extension(c, c->context, c->exten, c->priority,
> c->cid.cid_num, &found))) {
> if (c->_softhangup == AST_SOFTHANGUP_TIMEOUT && ast_exists_extension(c,
> c->context, "T", 1, c->cid.cid_num)) {
>                                    ...........
> c->priority++;
> } /* end while  - from here on we can use 'break' to go out */
> if (found && res) {
> /* Something bad happened, or a hangup has been requested. */
>
> You see, exists_extension() and spawn_extension() are both really just
> front ends to extension_helper, and seems a waste
> to call the same function twice in succession, when one can tell you
> everything you need to know!
>
> SO, I added the ptr to 'found' to the spawn_extension, and make
> spawn_extension set it. Then rearrange the flow so the same
> stuff happens as did previously.
>
> If I'm shooting myself or really mucking things up, please let me know. It
> looks OK to me, and runs OK in my test system, but
> this is at the very core of the PBX. Any other reviewers/testers who would
> like to make sure I'm not destroying something
> would be welcome.
>
> As it is, the code executed between priority executions is cut in half,
> and now only one call to find_extension is done, which seems to
> me more efficient.
>
>
> murf
>
>   --
> Steve Murphy
> Software Developer
> Digium
>
>
> _______________________________________________
> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-dev
>



-- 
Clod Patry

[Attachment #5 (text/html)]

speedup is always good Steve.<br><br>just a quick question regarding \
ast_spawn_extension(), why do we have to pass it the CEP (Context Extension \
Prioriry), while we are already passing it the ast_channel struct? Maybe to pass a \
different CEP? With a grep, i dont see any place where we pass other CEP then the \
ast_channel we already passed to it. <br>That could be simpler just to pass it the \
ast_channel no ?<br><br><br><br><div class="gmail_quote">On Oct 30, 2007 2:22 PM, \
Steve Murphy &lt;<a href="mailto:murf@digium.com">murf@digium.com</a>&gt; \
wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, \
204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



  
  

<div>
In the branch <a href="http://svn.digium.com/svn/asterisk/team/murf/fast-ast3" \
target="_blank">http://svn.digium.com/svn/asterisk/team/murf/fast-ast3</a> I have \
tweaked the execution loop that runs instructions in the dialplan, to eliminate half \
the find_extension calls, and therefore run more efficiently. It results in a solid \
9% speedup to trunk. <br>
<br>
What I did was this:<br>
<br>
		/* loop on priorities in this context/exten */<br>
		while (ast_exists_extension(c, c-&gt;context, c-&gt;exten, c-&gt;priority, \
c-&gt;cid.cid_num)) {<br>  found = 1;<br>
			if ((res = ast_spawn_extension(c, c-&gt;context, c-&gt;exten, c-&gt;priority, \
c-&gt;cid.cid_num))) {<br>  /* Something bad happened, or a hangup has been \
requested. */<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n \
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs \
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
................<br> <br>
to this:<br>
<br>
<br>
		/* loop on priorities in this context/exten */<br>
		while ( !(res = ast_spawn_extension(c, c-&gt;context, c-&gt;exten, c-&gt;priority, \
c-&gt;cid.cid_num, &amp;found))) {<br>  if (c-&gt;_softhangup == \
AST_SOFTHANGUP_TIMEOUT &amp;&amp; ast_exists_extension(c, c-&gt;context, \
&quot;T&quot;, 1, c-&gt;cid.cid_num)) {<br> \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n \
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
...........<br>  c-&gt;priority++;<br>
		} /* end while&nbsp; - from here on we can use &#39;break&#39; to go out */<br>
		if (found &amp;&amp; res) {<br>
			/* Something bad happened, or a hangup has been requested. */<br>
<br>
You see, exists_extension() and spawn_extension() are both really just front ends to \
extension_helper, and seems a waste <br> to call the same function twice in \
succession, when one can tell you everything you need to know!<br> <br>
SO, I added the ptr to &#39;found&#39; to the spawn_extension, and make \
spawn_extension set it. Then rearrange the flow so the same<br> stuff happens as did \
previously.<br> <br>
If I&#39;m shooting myself or really mucking things up, please let me know. It looks \
OK to me, and runs OK in my test system, but<br> this is at the very core of the PBX. \
Any other reviewers/testers who would like to make sure I&#39;m not destroying \
something<br> would be welcome.<br>
<br>
As it is, the code executed between priority executions is cut in half, and now only \
one call to find_extension is done, which seems to<br> me more efficient.<br>
<br>
<br>
murf<br>
<br>
<table cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td>
<pre>-- 
Steve Murphy
Software Developer
Digium
</pre>
</td>
</tr>
</tbody></table>
</div>

<br>_______________________________________________<br>--Bandwidth and Colocation \
Provided by <a href="http://www.api-digital.com--" \
target="_blank">http://www.api-digital.com--</a><br><br>asterisk-dev mailing \
list<br>To UNSUBSCRIBE or update options visit: <br> &nbsp; <a \
href="http://lists.digium.com/mailman/listinfo/asterisk-dev" \
target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-dev</a><br></blockquote></div><br><br \
clear="all"><br>-- <br>Clod Patry



_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic