Subject: Re: Kernel optimizations!
To: Sung N. Cho <sucho2@vt.edu>
From: David Laight <david@l8s.co.uk>
List: netbsd-help
Date: 05/10/2002 10:26:01
On Thu, May 09, 2002 at 07:51:23PM +0000, Sung N. Cho wrote:
> I was wondering, shouldn't turning on the optimization for gcc make the
> kernel bigger?
Probably not. Most of the 'optimisations' that increase code size
(eg loop unrolling and function inlining) are IMHO probably
deoptimisations for modern hardware. Indeed I don't think O3
enables them.
>
> I added in my /etc/mk.conf the following lines:
>
> COPTS+= -O3 -mcpu=i686 -march=i686
> CXXFLAGS+= -O3 -mcpu=i686 -march=i686
> CFLAGS+= -O3 -mcpu=i686 -march=i686
>
> Then compiled the kernel. The prior size for the kernel which was compiled
> with default -O2 option was 2.4M. This new kernel with -O3 option turned on
> have now even smaller size, 1.8M!
How are you measuring the size?
You need to use 'size' not 'ls'!
If you are seeing a 25% reduction it might be worth looking at
some of the generated code. Such a large change probably involves
a major change in the way code has been compiled!
David
--
David Laight: david@l8s.co.uk