[asterisk-dev] performance of DONT_OPTIMIZE
Tzafrir Cohen
tzafrir.cohen at xorcom.com
Wed Nov 27 13:41:27 CST 2013
Hi
https://wiki.asterisk.org/wiki/display/AST/Getting+a+Backtrace reads:
| Running a production server with DONT_OPTIMIZE is generally safe. You'll
| notice the binary files may be a bit larger, but in terms of Asterisk
| performance, impact should be negligible.
The effect of DONT_OPTIMIZE is setting the optimization build flag to
-O0 (rather than -O6).
As a side note, recent versions of gcc (4.8) have -Og:
| Optimize debugging experience. -Og enables optimizations that do not
| interfere with debugging. It should be the optimization level of choice
| for the standard edit-compile-debug cycle, offering a reasonable level
| of optimization while maintaining fast compilation and a good debugging
| experience.
It would probably be better than -O0, if available (thanks ot Tim_Today
on #asterisk-dev).
Common wisdom is that optimization level does impact performance.
Consider the following (pathalogical, though) example:
$ cat /tmp/test.c
int main() {
int i;
for(i=1; i<100000000; i++)
;
return 0;
}
$ gcc -O0 /tmp/test.c -o /tmp/test; time /tmp/test
real 0m0.214s
user 0m0.212s
sys 0m0.000s
$ gcc -O2 /tmp/test.c -o /tmp/test; time /tmp/test
real 0m0.001s
user 0m0.000s
sys 0m0.000s
The unoptimized version would have indeed preserved the code. But I want
the compiler to provide me with better performance.
A simple artificial test shows a noticable (-40% or so) performance
penalty on the following loop:
exten => time,n,Set(i=100000)
exten => time,n,While($[${i} > 0])
exten => time,n,Set(i=$[${i} - 1])
exten => time,n,EndWhile
So I wonder if Asterisk's performance is that much not CPU bound that
the effect of a similar penalty will be negligible. Any numbers?
--
Tzafrir Cohen
icq#16849755 jabber:tzafrir.cohen at xorcom.com
+972-50-7952406 mailto:tzafrir.cohen at xorcom.com
http://www.xorcom.com
More information about the asterisk-dev
mailing list