RE: kernel optimization

2005-07-26 Thread Lee Revell
On Wed, 2005-07-27 at 06:53 +0300, Al Boldi wrote:
> Gettimeofday loops using gcc-3.2.2 on 2.4.31 and 2.6.12.
> 
> Also, 2.4 is faster than 2.6!

All this proves is that gettimeofday() is faster on 2.4 than 2.6.
Hardly surprising.

Lee

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: kernel optimization

2005-07-26 Thread Al Boldi
Adrian Bunk wrote: {
On Tue, Jul 26, 2005 at 08:22:59AM +0300, Al Boldi wrote:
> Dr. Horst H. von Brand wrote: {
> Al Boldi <[EMAIL PROTECTED]> wrote:
> >  Adrian Bunk wrote: {
> > On Fri, Jul 22, 2005 at 07:55:48PM +0100, christos gentsis wrote:
> > > i would like to ask if it possible to change the optimization of the 
> > > kernel from -O2 to -O3 :D, how can i do that? if i change it to the 
> > > top level Makefile does it change to all the Makefiles?
> > And since it's larger, it's also slower.
> > }
> 
> > It's faster but it's flawed.  Root-NFS boot failed!
> 
> How do you know that it is faster if it is busted?
> }
> 
> The -O3 compile produces a faster kernel, which seems to work perfectly,
> albeit the Root-NFS boot flaw!

How did you measure that you that your -O3 kernel isn't slower?
}

Gettimeofday loops using gcc-3.2.2 on 2.4.31 and 2.6.12.

Also, 2.4 is faster than 2.6!

Try this:

#define __USE_GNU
#include 
#include 

unsigned long elapsed(int start) {

static struct timeval s,e;

if (start) return gettimeofday(&s, NULL);

gettimeofday(&e, NULL);

return ((e.tv_sec - s.tv_sec) * 1000 + (e.tv_usec - s.tv_usec) /
1000);

}

int main(int argc, char *argv[]) {

int i;

elapsed(1);
for (i = 0; elapsed(0) < 100; i++) {
int ret = i;

if (ret > i)
break;
else if (ret < 0) {
perror("not here");
break;
}
ret++;
}

printf("Elapsed: %lu in %lums %lu/ms",i,elapsed(0),i/elapsed(0));

int tmo=i;

elapsed(1);
for (i = 0; i < 100*tmo ; i++) {
int ret = i;

if (ret > i)
break;
else if (ret < 0) {
perror("not here");
break;
}
ret++;
}

printf(" - %lu/ms",i/elapsed(0));

elapsed(1);
for (i = 0; i < 100*tmo ; i++);

printf(" - %lu/ms\n",i/elapsed(0));

return 0;
}

--
Al

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kernel optimization

2005-07-26 Thread Adrian Bunk
On Tue, Jul 26, 2005 at 08:22:59AM +0300, Al Boldi wrote:
> Dr. Horst H. von Brand wrote: {
> Al Boldi <[EMAIL PROTECTED]> wrote:
> >  Adrian Bunk wrote: {
> > On Fri, Jul 22, 2005 at 07:55:48PM +0100, christos gentsis wrote:
> > > i would like to ask if it possible to change the optimization of the 
> > > kernel from -O2 to -O3 :D, how can i do that? if i change it to the 
> > > top level Makefile does it change to all the Makefiles?
> > And since it's larger, it's also slower.
> > }
> 
> > It's faster but it's flawed.  Root-NFS boot failed!
> 
> How do you know that it is faster if it is busted?
> }
> 
> The -O3 compile produces a faster kernel, which seems to work perfectly,
> albeit the Root-NFS boot flaw!

How did you measure that you that your -O3 kernel isn't slower?

> Al

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: kernel optimization

2005-07-25 Thread Al Boldi
Dr. Horst H. von Brand wrote: {
Al Boldi <[EMAIL PROTECTED]> wrote:
>  Adrian Bunk wrote: {
> On Fri, Jul 22, 2005 at 07:55:48PM +0100, christos gentsis wrote:
> > i would like to ask if it possible to change the optimization of the 
> > kernel from -O2 to -O3 :D, how can i do that? if i change it to the 
> > top level Makefile does it change to all the Makefiles?
> And since it's larger, it's also slower.
> }

> It's faster but it's flawed.  Root-NFS boot failed!

How do you know that it is faster if it is busted?
}

The -O3 compile produces a faster kernel, which seems to work perfectly,
albeit the Root-NFS boot flaw!

--
Al

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kernel optimization

2005-07-23 Thread cutaway
I submit that sparse switch jump table's are not an "unusual" construct in
the Linux kernel/drivers.  GCC only creates a table large enough to cover
the largest of the sparse values - it doesn't have to be 0...255.  0...60
with 10 values sparsely scattered would generate a 61 element jump table.

There's many K of locked memory in these sparse jump tables.  About 2K worth
in the VT102 code alone.

- Original Message - 
From: "Alan Cox" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "Adrian Bunk" <[EMAIL PROTECTED]>; 
Sent: Saturday, July 23, 2005 15:50
Subject: Re: kernel optimization


> On Sad, 2005-07-23 at 02:30 -0400, [EMAIL PROTECTED] wrote:
> > Larger does not always mean slower.  If it did, nobody would implement a
> > loop unrolling optimization.
>
> Generally speaking nowdays it does. Almost all loop unrolls are a loss
> on PIV.
>
> > ex. Look at how GCC generates jump tables for switch() when there's
about
> > 10-12 (or more) case's sparsely scattered in the rage from 0 through
255.
>
> You are comparing with very expensive jump operations its an unusual
> case. For the majority of situations the TLB/cache overhead of misses
> vastly outweighs the odd clock cycle gained by verbose output.
>
>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kernel optimization

2005-07-23 Thread Alan Cox
On Sad, 2005-07-23 at 02:30 -0400, [EMAIL PROTECTED] wrote:
> Larger does not always mean slower.  If it did, nobody would implement a
> loop unrolling optimization.

Generally speaking nowdays it does. Almost all loop unrolls are a loss
on PIV.

> ex. Look at how GCC generates jump tables for switch() when there's about
> 10-12 (or more) case's sparsely scattered in the rage from 0 through 255.

You are comparing with very expensive jump operations its an unusual
case. For the majority of situations the TLB/cache overhead of misses
vastly outweighs the odd clock cycle gained by verbose output.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kernel optimization

2005-07-23 Thread Simon Strandman

christos gentsis skrev:



so if i want to play with and see what happens i have to change it 
manually in each make file... good i may create a kernel like that to 
see what will happens (just for test) ;)


thanks
Chris

Just edit the top level Makefile and add your custom CFLAGS there. But 
you are risking the stability of your system and don't expect it to be 
faster.


--
Simon Strandman <[EMAIL PROTECTED]>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kernel optimization

2005-07-22 Thread cutaway
- Original Message - 
From: "Adrian Bunk" <[EMAIL PROTECTED]>
To: "christos gentsis" <[EMAIL PROTECTED]>
Cc: 
Sent: Friday, July 22, 2005 16:14
Subject: Re: kernel optimization
>
> It's completely untested.
> And since it's larger, it's also slower.

Larger does not always mean slower.  If it did, nobody would implement a
loop unrolling optimization.

ex. Look at how GCC generates jump tables for switch() when there's about
10-12 (or more) case's sparsely scattered in the rage from 0 through 255.
It generates a 256 element directly indexed jump table (obviously with many
duplicate entries).  This is faster than a cascaded if/else
construct(particularly for those that would have been on the end of the
if/else chain), but it is a very large construct.  You'll see some of these
"plump" switches generated in various SCSI drivers and in the VT102
emulation if you disassemble them.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: kernel optimization

2005-07-22 Thread Al Boldi
 Adrian Bunk wrote: {
On Fri, Jul 22, 2005 at 07:55:48PM +0100, christos gentsis wrote:
> i would like to ask if it possible to change the optimization of the 
> kernel from -O2 to -O3 :D, how can i do that? if i change it to the 
> top level Makefile does it change to all the Makefiles?
And since it's larger, it's also slower.
}

It's faster but it's flawed.  Root-NFS boot failed!

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kernel optimization

2005-07-22 Thread christos gentsis

Adrian Bunk wrote:


On Fri, Jul 22, 2005 at 07:55:48PM +0100, christos gentsis wrote:

 


hello
   



Hi Chris,

 

i would like to ask if it possible to change the optimization of the 
kernel from -O2 to -O3 :D, how can i do that? if i change it to the top 
level Makefile does it change to all the Makefiles?
   



search for the line with
 CFLAGS  += -O2
and change this to -O3.

This works for most Makefile's except for the one's that manually
set -Os.

 

And let's say that i change it... does this generate any problems with 
the space that the kernel will take? (the kernel will be much larger)
   



It's completely untested.
And since it's larger, it's also slower.

 


Thanks
Chris
   



cu
Adrian

 

so if i want to play with and see what happens i have to change it 
manually in each make file... good i may create a kernel like that to 
see what will happens (just for test) ;)


thanks
Chris

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kernel optimization

2005-07-22 Thread Adrian Bunk
On Fri, Jul 22, 2005 at 12:52:22PM -0700, David Lang wrote:

> This is a airly frequent question
> 
> the short answer is 'don't try'
> 
> the longer answer is that all the additional optimization options that are 
> part of O3+ are considered individually and if they make sense for the 
> kernel they are explicitly enabled (in some cases the optimizations need 
> to be explicitly turned off for proper functionality of the kernel under 
> all versions of GCC)

As far as I can see, none of the additional optimizations with -O3 is 
enabled in the kernel.

> David Lang

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kernel optimization

2005-07-22 Thread Adrian Bunk
On Fri, Jul 22, 2005 at 07:55:48PM +0100, christos gentsis wrote:

> hello

Hi Chris,

> i would like to ask if it possible to change the optimization of the 
> kernel from -O2 to -O3 :D, how can i do that? if i change it to the top 
> level Makefile does it change to all the Makefiles?

search for the line with
  CFLAGS  += -O2
and change this to -O3.

This works for most Makefile's except for the one's that manually
set -Os.

> And let's say that i change it... does this generate any problems with 
> the space that the kernel will take? (the kernel will be much larger)

It's completely untested.
And since it's larger, it's also slower.

> Thanks
> Chris

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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: kernel optimization

2005-07-22 Thread David Lang

This is a airly frequent question

the short answer is 'don't try'

the longer answer is that all the additional optimization options that are 
part of O3+ are considered individually and if they make sense for the 
kernel they are explicitly enabled (in some cases the optimizations need 
to be explicitly turned off for proper functionality of the kernel under 
all versions of GCC)


David Lang

On Fri, 22 Jul 2005, christos gentsis wrote:


Date: Fri, 22 Jul 2005 19:55:48 +0100
From: christos gentsis <[EMAIL PROTECTED]>
To: linux-kernel@vger.kernel.org
Subject: kernel optimization

hello

i would like to ask if it possible to change the optimization of the kernel 
from -O2 to -O3 :D, how can i do that? if i change it to the top level 
Makefile does it change to all the Makefiles?


And let's say that i change it... does this generate any problems with the 
space that the kernel will take? (the kernel will be much larger)


Thanks
Chris

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



--
There are two ways of constructing a software design. One way is to make it so 
simple that there are obviously no deficiencies. And the other way is to make 
it so complicated that there are no obvious deficiencies.
 -- C.A.R. Hoare
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/