[asterisk-dev] A small improvement to the pbx core... Call for review/test!

Steve Murphy murf at digium.com
Tue Oct 30 13:22:35 CDT 2007


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20071030/6abd7e05/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3227 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-dev/attachments/20071030/6abd7e05/attachment.bin 


More information about the asterisk-dev mailing list