<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Steve Murphy wrote:
<blockquote cite="mid1193843164.22777.60.camel@digium2" type="cite">
<meta http-equiv="Content-Type" content="text/html; ">
<meta name="GENERATOR" content="GtkHTML/3.14.3">
In my effort to resurrect my long-ignored work on keeping large
dialplans from slowing down the PBX, I unearthed the fact, that
somehow, somewhere, around 20% of the performance of the PBX engine
was "missing"!!!<br>
<br>
Where this performance went, I have no idea. But we all need to think
on how we might get them back. I've come up with almost half of them
(percentage points of performance, that is) in one optimization,
perhaps others of you can come up with others.<br>
<br>
My test is a simple tight loop of 4 priorities, I've written about and
talked about at conferences previously. Before, about a year ago, I was
seeing 90,000 PIPS from my test system. Yesterday, I measured trunk at
76,000 PIPS. With my optimization, I see 83,000 PIPS. <br>
<br>
I've used gprof on my fast-ast2 branch of asterisk, and these are the
contending routines for optimizations:<br>
<br>
% cumulative self self total<br>
time seconds seconds calls s/call s/call name<br>
23.83 5.47 5.47 4000005 0.00 0.00
pbx_substitute_variables<br>
11.69 8.15 2.68 2000075 0.00 0.00
pbx_substitute_variables_helper_full<br>
</blockquote>
...<br>
Well the following is obviously MUUCH faster than the original:<br>
<br>
static void pbx_substitute_variables(char *passdata, int datalen,
struct ast_channel *c, struct ast_exten *e)<br>
{<br>
<br>
/* No variables or expressions in e->data, so why scan it? */<br>
if (e->data && !strchr(e->data, '$'))<br>
ast_copy_string(passdata, e->data, datalen);<br>
return;<br>
}<br>
<br>
*passdata = 0;<br>
pbx_substitute_variables_helper(c, e->data, passdata,
datalen - 1);<br>
}<br>
<br>
<br>
Original:<br>
static void pbx_substitute_variables(char *passdata, int datalen,
struct ast_channel *c, struct ast_exten *e)<br>
{<br>
memset(passdata, 0, datalen);<br>
<br>
/* No variables or expressions in e->data, so why scan it? */<br>
if (e->data && !strchr(e->data, '$') &&
!strstr(e->data,"${") && !strstr(e->data,"$[") &&
!strstr(e->data,"$(")) {<br>
ast_copy_string(passdata, e->data, datalen);<br>
return;<br>
}<br>
<br>
pbx_substitute_variables_helper(c, e->data, passdata,
datalen - 1);<br>
}<br>
<br>
<br>
<br>
<br>
static void pbx_substitute_variables(char *passdata, int datalen,
struct ast_channel *c, struct ast_exten *e)<br>
{<br>
memset(passdata, 0, datalen);<br>
<br>
/* No variables or expressions in e->data, so why scan it? */<br>
if (e->data && !strchr(e->data, '$') &&
!strstr(e->data,"${") && !strstr(e->data,"$[") &&
!strstr(e->data,"$(")) {<br>
ast_copy_string(passdata, e->data, datalen);<br>
return;<br>
}<br>
<br>
pbx_substitute_variables_helper(c, e->data, passdata,
datalen - 1);<br>
}<br>
<br>
<br>
<br>
<br>
<br>
<blockquote cite="mid1193843164.22777.60.camel@digium2" type="cite"><br>
[dialextens]<br>
exten => _10X,1,Dial(Zap/${EXTEN:2}|30|tw)<br>
exten => _1ZX,1,Dial(Zap/${EXTEN:1}|30|tw)<br>
<br>
<br>
[dialthrus]<br>
exten => _3XX,1,Dial(Zap/${EXTEN:1}|30|tw)<br>
<br>
<br>
[t1incoming]<br>
include => dialextens<br>
include => parkedcalls<br>
exten => s,1,Answer()<br>
exten => s,2,Background(welcome-to-test-machine)<br>
<br>
<br>
[incoming]<br>
include => dialextens<br>
include => parkedcalls<br>
exten => s,1,Answer()<br>
exten => s,2,Background(welcome-to-test-machine)<br>
<br>
<br>
[extension]<br>
include => dialextens<br>
include => dialthrus<br>
exten => 5,1,Record(recording:gsm)<br>
exten => 5,2,Background(recording)<br>
exten => 81,1,Set(iterations=$[1000000])<br>
exten => 81,2,Set(time1=${EPOCH})<br>
exten => 81,3,Set(i=$[1])<br>
<font color="#ff6600">exten =>
81,4,GotoIf($[${i}<${iterations}]?5:8)</font><br>
<font color="#ff6600">exten => 81,5,NoOp(Hello)</font><br>
<font color="#ff6600">exten => 81,6,Set(i=$[${i}+1])</font><br>
<font color="#ff6600">exten => 81,7,Goto(4)</font><br>
exten => 81,8,NoOp(Finish for-extension-1)<br>
exten => 81,9,Set(time2=${EPOCH})<br>
exten => 81,10,Verbose(The time diff is $[${time2} - ${time1} ]
seconds)<br>
exten => 81,11,Verbose(Which means that the priorities/sec = $[4*
${iterations} / (${time2} - ${time1}) ])<br>
exten => 81,12,SayNumber($[4 * ${iterations} / (${time2} - ${time1})
])<br>
exten => 82,1,NoOp(Never here)<br>
exten => 82,2,Verbose(Not here either!)<br>
exten => 83,1,Read(x|beep|1||1|0.3)<br>
exten => 83,2,Read(x|beep|1||1|0.3)<br>
exten => 83,3,Read(x|beep|1||1|0.3)<br>
<br>
murf<br>
<table cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td>
<pre>--
Steve Murphy
Software Developer
Digium
</pre>
</td>
</tr>
</tbody>
</table>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
--Bandwidth and Colocation Provided by <a class="moz-txt-link-freetext" href="http://www.api-digital.com">http://www.api-digital.com</a>--
asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
<a class="moz-txt-link-freetext" href="http://lists.digium.com/mailman/listinfo/asterisk-dev">http://lists.digium.com/mailman/listinfo/asterisk-dev</a></pre>
</blockquote>
<br>
</body>
</html>