*BSD News Article 53928


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!pravda.aa.msen.com!dsinc!newsfeed.pitt.edu!uunet!in1.uu.net!newsfeed.internetmci.com!solaris.cc.vt.edu!news.mathworks.com!tank.news.pipex.net!pipex!uknet!dcl-cs!bath.ac.uk!aber!io.salford.ac.uk!viking.ucsalf.ac.uk!not-for-mail
From: mark@plato.ucsalf.ac.uk (Mark Powell)
Newsgroups: comp.unix.bsd.freebsd.misc,gnu.gcc.help,comp.os.linux.misc
Subject: gcc optimisations when compiling the kernel
Date: 1 Nov 1995 20:56:19 -0000
Organization: Computer Services Unit, University College Salford, Salford, UK
Lines: 54
Message-ID: <478mtj$e2v@plato.ucsalf.ac.uk>
NNTP-Posting-Host: plato.ucsalf.ac.uk
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:8144 gnu.gcc.help:13683 comp.os.linux.misc:68033

Looked in the handbook and the FAQ and couldn't find anything in there on
which optimisations to use when compiling the kernel. Although I knew the
-m486 flag would produce slightly faster code on a 486 with only slightly 
larger binaries, I was informed that it would actually reduce performance on
a Pentium. However, I did some tests on an unloaded 90MHz Pentium running
FreeBSD 2.0.5 with the supplied gcc v2.6.3 used to compile Dhrystone v2.1

All figures in Dhrystones/second taken as an average of 3 x 10,000,000 run
samples, when drhystone is compiled with the options on the left.

gcc                                      80290.1
gcc -fomit-frame-pointer                 81700.4
gcc -O2                                 111624.2
gcc -O                                  112035.1
gcc -O2 -m486                           114561.9
gcc -O -m486                            117896.4
gcc -O -fomit-frame-pointer             127490.0
gcc -O2 -fomit-frame-pointer            129067.8
gcc -O2 -m486 -fomit-frame-pointer      130799.1
gcc -O -m486 -fomit-frame-pointer       131268.6

Strange that the -O seems to have the edge over -O2 in most of the tests,
although the edge is only very slight and can probably be ignored due to
the general variance in dhrystone results.
Although -fomit-frame-pointer gives only a slight performance increase
with no optimisation, it seems useful when optimisation is on.
Compiling the FreeBSD 2.0.5-RELEASE kernel with my own configuration gives
the following /kernel sizes:

gcc -O2 -m486 -fomit-frame-pointer	952K
gcc -O2 -fomit-frame-pointer		888K
gcc -O2					868K

It would seem that the default kernel compile flags should be:

-O2		( or -O, anyone with good gcc knowledge care to comment? )

to get the smallest possible kernel, but:

-O2 -fomit-frame-pointer

to get good performance for only slightly more binary, and:

-O2 -m486 -fomit-frame-pointer

would seem okay for everyone except people with 4Mb RAM. Are there really
a lot of these?
Comments welcome.
-- 
Mark Powell - Senior Network Technician - Room: C806
Computer Services Unit, University College Salford, Salford, UK.
Tel:	+44 161 745 3376	Fax:	+44 161 736 3596
Email:	mark@ucsalf.ac.uk	finger mark@ucsalf.ac.uk (for PGP key)
<A HREF="http://www.ucsalf.ac.uk/~mark/">Home Page</A>