Re: P4 optimized Debian GNU/Linux?
On Fri, Feb 27, 2004 at 08:40:28AM +0000, Adam Majer wrote:
> Turbo Fredriksson wrote:
>
> >It's been discussed before, but I never bothered to look into that,
> >since I didn't think I cared :)
> >
> >Now, a friend of mine took the time to (more or less) manually recompile/
> >repackage/reinstall his Debian GNU/Linux woody box.
> >
> >His word was "it WAY faster!". No numbers, just those three words. Got'a
> >mean something...
> >
> >If I remember correctly from the last time I saw this subject come up,
> >the resolution was "no, we don't want that". I can't remember why, but
> >I don't care (unless it's changed :).
> >
> >
> Ok, I have actually done a little test program. The problem is that
> optimizing an application with gcc 3.3 might actually make things
> *slower*. I have a P4 (2.6GHz) and an K7 2000+ workstation. When I run a
> simple program that only does,
>
> start_time = time();
> for( int i=0; i<10000000; i++ ) // I forget how many 0 I had exactly
> sin ( i / 324.34444 );
> end_time = time();
> printf( "Diff: %d\n", end_time - start_time );
>
> When I run the program with no optimization -O0, I got some numbers that
> looked about the same for both machines. Then I compiled with
> -march=pentium-4 and -march=athlon-xp and -O6, and surprise, surprise,
> the P4 had a speed *decrease*!! It slowed down from something like 23
> seconds to 25 seconds. I don't know the exact numbers right now since
> this was about a month ago, but optimizing things for P4 using gcc is
> not the best thing. It is much better to just least things with i386 or
First of all -O6 is the same as -O3.
It's well-known that in most cases -Os or -O2 produces the fastest code -
-O3 usually produces slower code.
Could you double-check whether -Os or -O2 produce slower code than -O0?
> i486, and just use -O6 or whatever. There is a reason why linux uses
> assembly for speed critical parts of the kernel!
>...
These are only very few parts of the kernel.
_Many_ speed-critical paths of the kernel are written in C (often with
people checking the output of gcc).
The days when hand-written assembler was better than compiled C code are
nearly gone - writing faster assembler code for a modern cpu than the
output of a good C compiler is a very hard task.
> - Adam
>...
cu
Adrian
--
"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed
Reply to: