[Home]

Summary:ASTERISK-04982: Makefile specifies dangerous optimizations, not easy to use etc
Reporter:David James (davidj)Labels:
Date Opened:2005-09-04 20:57:52Date Closed:2011-06-07 14:10:37
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) gcc-opts.c
Description:Issues:

1. Makefile specifies -O6 which is really -O3, which can be dangerous for some archs.
2. Makefile assumes i686, PENTIUMPRO, which breaks sse/sse2 in iLBC and can cause Pentium4/Xeon slowdowns.  
3. Makefile should be tweeked to better allow CFLAGS changes to be made

This is with gcc 3.4.3 and perhaps other versions of gcc.


****** ADDITIONAL INFORMATION ******

1. See attached opts.c which is a snap of gcc-3.4.3/gcc/opts.c for explaination

2. Asterisk compiles default for i686 which infers PENTIUMPRO .. a very old processor.
* Users on Pentium4/Xeon will experience slowdowns because gcc won't optimize with any latest process technology and will experience cache misses. Critical for realtime apps.
* AMD K6 users, however, from my person experience will get a small speedup.  This is because AMD is focused on optimizating for the last generation of Intel.

* Specifically i686 will break sse, sse2, and sse3 (prescott/ latest AMD only):

My makefile:
[root@comcast asterisk]# grep sse Makefile
CFLAGS+= -msse -msse2 -pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY

See it break:

[root@comcast asterisk]# make && make install
...
gcc -msse -msse2 -pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -g  -Iinclude -I../include -D_REENTRANT -D_GNU_SOURCE  -O6 -march=i686 -DZAPTEL_OPTIMIZATIONS         -fomit-frame-pointer  -fPIC   -c -o app_directory.o app_directory.c
{standard input}: Assembler messages:
{standard input}:1189: Error: suffix or operands invalid for `movd'
make[1]: *** [app_directory.o] Error 1
make[1]: Leaving directory `/usr/src/asterisk/apps'
make: *** [subdirs] Error 1

To fix this I changed -march from i686 to pentium4 in the Makefile.

3. CFLAGS is defined in Makefile for changes in 23 locations starting at line at line 201, however, this is confusing.
I recommend CFLAGS to be refactored and moved to the beginning of the Makefile
near line 45 around "Tell gcc to optimize the code"

My suggestion is to release Asterisk with out any optimizations at all or very few optimizations (-O2 at the most), reducing steps needed for developers to backtrace bugs and increasing visibility on slow parts of the code.  
Then, production users could use 'make optimized', a new entry in Makefile to be added for best performance.

This isn't nessessarily the best recommendations, but I hope it can serve as a beginning for further discussions. Thanks.


Comments:By: Tilghman Lesher (tilghman) 2005-09-05 02:33:33

So you altered your Makefile, and suddenly it is failing?  That seems to be an error on your part, not a problem in Asterisk.

By: David James (davidj) 2005-09-05 03:42:32

No this issue effects all user of Asterisk.  Please come to #asterisk on freenode
and speak with me opus__

Best regards.D

By: Michael Jerris (mikej) 2005-09-05 08:13:37

Do you have an actual patch that you would like reviewed?  What are your suggestions?  Please create a patch and explain how it makes things better.

By: Michael Jerris (mikej) 2005-09-13 19:07:00

Suspended due to no response.  If you would like to continue with this, please submit a patch with explanaion so we can review and discuss (a discalimer would also be required).  Thanks