# Increasing kernel efficency

## Dralnu

Ok, I just upgraded my kernel. Great feeling when you hit enter after typing in make, then reboot into a working enviroment, ain't it?

Ok, well, I was configuring my system (havn't done that in ages. Normally I cp ../linux_prior/.config ./   then make, but this time I went ahead and ran through the menuconfig, and got to thinking:

Are there any ways to make the kernel more efficent?

I'm wondering if anyone knows of any tips/tricks to make it more efficent, faster, what have you, and maintain the same stability.

Info:

I'm running the Gentoo Sources, and I'm trying to keep it minimal as far as what is in it, but I'm not sure if there is anything else I could do other then mess with CFLAGS/LDFLAGS (neither of which I think would be a good idea on something so system-critical).

----------

## cokey

 *Dralnu wrote:*   

> Ok, I just upgraded my kernel. Great feeling when you hit enter after typing in make, then reboot into a working enviroment, ain't it?

 no, you get very used to it  :Wink: 

 *Dralnu wrote:*   

> Ok, well, I was configuring my system (havn't done that in ages. Normally I cp ../linux_prior/.config ./   then make, but this time I went ahead and ran through the menuconfig, and got to thinking:
> 
> Are there any ways to make the kernel more efficent?

 depends what you think of as "more efficient". Faster? Smaller? More manageable?

 *Dralnu wrote:*   

> I'm wondering if anyone knows of any tips/tricks to make it more efficent, faster, what have you, and maintain the same stability.

 

Info:

 *Dralnu wrote:*   

> I'm running the Gentoo Sources, and I'm trying to keep it minimal as far as what is in it, but I'm not sure if there is anything else I could do other then mess with CFLAGS/LDFLAGS (neither of which I think would be a good idea on something so system-critical).

 CFLAGS... Nothing really apart from error flags like -Wall and -Werror

LDFLAGS? No, you're not linking to anything

----------

## Dralnu

 *cokehabit wrote:*   

>  *Dralnu wrote:*   Ok, well, I was configuring my system (havn't done that in ages. Normally I cp ../linux_prior/.config ./   then make, but this time I went ahead and ran through the menuconfig, and got to thinking:
> 
> Are there any ways to make the kernel more efficent? depends what you think of as "more efficient". Faster? Smaller? More manageable?

 

Faster and, if possible, more managable, but faster is my main thing. I just want to see what I can get it to do  :Smile: 

----------

## erik258

I have a pentium-mmx 166 and i would love to hear some ways to tweak this thing.  mostly, i would really like to know if i can speed up the boot/shutdown process and decrease memory usage.

----------

## cokey

 *Dralnu wrote:*   

>  *cokehabit wrote:*    *Dralnu wrote:*   Ok, well, I was configuring my system (havn't done that in ages. Normally I cp ../linux_prior/.config ./   then make, but this time I went ahead and ran through the menuconfig, and got to thinking:
> 
> Are there any ways to make the kernel more efficent? depends what you think of as "more efficient". Faster? Smaller? More manageable? Faster and, if possible, more manageable, but faster is my main thing. I just want to see what I can get it to do 

 As a rule of thumb for kernels smaller is faster and more efficient. Take a look through your .config and look for all those modules and build them in (a quick grep is good for that because it is an uppercase M). Then look through and have a look at everything that you don't have and take it out. 3/4 of it will be unneeded and the best place to start is with hardware; you should know what you have so go and take out all the onboard sound and graphics cruft that you dont have. There is usually stuff that you dont use like V4L (video for linux) and others.

Get rid of that and your kernel will be smaller and faster and because of the lack of rubbish it will be very manageable.

----------

## cokey

 *erik258 wrote:*   

> I have a pentium-mmx 166 and i would love to hear some ways to tweak this thing.  mostly, i would really like to know if i can speed up the boot/shutdown process and decrease memory usage.

 for boot and shutdown speed the best way to speed it up is to take all the unneeded stuff out of boot. You can add some to default and plainly just delete the ones that you use rarely because you can start them manually.

Have a look at other init systems because sysvinit is slow and rather tiresome, there is a good wiki guide on initng here:

http://gentoo-wiki.com/HOWTO_Initng

http://en.wikipedia.org/wiki/Initng

Newer init systems allow parallel processes to run at startup

----------

## erik258

i already did ; ( unfortunately, i am not quite sure how to verify how good a job i did.  

perhaps you have a suggestion?  

i also run an uberlightweight wm (pwm)

i use vesafb because it looked like Chips & Technologies FB support expired in the 2.6 kernels.  

my biggest problem is that Firefox is really slow.  but it runs acceptably.  I wish i had a better option (links/fb sdl? )

any thoughts?

----------

## erik258

```
           alsasound |                               

            bootmisc | boot                          

             checkfs | boot                          

           checkroot | boot                          

               clock | boot                          

         consolefont | boot                          

         crypto-loop |                               

               cupsd |                               

          domainname |                               

                famd |                               

                 gpm |                               

              hdparm |                               

            hostname | boot                          

             hotplug |                               

           ip6tables |                               

            iptables |                               

                irda |                               

              isapnp |                               

             keymaps | boot                          

               local |      default nonetwork        

          localmount | boot                          

             modules | boot                          

            net.ath0 |      default                  

            net.eth0 |                               

              net.lo | boot                          

            net.ppp0 |                               

            netmount |                               

                 nfs |                               

            nfsmount |                               

                nscd |                               

             numlock |                               

              pcmcia |      default                  

             portmap |                               

           pure-ftpd |                               

           rmnologin | boot                          

              rsyncd |                               

              serial |                               

                sshd |                               

           syslog-ng |      default                  

          typescript |                               

             urandom | boot                          

                wlan |                               

                 xdm |                               

                 xfs |                               

              xprint |
```

for what might i need such services as ... 

urandom rmnologin (?) modules*  localmount (?) bootmisc (?) pcmcia (?)

* i have some modules i need on boot, for madwifi-ng.  others, for dialup.  and more for usb and pcmcia.  if i use this slow laptop, almost certainly gonna be using pcmcia.  but the others ... and the module dependancy step takes longer than just about anything on boot.  I should remove that one if possible ; )

i suppose i could remove consolefont

----------

## cokey

using a lightweight wm isn't going to affect anything. Gnome on mine starts up in less than a second. Have you tried changing what scheduler you use? I can imagine that you are using the Genetic Anticipatory scheduler. Try the preemptive scheduler, cfq or deadline instead.

----------

## cokey

 *erik258 wrote:*   

> 
> 
> ```
>            alsasound |                               
> 
> ...

 yeah, there is nothing there there is really worth removing really. Why do you need the modules? are they not part of the kernel?

----------

## erik258

it makes a big difference when you have 96 megs of ram ; )  actually, i have nothing to compare it to.  but it compiles thousands of times faster literally.  i just don't ask for much from a wm. 

moving on to your interesting ideas... 

i'm running 2.6.11 -- do you think i should upgrade?  (It takes a little while, so im lazy about it ; ) 

I Have preemptible kernel (& the big kernel lock) but don't have low latencey desktop as an option.  I actually already have DEADLINE installed ; ) i musta read the help on that one.  

Can I make it any faster? Or have i maxed it out?

----------

## cokey

 *erik258 wrote:*   

> it makes a big difference when you have 96 megs of ram ; )  actually, i have nothing to compare it to.  but it compiles thousands of times faster literally.  i just don't ask for much from a wm. 

 good point

 *erik258 wrote:*   

> i'm running 2.6.11 -- do you think i should upgrade?  (It takes a little while, so im lazy about it ; ) 

 yes, i would if i were you. Don't forget to take out all unneeded cruft that you will never use.

 *erik258 wrote:*   

> I Have preemptible kernel (& the big kernel lock) but don't have low latencey desktop as an option.  I actually already have DEADLINE installed ; ) i musta read the help on that one.  

 try the cfq for me, plenty of people say their desktop becomes more responsive with it

 *erik258 wrote:*   

> Can I make it any faster? Or have i maxed it out?

 there are always little things to make your desktop faster  :Wink:  try adding 

```
-fomit-fame-pointer -funroll-loops
```

to your CFLAGS

----------

## erik258

for modules like ppp, they're kb worth but i hardly ever use them.  i have no dialup account (but now that i have modem working i think, maybe after 6th ring i should have a computer pick up ; ) 

for wireless, it's madwifi-ng for wireless and isn't part of gentoo-sources.  so i can't actually compile them in?

what about the settings in the newer kernels, like 'compile for size' ?  

or the 'configure for small systems' stuff?

----------

## cokey

 *erik258 wrote:*   

> what about the settings in the newer kernels, like 'compile for size' ?  
> 
> or the 'configure for small systems' stuff?

 i can imagine that any settings in the kernel designed for high latency desktops would be beneficial to you

Is this box critical? You could try some CFLAGS that might help

----------

## Dralnu

 *cokehabit wrote:*   

>  *Dralnu wrote:*    *cokehabit wrote:*    *Dralnu wrote:*   Ok, well, I was configuring my system (havn't done that in ages. Normally I cp ../linux_prior/.config ./   then make, but this time I went ahead and ran through the menuconfig, and got to thinking:
> 
> Are there any ways to make the kernel more efficent? depends what you think of as "more efficient". Faster? Smaller? More manageable? Faster and, if possible, more manageable, but faster is my main thing. I just want to see what I can get it to do  As a rule of thumb for kernels smaller is faster and more efficient. Take a look through your .config and look for all those modules and build them in (a quick grep is good for that because it is an uppercase M). Then look through and have a look at everything that you don't have and take it out. 3/4 of it will be unneeded and the best place to start is with hardware; you should know what you have so go and take out all the onboard sound and graphics cruft that you dont have. There is usually stuff that you dont use like V4L (video for linux) and others.
> 
> Get rid of that and your kernel will be smaller and faster and because of the lack of rubbish it will be very manageable.

 I try to keep it minmal as far as what I have in it. I've got things like Vesa/VGA in there for back-up/in case its useful, but the majority of it I mess with some to see what it does. Sometimes the helpfiles that come with everything in there don't always help  :Wink: 

I don't use modules - compiling right in keeps things from becoming annoying when modules foo needed by bar isn't in there, and bar complains and I have no clue what is going on.

Somewhere before my post someone mentioned settings about desktop latency and whatnot. What kind of settings are there that I might be missing that could affect the speed of my system as far as these go? (I know one was a Mhz setting I buped up to 1k, but I forgot what it was exactly).

----------

## erik258

critical?  oh god no!  it's my laptop.  my only laptop ... if i can indulge in a brief synopsis, it was aquired when i helped a friend solder together a device to read from some EEPROM in a dell with a hard drive that for some reason related to the security related to the EEPROM we couldn't wipe.  It used to be running '98; now it's runnig a current OS with, well, everything i need.  I love it to death, if i can say that half seriously here ; )

on the other hand the firefox is old.  it was compiled with -03 

this is apple.com but...

 *Quote:*   

> -funroll-loops
> 
>     Unroll loops whose number of iterations can be determined at compile time or upon entry to the loop. -funroll-loops implies both -fstrength-reduce and -frerun-cse-after-loop. This option makes code larger, and may or may not make it run faster. 

 

I think the memory usage may or may not be worth the exchange ... maybe if the rest of it could be optimized ...

----------

## cokey

-funroll-loops makes binaries bigger (not good in your low memory box) but that means they act faster so compiling anything that is going to stay in memory and not be swapped will be better compiled with that.

I'd play around with some loops: 

```
-floop-optimize2

-fsched2-use-traces

-funsafe-loop-optimizations

-Wunsafe-loop-optimizations
```

the last one there will give you a warning if anything is going wrong

----------

## erik258

sweet ; ) now we're talking.

----------

## cokey

 *erik258 wrote:*   

> sweet ; ) now we're talking.

 It would be good to know how you get on with this. Have you tried the cfq scheduler?

If you see a -f (function) CFLAG have a look to see if there is a -W (warning flag) to go with it, that way you will see any likely errors. Some will mean nothing because they are just warnings and not errors but it is good to know

----------

## erik258

So far this little thing has managed to sync its portage tree, remerge portage (which required an update to sandbox,bash,and 2 others), and emerge/configure the kernel.  now it's compiling.  

don't worry, i'll keep you updated ; )

----------

## cokey

 *erik258 wrote:*   

> So far this little thing has managed to sync its portage tree, remerge portage (which required an update to sandbox,bash,and 2 others), and emerge/configure the kernel.  now it's compiling.  
> 
> don't worry, i'll keep you updated ; )

 you helped push through an idea of mine: https://forums.gentoo.org/viewtopic-t-523721.html

----------

