# [HOWTO] Flying with gentoo

## asph

HOW TO OPTIMIZE AND ACCELERATE YOUR SYSTEM

also known as how to fly with gentoo

This is guide is a sum of a lot of posts here in the forum and some investigations i have done in my boxes by trying out several programs and options. Some of them are completely safe, but some other could damage your system. Please make backups of your important data, try this guide in testing boxes, and then move the optimizations to the production boxes.

This improvements will obviously have a greater effect on a old computer, if you have a very good computer this will have a minor impact, as your system should already be pretty fast  :Wink: 

INDEX

0. How to make tests without being in danger

1. Optimization of the init scripts

2. Using rc-update

3. Cflags and ldflags

4. Using hdparm

5. Should you.. prelink?

6. Managing the Swap

7. Ccache

8. Distcc

9. USE's

10. Modifying ebuilds and injecting packages

11. Halt vs Suspend

12. Xdelta - Deltup

13. NPTL

14. GCC

15. Filesystems [data safety vs speed]

16. i/o and tasks schedulers

17. Useful Scripts

18. New tips

0. How to make tests without being in danger

To test new ebuilds and try new configurations I did an instalation inside a chroot to be completely safe. There's is a guide HERE to make a similar thing, and be able to test this howto without damaging your system. You could also use vmware or uml, but this seems a fastest way.

Once I did the chroot install, I made a compressed image, so that everytime I broke the sub-system with my tests i can extract it and go on testing with a new installed system (and my system keeps clean).

1. Optimization of the init scripts

Some of the operations performed when you boot the system are not always needed. Let's modify the scripts so that we only do them if they are really needed.

/etc/init.d/modules

change:

```
ebegin "Calculating module dependencies" 

    /sbin/modules-update &>/dev/null 

eend $? "Failed to calculate dependencies" 

```

for:

```
if [ /etc/modules.d -nt /etc/modules.conf ]

    then 

        ebegin "Calculating module dependencies" 

        /sbin/modules-update &>/dev/null 

        eend $? "Failed to calculate dependencies" 

    else

        einfo "Module dependencies are up-to-date"

fi 

```

Doing this, modules-update will only run if it´s really needed because you made changes in the system.

/etc/init.d/localmount

change:

```
mount -at nocoda,nonfs,noproc,noncpfs,nosmbfs,noshm >/dev/null
```

for:

```
mount -aFt nocoda,nonfs,noproc,noncpfs,nosmbfs,noshm >/dev/null
```

The will start all the local mounts at the same moment, not one after the other.

/etc/init.d/bootmisc

change:

```
if [ -x /sbin/env-update.sh ] 

then 

    ebegin "Updating environment" 

    /sbin/env-update.sh >/dev/null 

    eend 0 

fi
```

for:

```
if [ -x /sbin/env-update.sh ] 

then 

    if [ /etc/env.d -nt /etc/profile.env ] 

    then 

        ebegin "Updating environment" 

        /sbin/env-update.sh >/dev/null 

        eend 0 

    else

        einfo "Environment up-to-date"

    fi 

fi
```

Doing this, env-update will only run if it´s really needed because you made changes in the system.

/etc/conf.d/rc

change:

```
RC_PARALLEL_STARTUP="no"
```

for:

```
RC_PARALLEL_STARTUP="yes"
```

This will start all the services at the same moment, not one after the other.

note: could some devel explain if this tweaks are dangeorus, and if not why they are not in portage by default?

2. Using rc-update

Managing the runlevels is very easy thanks to rc-update, that makes easy this job:

to see how we have currently configured the boot runlevels:

```
# rc-update show
```

to remove a service from the system start:

```
# rc-update del aplicacion runlevel
```

note: change runlevel for boot or default (you could also create more), if you omit the runlevel it will search in all of them and remove the service.

to add an application:

```
# rc-update add application runlevel
```

I have some service in the boot runlevel and some in the default runlevel, please note that some services need to be started after some other (this means that some services depends on some other. 

You can check the depends editing the /etc/init.d/service file and checking the first lines, where the depends are declared. For example, if you want to start sshd, you will need the net services started before.

I have recently created a new runlevel (battery) where i added all i want to have running when i don´t have AC. Then, with acpid's help I configured the runlevel so that when i unplug the AC, it changes to battery runlevel, and the when i plug it again it gets back to default runlevel. This way, when I switch to the battery level i use speedfreq, hdparm and iwconfig to reduce the power consumption of the hardisk, the wireless card and the processor.

You can check the actual runlevel using rc-status:

```
# rc-status

Runlevel: battery

acpid                                          started

alsasound                                      started

domainname                                     started

gpm                                            started

hdparm.battery                                 started

local                                          started

metalog                                        started

speedfreq.battery                              started

vixie-cron                                     started

wireless.baterry                               started
```

more information about the RC- HERE.

For those who boot directly into X (xdm, gdm, kdm,..) i have read that you can put xdm and it's dependencies in boot runlevel, so that it will load X while loading the rest of services in the background. If someone have this running please comment so that the rest can use it.

3. cflags and ldflags

CFLAGS (you can set them at /etc/make.conf) are parameters we pass to gcc when we compile a package when emerging it. You can be more or less risky here, in THIS webpage and THIS one there is a lot of info on recommended configurations for CFLAGS. My CFLAGS for my pentium4 box are the following:

```
CHOST="i686-pc-linux-gnu"

CFLAGS="-march=pentium4 -mcpu=pentium4 -O3 -pipe -fforce-addr -falign-functions=4 -fprefetch-loop-arrays -fomit-frame-pointer"
```

note: cflags changed a little bit in gcc 3.4.X and -mcpu is deprecated, you should use -mtune instead. Moreover, pentium-m is accepted for centrino laptops. The CFLAGS of my centrino laptop are the following:

```
CFLAGS="-O3 -march=pentium-m -mtune=pentium-m -pipe -ftracer -fomit-frame-pointer -ffast-math -momit-leaf-frame-pointers"
```

As for the CXXFLAGS, -fvisibility-inlines-hidden has been reported as a good flag to improve the C++ compiles (thx teutzz).

Frepo has also been reported as a good cxxflag, but it does not perform very well on my system.

The ldflags are also interesting, they are discussed HERE and HERE. Ldflags are optimizations for the dinamyc loader (ld), so it's more or less the same way prelink would go. I am using them already and didn't have any problem when emerging new packages:

```
LDFLAGS="-Wl,-O1 -Wl,--enable-new-dtags -Wl,--sort-common -s"
```

Something more "stable" would be 

```
LDFLAGS="-Wl,-O1"
```

note: those in the ldflags are "L", not "1" (in the -W)

note: some users reported errors using ldflags, if you have problems compiling a package try to remove them (and post ldflags/package in this thread).

NOTE: Cflags and Ldflags are and will be always a subject in which everybody has his opinion. The best way is to test them yourself, do somebenchmarks, and keep the flags you find optimal for your system. Also check the differents posts in the forums talking about this so that you can get an idea. A useful program to determine what cflags you should use, is ACOVEA (already in portage), which is a benchmarking tool that will do several tests on your machine (the standard test will run for more than 15 hours) to help you pick the best cflags for your machine. See THIS thread for acovea scripts and results.

4. Using hdparm

Another important application is hdparm. It allows us to configure our hard disk parameters, so get the maximum performance:

```
# emerge hdparm

# rc-update add hdparm default
```

See /etc/conf.d/hdparm

see actual configuration:

```
# hdparm -i /dev/hda
```

testing the speed:

```
# hdparm -Tt /dev/hda
```

In my computer I modifified /etc/conf.d/hdparm to get the maximum of my hard disk:

```
hda_args="-d1 -X69 -c1"

cdrom0_args="-d1"
```

If you need more information the man page is pretty good

```
# man hdparm
```

Also check THIS for a little tutorial.

5. Should you.. prelink?

Prelink is a powerful application, it allows us to pre-link the libraries needed for a binary before using it. So instead of looking for which libraries the binary will need when we launch it, prelink will modify the binary addind a little descriptions of the libs it nees to run. This get rid of the search for shared libraries everytime we launch the binary, so it makes it faster.

Important: Everytime that you upgrade the libraries that are needed for the binaries, (for example glibc) you have to re-run prelink on the system.

This is a little optimization that we will thank when launching big applications like KDE (moreover, if you prelink your system KDE will not need to launch kdeinit, so it will also run faster). The little binaries are already pretty fast, so will not appreciate the difference.

Requirements: it is a must to have compiled the binaries with binutils-2.13.90.0.xx and gcc-3.2 or higher, and also have installed glibc-2.3.1-r2 or higher. The size of the binaries will be bigger with prelink, and to run the process you need enough free space on the hard disk.

Way to go:

```
# emerge prelink
```

Find config file at /etc/prelink.conf

```
# prelink -afmR
```

This is the common use of prelink, that will prelink ALL the binaries, and also will look if the binaries were already prelinked, and prelink them again if needed.

It is possible that you get some errors when running prelink, because some binaries can not be prelinked (the ones compressed with upx, for example).

More information HERE, and/or man prelink.

6. Managing the swap

In this section I just wanted to mention some things that can help us.

First of all, if you have two harddisks it is better to put the swap partition on the second disk (having the root partition in the first one) as this will improve the read/write times.

Also you should NOT use a file as swap. I tried it once in an old computer, deleted the swap partition and set a file as ./swap of 256 MB.¡ and modified fstab. This method is slower, as it has to find the file, open the file, find were it was writting to it, writte to it, save, and close the

file. With a partition in the disc this process is pretty much faster.

Another concept to know about is swappiness (kernel 2.6+). When an application needs memory and the RAM is full, there are two options: or the RAM gets empties a little bit cleaning out old used memory, or swap memory gets used (slower than ram). In the new kernels, you can set a variable to define if the kernel should empty some ram or use the swap partition.

/etc/sysctl.conf

```
vm.swappiness = 40
```

This value can be between 0 and 100. Close to 0 will mean that the kernel should empty some ram, and a higher value close to 100 will tell the kernel to use the swap memory more often.

The default value is 60. I set this to 25 in my laptop, so that i can reduce the disk access. You can use ´free -m´ to see the stats of your memory useage.

7. Ccache

ccache is an application (included en portage and on by default when emerging (if you emerge ccache)) that acts as a cache for the compiler.

With this little prog we will be able to compile in a faster way when compiling packages, specially with the big make's (you could think that using a cache when compiling has no use, but it speeds up some instructions like the make clean)

Just emerge it and set the default cache size (read the einfo after the emerge), and it will be on by default. You can check it with:

```
# emerge info | grep ccache

ccache version 2.3 [enabled]
```

You can check the ccache stats by doing:

```
# ccache -s
```

8. Distcc

distcc is an application that will make our life easier when installing gentoo in several computers, or if our computer is very slow but have another fast computer. It can be combined with ccache, optimizing the compiling time. I won't explaint this

feature a lot, because it's not used by everyone. Just that you know about it, because you can use cross-compiling with different computers with different processors, they will just share the compiling tasks. 

More information HERE.

9. USE's

The USE flags are a useful tool that gentoo provides us with to configure our packages as we want them.

For example, imagine that you want to compile apache:

```
# emerge -pv apache

[ebuild N ] net-www/apache-2.0.50 -debug -doc -ipv6 +ssl 6,197 kB
```

The (+/-) options that appear after the name of the program we are going to install (-v flag) are the USE vars we can use to configure the package we are installing. If, for example, we don't want our apache to use ssl, we can do this:

```
# USE="-ssl" emerge -pv apache

[ebuild N ] net-www/apache-2.0.50 -debug -doc -ipv6 -ssl 6,197 kB
```

We can see that ssl is now off, and apache won't be compiled with ssl support.

In this example we set the USE var directly on the propmt, but this is not the correct way to do it if you want the system to remember the USE flags everytime you compile that package. You can set your USE flags in the /etc/make.conf file, or also use /etc/portage/package.use to set them for

individual packages.

It is the same for the "x86" flag (to tell portage to use the latest version available of every package), it's not recommended to just set the flag on the prompt, you should set it on /etc/make.conf to use it for all the packages, or set it individually:

```
# echo "app-editors/nano ~x86" >> /etc/portage/package.keywords
```

It is important to take a look at the USE flags of the packages before installing them, so that we can turn off features we won't be needing saving space and sometimes dependencies.

For example, if we want to emerge the console irc client BitchX, portage want to install xmms, X, and some other dependencies that could be useless for some of us. Setting -xxms and -X for xmms in the /etc/portage/package.use will allow us to install BitchX without the xmms and X support, and we won't need to install all those packages.

You can see that this is a powerful tool to use when emerging, it gives us a lot of control of how the packages will be installed in our system.

You have a little description of the USE flags in /usr/portage/profiles/use.desc

10. Modifying ebuilds and injecting packages

Always keep a backup of your files before modifying them (also note that emerge sync will fix if you mess an ebuild).

¿What's injecting a package and what's the use of it?

Remember that time when you wanted to install package X, and as a dependency portage asked to install package Y? For example, a lot of users manage the kernel manually instead of using portage to do it (gentoo-sources, gentoo-dev-sources, vanilla-sources, and so on). Then, when you emerge some package that needs the kernel-sources (like alsa, or ipw2X00) installed portage will try to install some kernel-sources. Why would you do that if you already have your kernel at /usr/src?

note: injecting has been deprecated, now you should use package.provided and virtuals as explained

- using package.provided:

package.provided tells portage that a package is installed (even if it's not)

You can use this file to put all the packages you want to tell portage you installed by hand.

```
echo "sys-kernel/ck-sources" >> /etc/portage/profile/package.provided
```

package.provided doesn't affect virtuals, virtuals are used to tell portage what packages should install for a given category:

For example, you could tell portage that you want to satisfy x11 with xorg, and not xfree anymore (which is not a valid example anymore, but it is useful to understand the use of it)

```
echo "virtual/x11 x11-base/xorg-x11" >> /etc/portage/profile/virtuals
```

more information on this and /etc/portage management -> man portage

11. Halt vs Suspend

Have you never asked yourself why you shutdown you computer, when you can suspend it to ram or disk?

If you suspend to ram, it has the handicap that it will still need AC input in order to keep the system alive. But suspending to disk is very useful (specially for laptops), because the laptop will "shutdown", but we will keep our sesion.

Doing it this way we avoid to boot all the system services everytime (it not an instant recuperation from the "sleep", but seems faster).

I have used swsusp2 in my laptop and works fine, but you have to patch the kernel sources. You can find info in THIS post on how to do this. Try it and you won't regret.

12. Xdelta - Deltup

In THIS post Deltup is discussed, because a new version is available. The point is that everytime portage needs to download a file, deltup will look for an older version of the file (/usr/portage/distfiles) and try to download only the

difference between the two files, and create the new file on-the-fly.

This can be a big improvement for all those 56k users who keep their /usr/portage/distfiles in order to only download patches when new "revisions" are released, because this can lower the mb to download everytime they want to emerge new versions of the installed packages.

13. Native POSIX Thread Library

This library, know as NPTL, can improve our system, because it's up to 4 times faster than the standard LinuxThreads when creating new threads. You *should* use 2.6 linux headers, and a new version of glibc and gcc (~x86). To use ntpl you just have to recompile glibc with the USE flag

"nptl" turned on.

note: in order to use nptl you need gcc 3.x or higher installed.

HERE you can get more information and benchmarkings.

14. GCC

GCC is very important, specially in a distro like gentoo in which the users look to optimize their system by compiling theirselves the packages they install. Using an actual version of gcc has some advantages, because all the code we create when compiling will be more optimized (from version 3.4.x you can already use the -march=pentium-m for the centrino

processors).

To install the latest gcc, just emerge gcc with ~x86 turned on (rmember to change your profile also):

```
# echo "sys-devel/gcc ~x86" >> /etc/portage/package.keywords

# emerge -u gcc
```

15. Filesystems [data safety vs speed]

After trying out some filesystems, i use reiser4 because it's the fastest filesystem available. I think that it is very useful to use a fast filesystem, but you have to keep backups of your data just in case you have corruption issues.

Also point that, after using ext2, ext3, reiserfs, xfs, reiserfs and som other encripted filesystems i have never had corruption issues with my data. Just keep backups of your data and you will be all set.

Note that you need a version of the kernel with the reiser4 patches, so it will have to be a development patched release.

To convert your / partition to reiser4 you will need a livecd with reiser4 support like THIS one, and install a kernel with that support also.

NOTA: Some people have problems because they can't find the Reiser4 submenu in the Filesystems tree of the kernel, make sure that you have deactivated the option "use 4kb for kernel stacks instead of 8kb) under the kernel hacking submenu, and then you will find the Reiser4 option.

16. i/o and tasks schedulers

coming soon

17. Useful Scripts and tips

There are some useful scripts in the forums and the portage tree to manage our system:

1- esearch

This one is included in the portage tree (you can just emerge esearch), and it's an utility to search trought the portage package database. The good thing is that it's very fast (faster than emerge -sS).

Note that after every emerge sync we have to update de esearch database by running eupdatedb, or you can just use esync to update the portage tree (esync will emerge sync, and then show a list with the changes (new packages) from the last sync).

2- eix

The same concept as esearch, but it's faster (and it is also faster to update the package database).

It's a young project, but works pretty fine.

More info HERE.

3- Cruft

This script from will generate a list with all the files in our system that could be deleted because they don't belong to any installed package. You have to be careful when using it, because it can generase false positives.

Usage:

```
# ./cruft > cruft.log
```

Then you can check the list, and remove from it the files you want to keep.

Then you can run this command to get rid of the files:

```
# cat cruft.log | xargs rm -rf
```

You could also just take a look at the list and delete them yourself.

More info HERE.

4- Stale

Interesting script that will help us to keep /usr/portage/distfiles with an optimal size. The script will search in that dir, and delete (when invoked with the --nopretend option) the old files, not the actual ones.

For example, if we have libtool-1.3.5.tar.gz and libtool-1.5.2.tar.gz, it would delete libtool-1.3.5.tar.gz 

It gets messed with files like font-arial-iso-8859-1 and font-arial-iso-8859-2, in which the numeration doesn't not correspond to the versioning of the package (the same with gtk and glib in their versions 1.x and 2.x)

More info HERE.

5- Porthole

Portage frontend made in python (+gtk), that offers us a visual way to configure portage, and it makes easier to configure the packages and emerges. It's already in portage, so you just have to "emerge porthole".

6- kuroo

Another portage frontend, this one is made with Qt (for the kde-lovers). It's a young project, but works fine.

More info HERE.

You can also find more useful scripts and programs related to Portage in THIS thread.

7- portage cdb

This is not a script itself, but it's a nice tip to improve the portage speed. Try it, you wont be disappointed!

8- mounting / in ram

very nice article, worth a read  :Smile:  https://forums.gentoo.org/viewtopic-t-296892.html

18. New tips (xdarma)

1- Kernel 2.6 performance tips (link)

2- KDE performance tips (link)

-under construction-

----------

## Naib

Sweet, 

Just did the changes to teh /etc scripts. Not going to do the others but look usefoul for ppl interested in them

----------

## teutzz

 *nastassja wrote:*   

> 
> 
> ```
> CHOST="i686-pc-linux-gnu"
> 
> ...

 

1. -mcpu / -mtune preceded by -march implies -mcpu / -mtune (and everything that goes with it)

2. -falign-functions=4 actually slows you down a bit because your 1st level cache even that is used maybe a little more efficient it actually loads with data slower (even microsoft uses -falign-functions=16 even from the pentium-pro era) (for athlon and up a -falign-functions=64 would be more appropriate even that it does more or less of a diffrence; for intel (and i can be mistaken) maybe a value of 32 would suite)

3. when mentioning gcc-3.4 don't forget the -fvisibility-inlines-hidden cxxflag

4. -O3 does your binaries quite large and when it comes to desktop usage using -O2 may be more appropiate (faster program loading)

5. there are quite a few more cflags that can give more than a not notiable performance boost: -momit-leaf-frame-pointers -ffast-math etc

6. don't forget mentioning the diffrent kernel sources and diffrent i/o and tasks schedulers

----------

## galay2

excellent guide!! However, I'm particularly interested in your hdparm tweak. How did you come up with the optimizations? Is there a guide somewhere? The man page does provide a load of options, but I would imagine you tested it in a systematic way?

----------

## Deranger

Great HOWTO, got some valuable tricks from it  :Razz: Last edited by Deranger on Wed Nov 17, 2004 11:05 am; edited 1 time in total

----------

## asph

thanks for the comments teutzz, i'll consider that when updating the guide

glad you like it, I will work on it as it still needs some improvements  :Smile: 

galay: about the hdparm, the man page explains every option you can use.. using dma is really a boost, and also udma5 if your harddrive supports it (you can check with hdparm /dev/hda).. i also read a deep manual of hdparm, i'll post the link later.

----------

## Trevoke

HOT DAMN!

SWEET!

THUMBS UP!

Ok.. I'm killing the caps.. But.. Nice!

----------

## bladdo

Awsome Nice job! I expecially like porthole , very dandy but I wish you could just run it and then when you went to emerge something you could type in the root passwd like in gnome-system-tools.

----------

## mfkr79

Very interesting, especially LDFLAGS & Optimization of the init scripts that sound new to me

As I boot directly into X, I put xdm and his dependency into the boot runlevel, and noticed a little faster startup, maybe due more to the changes in the init-scripts

Thank you nastassja   :Very Happy: 

----------

## teutzz

 *nastassja wrote:*   

> galay: about the hdparm, the man page explains every option you can use.. using dma is really a boost, and also udma5 if your harddrive supports it (you can check with hdparm /dev/hda).. i also read a deep manual of hdparm, i'll post the link later.

 about hdparm: it is quite danderous to specify specific dma seting from hdparm; better let the bios manage the udma mode (much more safer)

btw: my hdparm settings:

```
-u1 -m16 -c1 -A1 -a64 -d1
```

----------

## MighMoS

[quote="teutzz"] *nastassja wrote:*   

> btw: my hdparm settings:
> 
> ```
> -u1 -m16 -c1 -A1 -a64 -d1
> ```
> ...

 

...and just to outdo you, here are mine:

```
disc0_args="-d1 -X66 -u1 -m16 -a256 -A1 -c3 -k1 -A1"

disc1_args="-d1 -X66 -u1 -m16 -a256 -A1 -c3 -k1 -A1"

cdrom0_args="-d1 -E40"
```

  Note:  replace -E40 w/ your actual cdrom speed.  Also, the -c3 gives a big speed boost for me, so if you just take one letter, take that one.

----------

## seringen

for something so over the top (but i like it) you might want to consider adding a section on acovea https://forums.gentoo.org/viewtopic.php?t=157108&highlight=acovea

it helped me speed up my computer a lot, even though it does take a while.  The scripts in the forum thread make it very simple to use

----------

## dol-sen

For porthole, I am very near a -0.4 release.  Watch for the announcement in Chat.   There is a thread in there for the porthole-cvs with instructions on how to test it for the -0.4 release.

As for having an internal su ability.  It is something I have wanted to put in, but gksu was undergoing major rework to its API and would have only meant trouble to include it before now.   I will work on including it after I have the -0.4 release out.

The tuning tricks look good.   I'll have to work on my system a little

----------

## teutzz

[quote="MighMoS"] *teutzz wrote:*   

>  *nastassja wrote:*   btw: my hdparm settings:
> 
> ```
> -u1 -m16 -c1 -A1 -a64 -d1
> ```
> ...

 sorry to disapoint you but you don't outdo me: i have udam5 (set corectvly by the system bios); alsa c3 if you read the man page is acctuly slower then c1 as it is syncronous

also my opinnion is that your readahead is to great (okay it will perform better in hdparm tests) because it will have mediocre speed rezults in real life usage as the data from your hdd is not a single continous string of data written on the disc on the exact order that the user will access it (more or less it is quite fragmented -> in linux that is good -> especially when using reiser4)

one thing is for sure: your args line is longer than mine, so you certenly outto me there  :Very Happy: 

sorry for the bad english: 7am here, just woke up

----------

## teutzz

 *seringen wrote:*   

> for something so over the top (but i like it) you might want to consider adding a section on acovea https://forums.gentoo.org/viewtopic.php?t=157108&highlight=acovea
> 
> it helped me speed up my computer a lot, even though it does take a while.  The scripts in the forum thread make it very simple to use

 yeah, but it gives a very very optimised settings output, i.e. changing the fsb with only one 1 Mhz or just adding more ram / or changing the ram chip is all that it takes to outdate your acovea cflags; not to mention the days spend doing the acovea tests (and all test in order to be valid must be done in single user mode, just console running, no X etc)

and in the end you still lose some time because you have to sort out what can be let in and what must be left out (many times it spits weird flags which if you use them it's like a disaster waiting to happen)

although (i ran it once, twice actualy: 1 time for my c compiler, 1 time for my c++ compiler), and what i can say it's that is good for a general direction (giving a sense of where to go from now), but nothing more, and that it must be treaten with care whatever the result

[EDIT]

not to mention that in genereal adding more optimisation (i.e. cflags) rarely makes a measureable diffrence (speed), maybe just increasing compile time (now i'm not saying go rock stable cflags, but go tested and proven to make a diffrence experimental cflags, i.e. -ffast-math, -fomit-frame-pointer, -momit-leaf-frame-pointer, -ftracer, -fforce-addr, -fprefech-loop etc)

[/EDIT]

----------

## seringen

 *teutzz wrote:*   

> 
> 
> although (i ran it once, twice actualy: 1 time for my c compiler, 1 time for my c++ compiler), and what i can say it's that is good for a general direction (giving a sense of where to go from now), but nothing more, and that it must be treaten with care whatever the result
> 
> [EDIT]
> ...

 

yeah, well of course you should only use it as a pointer to what you should use.  And I'd highly argue against the idea of "proven" cflags like you claim.  I personally run -O1 mainly with options turned off and only a few turned on.  And on a reasonably fast computer, acovea should run overnight.  Anyway I still feel acovea is a perfectly sane addition to the list, considering the nature of this topic is speeding up your computer, and people who really feel they have to do it would be interested in acovea.  And acovea really did help speed my computer up.

Hope that clarifies my point.

----------

## teutzz

 *seringen wrote:*   

>  *teutzz wrote:*   
> 
> although (i ran it once, twice actualy: 1 time for my c compiler, 1 time for my c++ compiler), and what i can say it's that is good for a general direction (giving a sense of where to go from now), but nothing more, and that it must be treaten with care whatever the result
> 
> [EDIT]
> ...

 in every gentoo power user's life comes a time of wondering if he/she can optimize his box even better (i'm one of those, stating that i even ran the full acovea tests just to see the rezults more or less out of curiosity) so yes at least partly i agree with you

----------

## alechiko

Great guide! thanks a lot! really appreciated it, especially the suspend change and the tip about keeping gcc upto date.. which made me realised that the processor-m is out for the centrino which ive updated from what was i686 i think  :Smile: 

----------

## ryceck

The thingy bout the LDFlags was new for me... but it doesn't work :/

```

/usr/lib/i686-gpc-linux-gnu/3.4.2/../../../../i686-pc-linux-gnu/bin/ld : no such file: no such file or directory

```

I checked, and ld is at the location it asks for... so I wouldn't what goes wrong here....

The rest of the tweaks are excellent  :Very Happy: 

----------

## asph

 *ryceck wrote:*   

> The thingy bout the LDFlags was new for me... but it doesn't work :/
> 
> ```
> 
> /usr/lib/i686-gpc-linux-gnu/3.4.2/../../../../i686-pc-linux-gnu/bin/ld : no such file: no such file or directory
> ...

 

what ldflags did you use? what package are you trying to compile when you get the error?

i am working on an update, i guess i will post it today or tomorrow

----------

## Chaosite

What happened to the times when all we had to do was try to hit the ground and miss?

 :Wink: 

----------

## ryceck

 *mvila wrote:*   

>  *ryceck wrote:*   The thingy bout the LDFlags was new for me... but it doesn't work :/
> 
> ```
> 
> /usr/lib/i686-gpc-linux-gnu/3.4.2/../../../../i686-pc-linux-gnu/bin/ld : no such file: no such file or directory
> ...

 

Every package and these flags: "Wl, O1"

@Chaosite: Those days will arrive again when the Vorlons do  :Wink: 

----------

## John5788

great guide, just tried it  :Smile: 

----------

## seringen

how's the update coming along?

----------

## vdboor

 *mvila wrote:*   

> 14. GCC
> 
> GCC is very important, specially in a distro like gentoo in which the users look to optimize their system by compiling theirselves the packages they install. Using an actual version of gcc has some advantages, because all the code we create when compiling will be more optimized (from version 3.4.x you can already use the -march=pentium-m for the centrino
> 
> processors).
> ...

 

I've just merged a new gcc, but I noticed it isn't being used..!!

Right now, I have two versions of gcc installed. (3.3.4-r1 and 3.4.2-r2)

Try running these commands and you'll like notice the same:

```
gcc -v

etcat -v gcc

gcc-config --get-current-profile

gcc-config --list-profiles
```

Something tell me we need to run gcc-config i686-pc-linux-gnu-3.3.4  first...  :Razz: 

----------

## asph

little update, more to come  :Smile: 

thanks for the posts, suggestions and corrections

----------

## Pseud

rotflmao @ mvila's signature

----------

## b-o-s-s

This is a very nice howto, thanks mvila! 

However, there's one point I don't feel comfortable with. You write:

 *Quote:*   

> 
> 
> Another concept to know about is swappiness (kernel 2.6+). When an application needs memory and the RAM is full, there are two options: or the RAM gets empties a little bit cleaning out old used memory, or swap memory gets used (slower than ram). In the new kernels, you can set a variable to define if the kernel should empty some ram or use the swap partition.
> 
> 

 

I think this explanation is somewhat misleading. In my opinion (which could be totally wrong), swappiness affects the rate, at which a potentially growing page cache may force user pages to swap. (at least it should)

Basically, the page cache is memory, where linux caches nearly everything, and this is independent of it's likeliness to be needed again. Then there comes the point where the page cache would grow beyond free physical memory. A decision has to be made whether the page cache should grow anyway, which may mean putting even running applications to swap, or to keep the page cache's size and replace some entries in it. The good point in not growing the page cache is, this doesn't force applications to swap, but the bad point is, page cache entries might be thrown away that are needed again shortly (and thus have to be reread from disk). So this is a serious tradeoff, which can be manipulated through the tunable swappiness. (/proc/sys/vm/swappiness)

A very distressing fact about swappiness comes from a discussion I read on www.kerneltrap.org, where someone (can't remember) figured out, that from kernels > 2.6.6, swappiness isn't been honoured correctly. This means, swappiness has little, even unexpected influence on the above described decision. swappiness 0 should mean "never swap out user pages in favour of page cache growth" and 100 should mean "always favour page cache growth". Note that this is part of the old tradeoff between "overall throughput" and "desktop interactivity". Unfortunately, on kernels > 2.6.6 even swappiness 0 leads to swapping out user pages for a growing page cache and in general, the swappiness value is totally incomprehensible. (Although I don't know if this is really a bad thing. Ideally, something like swappiness shouldn't be needed at all)

Hope I got this all right, so feel free to correct me.

Oh, and one last thing. You recommend considering acovea for getting the optimal CFLAGS. I don't agree with this. While a very nice concept, I don't think the very special CFLAGS acovea spits out, are suited for compiling a whole system. In fact, I think it actually leads to worse performance, but this claim deserves a thread of its own...

----------

## vdboor

 *mvila wrote:*   

> /etc/init.d/localmount
> 
> change:
> 
> ```
> ...

 

I've noticed this new mount command gives problems with mount points depending on each other, for example:

```
/usr/local/opt  /opt     none  auto,bind   0  0
```

I haven't found any solution for this in the mount manual. In fact, the manual even states:

 *Quote:*   

> A disadvantage is that the mounts are done in undefined order.  Thus, you  cannot  use  this option if you want to mount both /usr and /usr/spool.

 

To bad  :Sad: 

----------

## BlindSpy

wow this guide is completely amazing! i love it when you vets share your secrets =)

----------

## c0balt

A way to speed up emerge (calculating dependencies, searching etc) that has been floating around the forums for some time:

```
emerge psyco
```

add in /usr/bin/emerge (somewhere at the beginning)

```
try:

    import psyco

    psyco.full()

except ImportError:

    pass
```

ive never comprehensively tested it, but it feels faster.

It has to be done after every portage update though (USE flag would be cool)[/code]

----------

## massctrl

Hi all,

I'm especially interested in the centrino flags etc,..

The thing is, if you want to do a stage 1 install using the 2004.2 livecd you need to install the latest C-compiler first ,since the version on 2004.2 doesn't support the pentium-m flag?

I'm getting an error when bootstrapping the system, this is caused by this pentium-m flag.

Anyone with tips about this issue?

Thanks in advance 

Massctrl

----------

## JanErik

One more interesting thing could be nscd, or Name Service Cache Daemon. Should give faster web since it doesn't have to do a DNS lookup for visited URLs.

/etc/init.d/nscd start

or

rc-update add nscd default

----------

## TheKat

 *Quote:*   

> As for the CXXFLAGS, -fvisibility-inlines-hidden has been reported as a good flag to improve the C++ compiles (thx teutzz).

 

Is there a specific GCC version for those? GCC 3.3.4 dies with -fvisibility-inlines-hidden.

```
cd ../obj_s;  /usr/bin/g++ -I../c++ -I../include -I. -DHAVE_CONFIG_H -I. -I../include -D_GNU_SOURCES -DNDEBUG -march=pentium3 -O3 -ftracer -fforce-addr -pipe -fomit-frame-pointer -fvisibility-inlines-hidden -fPIC -fPIC -c ../c++/cursesm.cc

make[1]: *** [../obj_s/cursesm.o] Error 1

make[1]: *** Waiting for unfinished jobs....

cc1plus: error: unrecognized option `-fvisibility-inlines-hidden'

make[1]: *** [../obj_s/cursesf.o] Error 1

make[1]: Leaving directory `/var/tmp/portage/ncurses-5.4-r5/work/ncurses-5.4/c++'

make: *** [all] Error 2

livecd portage# gcc --version

gcc (GCC) 3.3.4 20040623 (Gentoo Linux 3.3.4-r1, ssp-3.3.2-2, pie-8.7.6)
```

----------

## Deranger

Solved...Last edited by Deranger on Wed Nov 17, 2004 11:07 am; edited 2 times in total

----------

## Keffin

I'd just like to say thanks for an awesome guide. It really helps to have all this stuff in one place  :Very Happy: . I've edited my init scripts to save time on booting, and you forced me to go for NPTL/LDFLAGS too  :Wink: .

----------

## wrc1944

If you adopt the use of LDFLAGS in /etc/make.conf, do you still use prelink- or are they incompatible?

----------

## zerojay

 *TheKat wrote:*   

>  *Quote:*   As for the CXXFLAGS, -fvisibility-inlines-hidden has been reported as a good flag to improve the C++ compiles (thx teutzz). 
> 
> Is there a specific GCC version for those? GCC 3.3.4 dies with -fvisibility-inlines-hidden.
> 
> ```
> ...

 

3.4.x

----------

## Keffin

 *wrc1944 wrote:*   

> If you adopt the use of LDFLAGS in /etc/make.conf, do you still use prelink- or are they incompatible?

 

Apparently they are compatible, though I have never tried prelinking before or after setting up LDFLAGS.

----------

## wrc1944

Keffin,

Thanks for the input. Seeing as how you have not actually tried this, could you elaborate a little on your basis for thinking they are compatible, or point me to some info (other than the forum threads)? 

I recently installed Yoper on one of my boxes, and it has prelink out of the box, and I must say Yoper is very snappy for a precompiled rpm distro.  Therefore,  I prelinked one of my Gentoo installations to see if made any difference. I have to say I can barely notice any, and maybe I'm imagining any perceived improvement.

Then I  read about LDFLAGS, and it seemed like something to try, thus my question about prelink & LDFLAGS. Can anyone confirm that I remove prelink before trying LDFLAGS, or doesn't it really matter?

----------

## Keffin

 *wrc1944 wrote:*   

> Keffin,
> 
> Thanks for the input. Seeing as how you have not actually tried this, could you elaborate a little on your basis for thinking they are compatible, or point me to some info (other than the forum threads)? 
> 
> I recently installed Yoper on one of my boxes, and it has prelink out of the box, and I must say Yoper is very snappy for a precompiled rpm distro.  Therefore,  I prelinked one of my Gentoo installations to see if made any difference. I have to say I can barely notice any, and maybe I'm imagining any perceived improvement.
> ...

 

Sorry for the excessively short reply, I was on windows after having the problem with the new tar stopping me booting linux.

I don't know how to link to an exact post in a thread but look at the 9th/10th post down to the end of the page on page 2 of this thread. The conversation about prelinking seems to fizzle out with no word of whether it worked or not, but there's a couple of links to information about it there.

----------

## cbr

 *Keffin wrote:*   

> I don't know how to link to an exact post in a thread....

 

 *Quote:*   

> Posted: Tue Oct 12, 2004 4:42 pm    Post subject:

 

Infront of this line there is a little page icon. Press on that and copy the address on the address bar or do Copy Link Location on it  :Wink: 

----------

## Keffin

 *cbr wrote:*   

>  *Keffin wrote:*   I don't know how to link to an exact post in a thread.... 
> 
>  *Quote:*   Posted: Tue Oct 12, 2004 4:42 pm    Post subject: 
> 
> Infront of this line there is a little page icon. Press on that and copy the address on the address bar or do Copy Link Location on it 

 

Ah, that's clever. Thanks.

----------

## asph

theres a little discussion about this thread in the developers mailing list, its a good reading to learn why some of the tweaks are dangerous  :Razz: 

http://thread.gmane.org/gmane.linux.gentoo.devel/22100

----------

## Deranger

I did all those init-script tweaks (except RC_PARALLER_STARTUP, why? see my posts above)

Running nitro-sources, dramatically speed increase in boot...Especially localmounts, Reiser4 takes more time to mount than other filesystems, and I have 6 x Reiser4 (/ and 5 x storage) partitions...

As far as I understood, localmounts tweak is safe if your fstab entries doesn't have dependencies (in example /usr & /usr/share)

 *Some guy wrote:*   

> 
> 
> Now, in all seriousness, none of the modifications (save the 
> 
> RC_PARALLEL_STARTUP setting) are safe:
> ...

 

 :Laughing:  "If it ain't b0rked, b0rk it"

Actually, I removed those tweaks and left only localmounts (No, I don't have any entries in fstab that has dependencies to each other...)

And last, but not least: there seems to be some problems with ccache if you haven't set CCACHE_DIR in /etc/make.conf

Read more from here: https://forums.gentoo.org/viewtopic.php?t=236603

----------

## teutzz

 *Keffin wrote:*   

>  *wrc1944 wrote:*   Keffin,
> 
> Thanks for the input. Seeing as how you have not actually tried this, could you elaborate a little on your basis for thinking they are compatible, or point me to some info (other than the forum threads)? 
> 
> I recently installed Yoper on one of my boxes, and it has prelink out of the box, and I must say Yoper is very snappy for a precompiled rpm distro.  Therefore,  I prelinked one of my Gentoo installations to see if made any difference. I have to say I can barely notice any, and maybe I'm imagining any perceived improvement.
> ...

 

well i have 99% of my system build with ldflags (including kde) (that 1% that's missing includes openoffice and so on) and it's all prelinked and no problems what so ever   :Very Happy: 

----------

## Keffin

Anyone having problems with loading modules in >=gentoo-dev-sources-2.6.8-r8 will have to lose the changes to the init scripts. I can't be bothered finding out which one did it at the moment, but I might when I get time.

----------

## Hackeron

Ran a short test to see if psyco makes a noticeable improvement. Notice that psyco now imports fine. So "except: pass" is no longer needed.

```

portage-2.0.50-r11  emerge -ep world

1ghz via c3-2 nehemiah 512Mb PC2700

-----------------------------------

psyco.full()

        0m41.919s 0m36.447s 0m5.002s

        0m42.046s 0m36.539s 0m5.006s

        0m42.089s 0m36.430s 0m5.154s

psyco.log(); psyco.full()

        0m42.098s 0m36.559s 0m5.010s

        0m42.101s 0m36.508s 0m5.040s

        0m42.230s 0m36.374s 0m5.319s

psyco.full(); except pass

        0m42.127s 0m36.569s 0m5.028s

        0m42.440s 0m36.388s 0m5.275s

        0m42.265s 0m36.423s 0m5.188s

psyco.profile()

        0m49.296s 0m42.820s 0m5.844s

        0m49.037s 0m42.642s 0m5.756s

        0m49.179s 0m42.839s 0m5.741s

psyco.log(); psyco.profile()

        0m49.450s 0m43.109s 0m5.746s

        0m49.417s 0m42.917s 0m5.865s

        0m49.575s 0m43.173s 0m5.804s

nothing;

        0m49.623s 0m44.142s 0m4.856s

        0m49.543s 0m44.050s 0m4.933s

        0m49.648s 0m44.121s 0m4.910s

psyco.log(); psyco.profile(0.2)

        0m54.920s 0m48.323s 0m5.889s

        0m55.047s 0m48.585s 0m5.767s

        0m56.631s 0m48.424s 0m6.463s

```

Verdict? -- not quite 100x improvement as possible, not even the 4x as promised.. not even 2x as minimum listed! -- doesnt seem worth the risk of things breaking.

----------

## twiggy

http://217.209.205.126/goawaybaselayout.html

I hope this could be of any use for some of you   :Smile: 

----------

## Hackeron

 *twiggy wrote:*   

> http://217.209.205.126/goawaybaselayout.html
> 
> I hope this could be of any use for some of you  

 

How does this speed anything up exactly?

----------

## twiggy

 *Hackeron wrote:*   

>  *twiggy wrote:*   http://217.209.205.126/goawaybaselayout.html
> 
> I hope this could be of any use for some of you   
> 
> How does this speed anything up exactly?

 

Reduces the bootup time alot. It might not be what you want but it is without a doubt in the speed category.

----------

## Hackeron

 *twiggy wrote:*   

> Reduces the bootup time alot. It might not be what you want but it is without a doubt in the speed category.

 

Well, I just tried it on a spare machine that I use for distro testing, and I dont notice any speed up what so ever. Maybe its there, especially if you have many services, but then again you already have parallel startup in baselayout and there's ofcourse tips on this thread to make startup as fast as possible. Try them!

Even if there is a slight gain in speed if using sysvinit with those scripts instead of baselayout (no gain in speed here), I dont see how anyone would compromise baselayout's usability for it. 

The init system in gentoo is one of my favorite things about the distribution. Look at fedora's sysv implementation - services marked started when they're not is just one of the examples of the many things wrong with it - and they have a far more advanced configuration than crux  :Wink: 

----------

## twiggy

It's all about taste   :Smile: 

Baselayout might be useable but i just hate it. Mostly because the output is so freaking ugly and i like to keep things simple.. It's certainly not something everyone should use but it's perfect for me..

----------

## Hackeron

 *twiggy wrote:*   

> It's all about taste  
> 
> Baselayout might be useable but i just hate it. Mostly because the output is so freaking ugly and i like to keep things simple.. It's certainly not something everyone should use but it's perfect for me..

 

Ofcourse, very valuable howto! , I just think it deserves its own thread on the documentation forum!

Afterall, gentoo is about choice  :Smile: 

----------

## twiggy

 *Hackeron wrote:*   

>  *twiggy wrote:*   It's all about taste  
> 
> Baselayout might be useable but i just hate it. Mostly because the output is so freaking ugly and i like to keep things simple.. It's certainly not something everyone should use but it's perfect for me.. 
> 
> Ofcourse, very valuable howto! , I just think it deserves its own thread on the documentation forum!
> ...

 

https://forums.gentoo.org/viewtopic.php?p=1665175#1665175

If you'd like to say hello or whatever   :Smile: 

----------

## bruciemoose

I'm a newbie to Gentoo, but I would have thought that hdparm would be best run as soon as possible. Looking at /etc/init.d/hdparm the dependency shows:

```
depend() {

        before bootmisc

}

```

Since bootmisc is in the "boot" runlevel, I would assume that it would be best to run hdparm in "boot" and not "default"?

Andrew

----------

## asph

bruciemoose: if you want to run hdparm the soon as possible put it on the boot runlevel (which is executed before the default one)

twiggy: the baselayout tweaks look amazing, but also it seems dangerous when you lose all the improvements/fixes/changes made in the new baselayouts gentoo releases.. maybe i would go with modyfing it, instead of unmerging it all  :Razz: 

----------

## twiggy

 *mvila wrote:*   

> bruciemoose: if you want to run hdparm the soon as possible put it on the boot runlevel (which is executed before the default one)
> 
> twiggy: the baselayout tweaks look amazing, but also it seems dangerous when you lose all the improvements/fixes/changes made in the new baselayouts gentoo releases.. maybe i would go with modyfing it, instead of unmerging it all 

 

I tweaked baselayout a bit before but it's a lot easier to get the things like you want it by starting from scratch.. the only real "downside" i can see is you really can't tell if all the initscripts gets up and running or if it fails but i really don't care that much and it's problably not so hard do fix that..   :Shocked: 

----------

## Kurse

 *wrc1944 wrote:*   

> Keffin,
> 
> Thanks for the input. Seeing as how you have not actually tried this, could you elaborate a little on your basis for thinking they are compatible, or point me to some info (other than the forum threads)? 
> 
> I recently installed Yoper on one of my boxes, and it has prelink out of the box, and I must say Yoper is very snappy for a precompiled rpm distro.  Therefore,  I prelinked one of my Gentoo installations to see if made any difference. I have to say I can barely notice any, and maybe I'm imagining any perceived improvement.
> ...

 

My system is prelinked, and I do use LDFLAGS as well. I havent had any negative impact that I can see, and I do notice a speed improvement with some applications

----------

## pennedinil

My Experiences with LDFLAGS

I thought I'd add this to the post. Perhaps someone can confirm/correct my problems.

In the hopes of maximizing speed and optimizing my system, I added the following to make.conf -

```

CFLAGS="-O2 -pipe -march=pentium4 -fomit-frame-pointer"

CFLAGS=" -maccumulate-outgoing-args -ftracer" #<-- additional opts

CFLAGS+=" -mmmx -msse -msse2" #<-- for the extra registers

CFLAGS+=" -mfpmath=sse" #<-- for my math libs

LDFLAGS="-Wl,-O1 -Wl,--enable-new-dtags -Wl,--sort-common -Wl,-s"

CFLAGS="$CFLAGS $LDFLAGS" #<-- gives lots of gcc warnings but works

CXXFLAGS="$CFLAGS -fvisibility-inlines-hidden"

```

I felt adding LDFLAGS to CFLAGS would force those packages that do not otherwise use LDFLAGS to do so. 

I'm using hardened toolchain, with gcc-3.4.2 with the latest glibc libs, system compiled from the ground up.

One of the strangeness I noticed was that some of the executables now had the suffix "*.c.20.combine". This was especially noticable in the star & cdrtools packages. Other packages exhibiting this behavior are pkgconfig, gdb and xterm. I had to manually go into the PORTAGE_TMPDIR and rename the files for the application to complete the merge. 

Other applications also give similar problems, I can't remember exactly which ones, but the fix usually involved me having to manually rename files or move them around in PORTAGE_TMPDIR.

Another problem I noticed was when kdelibs failed to compile. After a lot of backtracking, I found that the problem was with the jpeg package. With LDFLAGS in CFLAGS, libjpeg.so is not created. Which is very odd. [Perhaps this sould be in a bug report.]

All said and done, I feel my system is now a lot more responsive. E.g., konqueror opens immediately instead of the normal 2-3 second delay.

So my questions here are -

1) anyone else try the above?

2) if so (or even otherwise) anyone else notice anything similar with cdrtools?

3) what about the jpeg package?

4) if you haven't tried this, would anyone else be willing to confirm the above, just so I know it's not specific to my system?

Thanks.

And BTW pretty good HOWTO, somet things I really like, others I'm not yet ready to embrace.

----------

## twiggy

mvila:

In the updated version of my guide and i've removed the part where you remove baselayout so that can't cause any problems and otherwise the init stuff works like in the old guide..

----------

## xces

@pennedinil:

```
CFLAGS="-O2 -pipe -march=pentium4 -fomit-frame-pointer"
```

 *man gcc wrote:*   

> -fomit-frame-pointer
> 
>            Don't keep the frame pointer in a register for functions that don't
> 
>            need one.  This avoids the instructions to save, set up and restore
> ...

 

-fomit-frame-pointer is already activated, when you use -O2.

```
CFLAGS=" -maccumulate-outgoing-args -ftracer" #<-- additional opts
```

You are lacking a '+' here, aren't you? The compiler-flags you added here both make the size of the generated code bigger, so you should have a quite fast harddisk to compensate this.  :Wink: 

```
CFLAGS+=" -mmmx -msse -msse2" #<-- for the extra registers
```

All three flags/features are already activated when using -march=pentium4.

----------

## pennedinil

You're right about the missing + in my CFLAGS. Typo when I typed out the post. 

I saw something similar about -fomit-frame-pointer somewhere, that it's activated with -O2. But I've also seen something to the converse. So just to be safe, I leave it in.

And I've seen something similar with regard to -mmmx -msse -msse2, that they are not activated by default with -march=pentium4, so again, just to be on the safe side...

It's more than possible the x86-P4 relevant flags above are activated with -march, and perhaps what I read was in reference to -mcpu.

And yes, I do have more than enough disk space. :Smile:  Compared to the amount of space the portage tree takes up (packages, distfiles, tempfiles, ebuilds, ccache), which adds up to about 30GB (yes, I don't clean house often!) the added size of the executables is something I'm very much willing to live with.

This still doesn't answer my other questions though...

Thanks.

----------

## M@rijn

Here a little question, how can i set prelink as een startup service, so he starts up with the system?

----------

## pleusicles

 *M@rijn wrote:*   

> Here a little question, how can i set prelink as een startup service, so he starts up with the system?

 

You can't (and don't have to). After prelinkink, the effect will last as long as binaries aren't changed. But you will need to re-run prelink when emerging new versions. You may, however, make a cron job which does that regularly for you.

----------

## ahorn

Hi there,

got some tiny problems by compiling glibc with nptl and prelink with normal use flags

```

[blocks B     ] sys-kernel/linux-headers (from pkg sys-kernel/linux26-headers-2.6.8.1-r1)

[ebuild  N    ] sys-kernel/linux-headers-2.4.22  -build 28,836 kB

[ebuild  N    ] sys-kernel/linux26-headers-2.6.8.1-r1  -build 34,793 kB

[ebuild   R   ] sys-libs/glibc-2.3.4.20040808-r1  -build -debug -erandom -hardened -makecheck -multilib +nls +nptl* -pic -userlocales 0 kB

```

```

[blocks B     ] dev-libs/libelf (from pkg dev-libs/elfutils-0.94-r1)

[blocks B     ] dev-libs/libelf (from pkg sys-devel/prelink-20040707)

[ebuild  N    ] dev-libs/elfutils-0.94-r1

[ebuild  N    ] sys-devel/prelink-20040707

```

both blocks are still there with ~x86! i use 2.6.9-r4-love1

can you give me any explanation how i can manage this? the other tweaks works well. for amd users i recommend to use athcool. a nice tool, cools the cpu by increase the powersaving feature so you can oc them more

----------

## bob1977

For glibc, I think you have to inject linux26-headers somewhere. Try to search in forums for glibc and nptl.

 For prelink, you must unmerge libef and then you will emerge prelink. Finally you type: prelink -avmR. Wait for 20 minutes and it's done. I've just installed it and I'm going to test the new performances.

 See you later.

----------

## ahorn

thanks for the tip at prelink  :Wink: 

```

checking for C compiler default output file name... configure: error: C compiler cannot create executables

See `config.log' for more details.

!!! ERROR: dev-libs/elfutils-0.94-r1 failed.

```

i'm going to unpack gcc glibc binaries to fix this prob. maybe i've got broken linux-headers or i need libelf to let gcc work

@nptl: --inject is deprecated by portage, i guess. and i don't wanna mess with glibc by doing handstuff. is there not an easy routine to get nptl working?

----------

## iainvt

fantastic tips man

----------

## baeksu

Tried adding xdm (i.e. gdm) to my boot run-level, works with no problems.

 *Quote:*   

>                acpid | battery      default                  
> 
>            alsasound | battery      default                  
> 
>                aumix |                                       
> ...

 

 I'm not familiar with the runlevels or depenencies, however. Xdm kicks in at the end of the boot levels, and as I have little on my default level, the speed increase is not very huge. Still, X starts a little earlier than before.

 On a another note, there's some discussion on using the suspend/hibernate to speed up starting the computers.

https://forums.gentoo.org/viewtopic.php?p=1679415#1679415

 I haven't had time to try it myself yet, but will do as soon as I get around installing the suspend scripts.

----------

## nat

 *Quote:*   

> In this section I just wanted to mention some things that can help us.
> 
> First of all, if you have two harddisks it is better to put the swap partition on the second disk (having the root partition in the first one) as this will improve the read/write times.
> 
> 

 

Wouldn't it be better to have 2 swap partitions, one on every IDE bus? Linux is supposed to automatically RAID swap, so using 1 swap on every disk (on different IDE busses) would almost double the swap speed in theory.

Correct me if I am wrong. I have not tested...

And about CFLAGS, I suspect that bigger C++ applications (like KDE) will go faster with -Os instead of -O3. That is also theory, but if the main bottle neck is the disk, it is probably true. I believe this might be noticeable on slower boxes.

----------

## nat

 *JanErik wrote:*   

> One more interesting thing could be nscd, or Name Service Cache Daemon. Should give faster web since it doesn't have to do a DNS lookup for visited URLs.
> 
> 

 

Since I am maintaing a DNS proxy I had to compare nscd with dnrd.

```
ncopa@nc ~/src/stressdns $ sudo /etc/init.d/nscd start

 * Starting Name Service Cache Daemon ...                                 [ ok ]

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26247: 9986 of 10000 lookups was successful. Time: 8.770 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26248: 9986 of 10000 lookups was successful. Time: 1.297 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26249: 9986 of 10000 lookups was successful. Time: 1.225 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26250: 9986 of 10000 lookups was successful. Time: 1.168 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26251: 9986 of 10000 lookups was successful. Time: 1.529 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26252: 9986 of 10000 lookups was successful. Time: 1.334 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26253: 9986 of 10000 lookups was successful. Time: 1.803 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26254: 9986 of 10000 lookups was successful. Time: 1.346 seconds

```

stressdns is a small utility I wrote to test a bunch of gethostbyname calls. In this example I did lookups of 10000 names from a squid log.

The first run is slow (8.7 seconds) because the cache is empty. The next runs are fast.

I started modified /etc/conf.d/dnrd to point to y DNS servers, modified /etc/resolv.conf to point to 127.0.0.1 and started dnrd.

```
ncopa@nc ~/src/stressdns $ sudo /etc/init.d/dnrd start

 * Starting dnrd ...                                                      [ ok ]

ncopa@nc ~/src/stressdns $ sudo vim /etc/resolv.conf 

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26439: 9986 of 10000 lookups was successful. Time: 2.330 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26440: 9986 of 10000 lookups was successful. Time: 0.838 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26441: 9986 of 10000 lookups was successful. Time: 0.854 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26442: 9986 of 10000 lookups was successful. Time: 0.841 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26443: 9986 of 10000 lookups was successful. Time: 0.830 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26444: 9986 of 10000 lookups was successful. Time: 0.838 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26445: 9986 of 10000 lookups was successful. Time: 0.834 seconds

```

Without nscd and dnrd:

```
ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26405: 9986 of 10000 lookups was successful. Time: 6.391 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26406: 9986 of 10000 lookups was successful. Time: 5.365 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26407: 9986 of 10000 lookups was successful. Time: 5.212 seconds

ncopa@nc ~/src/stressdns $ ./stressdns more10k_a 

Number of parallell lookups: 1

26408: 9986 of 10000 lookups was successful. Time: 5.463 seconds

```

(pretty fast lookups anyway because I run a bind on a P4 with gigabit....)

Conclusion is: dnrd is the fastest here. You will ofcourse not note any difference unless you do some really heavy DNS intesive things, but dnrd adds security by randomizing the UDP source ports.

So I recommend dnrd (http://dnrd.sourceforge.net) instead of nscd.

Unfortunally it is not in the portage tree yet, even if an ebuild have been around for a long time.

https://bugs.gentoo.org/show_bug.cgi?id=56378

----------

## Dana Merrick

 *baeksu wrote:*   

> Tried adding xdm (i.e. gdm) to my boot run-level, works with no problems.
> 
> ...I'm not familiar with the runlevels or depenencies, however. Xdm kicks in at the end of the boot levels, and as I have little on my default level, the speed increase is not very huge. Still, X starts a little earlier than before.

 

I did the same thing, and it's a subtle improvement.

Does anyone know what the deps are for xdm?

I feel that it could be booting faster than it is, but I'm not sure what else I need to start...

(Edited to fix quote tags  :Rolling Eyes: )

----------

## rhill

 *xces wrote:*   

> 
> 
>  *man gcc wrote:*   -fomit-frame-pointer
> 
>            Don't keep the frame pointer in a register for functions that don't
> ...

 

but if you look further up, it states:

 *man gcc wrote:*   

> -O also turns on -fomit-frame-pointer on machines where doing so does not interfere with debugging. 

 

the x86 architecture is definitely one of the ones where it makes debugging impossible, and so it is not activated at any -O level unless it's stated specifically.

i wish i had a better reference, (of course you can't find these things when you need them)

but this recent post backs it up:

http://lists.gnu.org/archive/html/gcl-devel/2004-06/msg00005.html

 *Quote:*   

> Test configuration 1.
> 
> With optimisation set to "-g -O3" (that is, without -fomit-frame-pointers)
> 
> maxima ignore-errors  -- NO
> ...

 

 *Quote:*   

> Test configuration 2.
> 
> With optimisation set to "-g -O3 -fomit-frame-pointers":
> 
> maxima ignore-errors  -- NO
> ...

 

--de.

----------

## HardenCoonor

 *Quote:*   

> LDFLAGS="-Wl,-O1 -Wl,--enable-new-dtags -Wl,--sort-common -Wl,-s" 

 

I think with binutils-2.15.92.0-* -Wl,--enable-new-dtags is obsolete, as it is most probably activated by default, there is a patch included in the binutils-patch-tar.bz2.

Has anyone tried -fdata-sections and/or -ffunction-sections in his/her CFLAGS and -gc-sections in LDFLAGS?

----------

## Dhaki

 *aragostaragazzo wrote:*   

>  *baeksu wrote:*   Tried adding xdm (i.e. gdm) to my boot run-level, works with no problems.
> 
> ...I'm not familiar with the runlevels or depenencies, however. Xdm kicks in at the end of the boot levels, and as I have little on my default level, the speed increase is not very huge. Still, X starts a little earlier than before. 
> 
> I did the same thing, and it's a subtle improvement.
> ...

 

I've found in the dev ml this:

 *Quote:*   

> That article in the forums suggests adding xdm to the boot runlevel to get it 
> 
> started sooner. Ive been doing something for a while which is slightly 
> 
> different, and IMO a little cleaner.
> ...

 

But I dont know the exactly dependancies of xdm...

----------

## asph

you can check the depends of every service by editing the scripts at /etc/init.d

rmember that if X depends on Y, and Y depends on Z, X will also depend on Z  :Razz: 

----------

## Dhaki

Yes but for example if you need samba or I dont know what, it isn't in the /etc/init.d/xdm file... Yes, in 1 or 2 boot you would have a system that work and is ok... There isn't any other possible problems?

And for a very minimal system, witch rc-update I can delete? For example, 

```
 consolefont | boot
```

is really needed?

----------

## castorilo

Pretty much the whole section 1 has problems, and I have written several patches to fix them.

/etc/init.d/modules

Your approach has problems because when a kernel changes, modules-update does not get run. Also, if only one of the scripts in /etc/modules.d changes, the directory itself does not get marked as changed and modules-update will not be run.

Check this bug for the appropiate way to do it.

/etc/init.d/localmount

This works fine unless you have something like /usr and /usr/local in fstab. In that case it can completelly fail. Maybe a warning should be put?

/etc/init.d/bootmisc

This does not work because if you change just one script inside /etc/env.d/, the directory itself does not change and env-update.sh will not be run. 

Check this bug for the proper way to do it

/etc/conf.d/rc

RC_PARALLEL_STARTUP is currently a joke. At any given time during boot up, it is running either one script, or two scripts + a cpu hungry busy wait. It can even make things worse.

I wrote a patch that does true parallel startup with no busy waits, and it does save a lot of time, check this bug

I wrote a guide on how to apply these patches in some other thread, I'll quote it here:

 *paulpach wrote:*   

> 
> 
> I made 3 patches that speed up boot time dramatically. Initially, It took my computer 2:00 minutes from grub to kdm, and I have been able to reduce it to 1:09 (YMMV). Here is how you can do it:
> 
> make sure you have baselayout-1.11.6-r1.
> ...

 

----------

## vdboor

 *baeksu wrote:*   

> Tried adding xdm (i.e. gdm) to my boot run-level, works with no problems.
> 
> ...I'm not familiar with the runlevels or depenencies, however. Xdm kicks in at the end of the boot levels, and as I have little on my default level, the speed increase is not very huge. Still, X starts a little earlier than before.

 

I can actually hardly believe it "starts a little earlier than before"... the /etc/init.d/xdm script just tells init it should run "runlevel a" after it completed all other runlevels.... so, how is this actually improving speed?  :Embarassed:  (but it also explains why xdm always starts as last service)

 *Dhaki wrote:*   

> But I dont know the exactly dependancies of xdm...

 

Afaik xdm doesn't have any real dependencies (init starts runlevel 'a' once everything else is running) But the gentoo devs did this for a reason: if both X and agetty try to open the same terminal, your X session hangs. That's why X starts after init finished the entire boot process and started agetty to open the 6 terminals.

I've been playing with the postx script as well, but removed it too.. My desktop became a little unusable (because of all the services loading in the background), exactly the same problem I always have with MS-Windows.

----------

## baeksu

 *Quote:*   

> vdboor: I can actually hardly believe it "starts a little earlier than before"... the /etc/init.d/xdm script just tells init it should run "runlevel a" after it completed all other runlevels.... so, how is this actually improving speed? Embarassed (but it also explains why xdm always starts as last service)

 

 The difference is that when xdm was run on the default, you would have a couple of seconds of login prompt before X starts (almost enough time to login, actually).

 When xdm was at boot, the login prompt barely flashed before X started. Granted, this was probably less than a three second improvement.

----------

## Dhaki

I've found this: https://forums.gentoo.org/viewtopic.php?p=1525723

----------

## SerfurJ

mvila,

you should add fc-cache to your list.  it really improved the performance of my system.  application startup time was reduced several fold.

----------

## gungholady

Regarding the tip for swappiness. I've seen some information about this other places. I've been unable to find anything in /proc/sys/vm that is called swappiness. Is this something I've missed when I compiled my kernel? I'm using a 2.6+ kernel.

----------

## robind

But how exactly does one go about making it so that GDM will just start on boot?

----------

## makzu

I don't know if this was said before or not, but I may as well throw my  two cents in.

If you specify both -march AND -mtune in make.conf, it turns out that the last one you specify is the one that gets used.  This might cause a small amount of slowdown in your programs, because GCC will use -mtune instead of -march.

The obvious solution is to change the order.  Make sure -march is AFTER -mtune in /etc/make.conf, and you won't run into that little slowdown.

----------

## licor

LOL!!!!

Long live HHGTTG!

 :Razz: 

 *Chaosite wrote:*   

> What happened to the times when all we had to do was try to hit the ground and miss?
> 
> 

 

----------

## Seabeast

I'm having some problems with /etc/init.d/bootmisc

After editing it with the env-update part (and just that part) described on the HOW-TO it looks just like this:

```
if [ -x /sbin/env-update.sh ]

         then

         if [ /etc/env.d -nt /etc/profile.env ]

         then

         ebegin "Updating environment"

         /sbin/env-update.sh >/dev/null

         eend 0

            else

            einfo "Environment up-to-date"

         fi

         fi
```

As it should be, right?

But then, at startup, after setting the hardware clock (i don't use XDM or it derivatives) the system says:

```
/var/lib/init.d/bootmisc-372: line 115: syntax error unexpected token '}'

ERROR: "/etc/init.d/bootmisc" has syntax errors in it not executing.
```

Even when line 115 is empty, or when it has '}'.

Can someone help me? I've felt no downgrade or malfunctioning due to this message but it's kinda annoying.

----------

## DFanick

hi!

here my make.conf for pentium4 with gf5200. i didn't use them from scratch, but eveything i compile now seems to work fine (&FAST) with the newest gcc (3.4.3 20041125).

```
CHOST="i686-pc-linux-gnu"

CFLAGS="-O4 -mtune=pentium4 -march=pentium4 -pipe -fforce-addr -falign-functions=4 -fprefetch-loop-arrays -fomit-frame-pointer -ffast-math"

CXXFLAGS=${CFLAGS}-fvisibility-inlines-hidden

MAKEOPTS="-j2"

LDFLAGS="-Wl,-O1,-z,now"

USE="x86 oss apm -arts avi berkdb crypt cups devmap dga directfb divx4linux dvd dvdr eds encode fbcon foomaticdb gdbm

gif gpm gstreamer gtk gtk2 hal -hardened pgo imlib jpeg kde gnome jack kde libg++ libwww mad mikmod mmx motif mpeg ncurses nls

nptl npltonly oggvorbis opengl pam pdflib pic png python qt quicktime quotes readline sdl slang spell sse ssl svga

tcltk tcpd truetype -unicode X xml2 xmms xprint xv x86 zlib"

```

that's all.

bye

----------

## alctraz

just made a benchmark with bootchart to measure the efficiency of the init scripts optimization

http://www.groulala.net/alctraz/bootchart/

result: boot time reduced from 32s to 25s

----------

## unix

realy nice hotwo THX

----------

## blixel

 *asph wrote:*   

> 11. Halt vs Suspend
> 
> Have you never asked yourself why you shutdown you computer, when you can suspend it to ram or disk?
> 
> If you suspend to ram, it has the handicap that it will still need AC input in order to keep the system alive. But suspending to disk is very useful (specially for laptops), because the laptop will "shutdown", but we will keep our sesion.
> ...

 

Nice guide.  I was especially interested in the hibernate part because I have *NEVER* been able to suspend my machine.  It goes doen fine, but bringing it back up is another story.  I followed your links and tips and got it more or lesss working.  I'm pretty happy just to have what I have now.  Which is the ability to suspend to the disk and shutdown completely.  However, I'm far more interested in the sleep mode and that seems to not be working quite right.  When I type "hibernate", the machine goes to sleep but then instantaneously reboots.  Besides being an undesirable effect, I feel that it is probably very hard on my computer hardware (primarily the hard-drive) to have it shutdown and reboot so quickly.  So I don't want to do much experimenting until I learn a little more about this.  Has anyone else had this problem?

Here's a look at my complte /etc/hibernate/hibernate.conf  (I removed all comments so it wouldn't be so long.)  "PowerdownMethod 5" is the only one that works the way I would expect.  If I use 3 or 4, the system goes down, and then instantly reboots.  Not quite the same as hitting the reset button.  More like pulling the power cord and plugging it right back in.  

```
UseSwsusp2 yes

Reboot no

## Powerdown method - 3 for suspend-to-RAM, 4 for ACPI S4 sleep, 5 for poweroff

PowerdownMethod 5

Verbosity 1

LogFile /var/log/hibernate.log

LogVerbosity 1

SaveClock yes

UnloadBlacklistedModules yes

LoadModules auto
```

----------

## Dhaki

Hi, take a look here: https://forums.gentoo.org/viewtopic-t-296892.html

----------

## kalestic

Great HowTo!

----------

## Bigun

The link you gave for more info on the acpi runlevel, was in Spanish.  Is there a version in English?

*EDIT*

Here is the URL for the English version, just scroll down a bit.

----------

## Gogiel

 *Quote:*   

> 
> 
> 6. Managing the swap
> 
> In this section I just wanted to mention some things that can help us.
> ...

 

I tried set swappines on 0, 30, 60, 100 but it still uses swap  :Sad:   :Mad: 

```
gogiel@gogiel gogiel $ uname -r

2.6.10-gentoo-r6
```

----------

## asph

are you sure the value is being used? do you use /proc or /etc/sysctl.conf?

please paste the sysctl and free -m outputs

----------

## Kestutis

I did:

/etc/init.d/modules

change:

Code:

ebegin "Calculating module dependencies"

    /sbin/modules-update &>/dev/null

eend $? "Failed to calculate dependencies"

for:

Code:

if [ /etc/modules.d -nt /etc/modules.conf ]

    then

        ebegin "Calculating module dependencies"

        /sbin/modules-update &>/dev/null

        eend $? "Failed to calculate dependencies"

    else

        einfo "Module dependencies are up-to-date"

fi

Doing this, modules-update will only run if it´s really needed because you made changes in the system.

and now my modules doewsn't load anymore. What should I do? I cannot load to graphical mode:(.

Here is modules file: 

#!/sbin/runscript

# Copyright 1999-2004 Gentoo Technologies, Inc.

# Distributed under the terms of the GNU General Public License v2

# $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/modules,v 1.30 2004/04/21 17:09:18 vapier Exp $

depend() {

	need checkroot hostname

	use isapnp

}

load_modules() {

	local x=

	local i=0

	local retval=0

	local modules=

	local modargs=

	local modcount=0

	local config="$1"

	[ -z "${config}" ] && return 0

	[ ! -r "${config}" ] && return 0

	# Loop over every line in $config

	eval $(awk '

		BEGIN {

			COUNT = 0 # Make sure COUNT is set

		}

		$0 !~ /(^[[:space:]]*(#|$))/ {

			if (MODULES == "")

				MODULES = $1

			else

				MODULES = MODULES " " $1

			# Not the greatest method to remove $1 from $0, but it works

			sub(/^[[:space:]]*[^[:space:]]*[[:space:]]*/, "")

			ARGS[COUNT] = $0

			COUNT++

		}

		END {

			# 'eval' will make sure these are set to proper bash variables

			print "modcount=" COUNT

			print "modules=\"" MODULES "\""

			for (x = 0;x < COUNT;x++)

				print "modargs[" x "]=\"" ARGS[x] "\""

		}

	' "${config}")

	if [ "${modcount}" -gt 0 ]

	then

		einfo "Using ${config} as config:"

		for x in ${modules}

		do

			ebegin "  Loading module ${x}"

			modprobe -q ${x} ${modargs[${i}]} &>/dev/null

			retval=$?

			eend ${retval} "  Failed to load ${x}"

			i=$((i+1))

			[ "${retval}" -eq 0 ] || modcount=$((modcount-1))

		done

		einfo "Autoloaded ${modcount} module(s)"

	fi

	return 0

}

start() {

	# Should not fail if kernel do not have module

	# support compiled in ...

	[ -f /proc/modules ] || return 0

	# Here we should fail, as a modular kernel do need

	# depmod command ...

	if [ ! -x /sbin/depmod ]

	then

		eerror "ERROR:  system is missing /sbin/depmod !"

		return 1

	fi

	if [ -z "${CDBOOT}" ]

	then

	if [ /etc/modules.d -nt /etc/modules.conf ]

    then

        ebegin "Calculating module dependencies"

        /sbin/modules-update &>/dev/null

        eend $? "Failed to calculate dependencies"

    else

        einfo "Module dependencies are up-to-date"

fi 

	if [ -f /etc/modules.autoload -a ! -L /etc/modules.autoload ]

	then

		# Loop over every line in /etc/modules.autoload.

		load_modules /etc/modules.autoload

	else

		local KV="$(uname -r)"

		local KV_MAJOR="`KV_major "${KV}"`"

		local KV_MINOR="`KV_minor "${KV}"`"

		# New support for /etc/modules.autoload/kernel-$KV

		if [ "$(get_KV)" -ge "$(KV_to_int '2.5.48')" ] && \

		   [ -f /etc/modules.autoload.d/kernel-"${KV_MAJOR}.${KV_MINOR}" ]

		then

			load_modules /etc/modules.autoload.d/kernel-"${KV_MAJOR}.${KV_MINOR}"

		elif [ ! -f /etc/modules.autoload.d/kernel-"${KV_MAJOR}.${KV_MINOR}" ]

		then

			ewarn "Missing /etc/modules.autoload.d/kernel-${KV_MAJOR}.${KV_MINOR}"

			load_modules /etc/modules.autoload.d/kernel-2.4

		else

			load_modules /etc/modules.autoload.d/kernel-2.4

	fi

	#

	# Just in case a sysadmin prefers generic symbolic links in

	# /lib/modules/boot for boot time modules we will load these modules

	#

	if [ -n "$(modprobe -l -t boot)" ]

	then

		modprobe -a -t boot \*  &>/dev/null

	fi

}

# vim:ts=4

Where is a misstake? Please someone help me.  :Sad: 

----------

## asph

i don't think the modules are not beign loaded because of that tweak, if you just changed that.

are you sure you didnt change something more? when you say that they dont load, is it because of some errors or they are just not loaded?

i guess that you have your modules on /etc/modules.autoload/kernel-2.X (change X for your kernel version, which you can know by typing uname -a).. then modules-update

also use lsmod to make sure the modules are not loaded, and you can also try to modprobe them manually "modprobe module_name", to see if they contain errors. If they load correctly, they should when you boot the system (running modules-update each time makes no sense on a typical users system, where changes are really only made once in a while)

----------

## zayhen

Hey people,

    All of you have great ideas! This gives me a lot of doubts! Before complaining me, remember, I worried about STABILITY vs VELOCITY. Truth is:

```
 I run a network with 14 Gentoo/Win2000 and 8 Win2000 machines in my College Math Lab.

We offer email, system accounting, ssh and httpd for our users. All these are run in 1 server only! Yeah! Just one!!! I know this madness.

The Gentoo machines have (against my will) every litle scientific pkg and WM and X aplication. OKay that's not everyone. But the major ones!

```

    The workstations will be turned in a cluster. So will be the server. It will receive two clone machines.

    Now the questions:

```
Would you risk reiserfs4?

What about nptlonly machines?

Which WM runs faster? Does compensate using KDE or may continue offering every litle X shit to my users?

Which techinques may speed my boot time?

My kernel is like a module archipelago (diferent hardware problems). Does anyone may suggest a good, stable and reliable kernel?

```

    Too many questions will come to mind. You might be sure. But this is my strongest concernings right now. I know some of you might think this isn't concerned with this topic. But yes, this is! Speed without realiability isn't a good thing.

----------

## Sheepdogj15

 *asph wrote:*   

> 
> 
> ```
> CHOST="i686-pc-linux-gnu"
> 
> ...

 

just FYI, from the GCC documentation, "Moreover, specifying -march=cpu-type implies -mtune=cpu-type."

you can check out the GCC documentation here: http://www.gnu.org/software/gcc/onlinedocs/ (just go to the first one for your version number... they are pretty comprehensive in describing what each option does. there's a specific section on optimizations, that anyone here ought to consider looking at.)

----------

## FastTurtle

I had the same problem that many complain about. Boot took over 2m20s to complete and after extensive reading, I finally found a solution that requires no editing of scripts, just simple changes to rc-update an a single kernel config change.

The change I made to rc-update was to remove netmount and that saved 1+min of time by itself. The other change was to change the kernel config and convert automount to a module and load it into modules.autoload.d/kernel-2.x.. Between these to changes, I was able to improve my boot speed from lilo prompt to log-in to less then 30 seconds.

It really doesn't take much to improve Gentoos boot speed significantly. The 1st thing to always examine is what services are starting and to disable those that you don't need. This is also the beginning of securing your system. Don't start services unless really need them. In fact I would like to see netmount being removed from rc-update and all services that aren't explictly needed to boot disabled by default. If you need them, then you add them in as the OpenBSD folks believe.

System Config: Stage1 using 2005.0 live cd No ntpl

XP1800; 1024 mem 60 gig WD /home 15.3 Seagate / and remainder

cflag -march -O1 -pipe

----------

## Bitspyer

Does anyone tried init-ng? If this works like they say, it should boost up the boot process.

I've tried it, but it hangs, when my network comes up. :Rolling Eyes: 

----------

## Varg_

I've installed and tried it with my gentoo64, It more than halved my boot time to around 17 seconds or so. 

But it is broken with nvidia drivers, and there are apparently some network issues; its encouraged for you write or edit your own init scripts to get things like network working properly however - the standard sysV init scripts are incompatible with initng

----------

## hellspawn

Anyone got an operation not permited when tryng to set dma?

I got this and i wonder how to get around it.

----------

## Plazmic

Excellent guide! In someways a bit too agressive for my liking but nonetheless very helpful  :Smile: 

InitNG had my system booting in under 15 seconds... that said it is still an alpha build. Eventually it will completely deprecate sysvinit (in my opinion) but I would recommend not using it for production enviroments much less if you don't know exactly what your doing. Theres alot of configuration incompatabilities as previously stated.

Also in:

```
 CFLAGS="-O3 -march=pentium-m -mtune=pentium-m -pipe -ftracer -fomit-frame-pointer -ffast-math -momit-leaf-frame-pointers"
```

```
-momit-leaf-frame-pointers
```

 should not have an s at the end. The correct flag is 

```
-momit-leaf-frame-pointer
```

Regarding that, can anyone verify if using -fomit-frame-pointer with -momit-leaf-frame-pointer is redundant? I was under the influence that -momit-..-.. was implied by -fomit-..-.. because -fomit-..-.. frees the register in all pointer functions or something along those lines.

----------

## lnxz

Well, as I understand the gcc info page on gcc optimizations -fomit-frame-pointer makes gcc not keep the frame pointer in a register for functions that don't need one, it doesn't disable keeping frame pointers for all functions. 

I think leaf frame pointers are different from regular frame pointers, but I'm not sure, though.

----------

## asph

i am planning a major update (re-write) of the guide in order to update it, i would like to ask for a little collaboration to make it wider and add more tweaks for the system.. it will take me a while because I want to do it right and extense, if you think you can add something or want some feature to be commented please feel free to p.m. me  :Smile: 

----------

## Enlight

 *Plazmic wrote:*   

> Excellent guide! In someways a bit too agressive for my liking but nonetheless very helpful 
> 
> InitNG had my system booting in under 15 seconds... that said it is still an alpha build. Eventually it will completely deprecate sysvinit (in my opinion) but I would recommend not using it for production enviroments much less if you don't know exactly what your doing. Theres alot of configuration incompatabilities as previously stated.
> 
> Also in:
> ...

 

momit-leaf-frame-pointer is redondant whan using -fomit-frame-pointer is in use but not the contrary.

 *man gcc wrote:*   

> -momit-leaf-frame-pointer
> 
>            Don't keep the frame pointer in a register for leaf functions.
> 
>            This avoids the instructions to save, set up and restore frame
> ...

 

Now question is what are "leaf" functions?

----------

## TGL

 *Enlight wrote:*   

> Now question is what are "leaf" functions?

  A function which doesn't call any other function. See:  http://gcc.gnu.org/onlinedocs/gccint/Leaf-Functions.html

----------

## user118696

Interesting. Thx.

----------

## karmarcoma

what about this:

/etc/init.d/xdm

find the line which reads 

```
/sbin/telinit a &>/dev/null
```

 and change it to 

```
/etc/X11/startDM.sh &>/dev/null
```

this way xdm wont start at the end of the default runlevel but right when the script's executed   :Cool: 

now move xdm from default runlevel to boot runlevel

works for me... is this dangerous/stupid?

----------

## TGL

 *karmarcoma wrote:*   

> is this dangerous/stupid?

 

Not really. You can check bug #70689 for more discussion on that topic.

----------

## Gotterdammerung

really cool! I'm trying some of these tips right now.

----------

## enderandrew

From what I understand, it is preferred to use the glibc-omitfp use flag over the -fomit-leaf-frame-pointer CFLAG.  It is less likely to break things.  It allows glibc to decide when to omit frame pointers.

----------

## shadowscythe

 *hellspawn wrote:*   

> Anyone got an operation not permited when tryng to set dma?
> 
> I got this and i wonder how to get around it.

 

I was getting this error as well.  After a few mins of thinking of all the stupid things I could have possibly done...

I went to the kernel config and lo and behold... someone forgot to set the correct driver for the pci chipset in Device Drivers->ATA/ATPI...->    :Embarassed: 

Works great after that

```
/dev/hda:

 Timing cached reads:   2040 MB in  2.01 seconds = 1015.87 MB/sec

 Timing buffered disk reads:  114 MB in  3.04 seconds =  37.45 MB/sec

```

```
/dev/hdb:

 Timing cached reads:   2036 MB in  2.00 seconds = 1017.94 MB/sec

 Timing buffered disk reads:   44 MB in  3.03 seconds =  14.53 MB/sec

```

They were 45MB/sec and 50MB/sec in Single User Mode respectively..  before dma... a dismal 3.5MB/sec

----------

## crys0000

I don't have any /etc/init.d/service file in my system...   :Confused: 

----------

## ZiffyWombat

I would recommend compiling all of your boot programs with the 

```
CFLAGS="-Os  -march=arch -pipe"

CXXFLAGS="-Os -march=arch -pipe -fvisibility-inlines-hidden"
```

Flags. Considering -O3 heavily bloats the code, it probably would'nt be the best choice for boot proggies..

Combined with LDFLAGS and prelink, this should cut boot time by a few seconds.

----------

## asph

added performance tips for kernel 2.6 and for kde users (thanks xdarma for the links)

----------

## yoshi314

using a separate partition for portage workdir (compilation directory and ccache dir) makes such a big difference. [sounds obvious, heh]. 

i also noticed that it was a bad idea to try reiser4 with that partition - that fs put some stress on cpu on compilation, and interfered with compilation a bit (most noticeable with packages that have thousands of source files to compile). ext3 with dir_index tweak did much better job.

i don't want to state the obvious, but it also reduces the mess in your root partition. and that really shows, after a couple of dozens of merged packages.

----------

## mostro

Here is a small, but important detail about the code given to determine if modules-update should be executed or not.

If you only look at the mtime of the /etc/modules.d directory, you will be missing potential changes to the actual files within the directory.  So a better alternative is:

for File in /etc/modules.d/*; do

     if [ "$File" -nt /etc/modprobe.conf ]; then

          # modules-update code goes here.

          # ...

          break

     fi

done

The reason for the "break" is that once modules-update runs, there is no point in continuing to check the other files...  I hope this helps someone out there.

----------

## ygor

I liked a lot, congratulations for the good work.

Can you give a word about init-ng????

Also do you know any hdparm like application that currently works with the latest SATA drivers???

Thanks,

Ygor Lemos

----------

## ebfe

most of the general tips and like all of the cflags in the first post won't lead to any performance gain, are incorrectly discribed and in general just bogus. you may also add -fflux-capacitor or -frearrange-dilithium-core

btw take a look at some ebuilds and you'll see that some of the most popular packages filter cflags.

----------

## cfriedt

 *asph wrote:*   

> 
> 
> 11. Halt vs Suspend
> 
> Have you never asked yourself why you shutdown you computer, when you can suspend it to ram or disk?
> ...

 

This should read "it will draw a minimal amount of power" instead of "it will still need AC input". 

That covers the case of a laptop, desktop pc, or any other form of computer as well  :Smile: 

----------

## monsm

Hi,

This looks like some very good advice.  It is now just past its 3 year birthday since it was originally posted and a year since the last edit.

I guess this is still reasonably relevant?

Shouldn't this be on the wiki instead?  or is it already there somehwere?

----------

## i92guboj

 *monsm wrote:*   

> Hi,
> 
> This looks like some very good advice.  It is now just past its 3 year birthday since it was originally posted and a year since the last edit.
> 
> I guess this is still reasonably relevant?
> ...

 

If this were reasonably relevant, it would be the default.

It it has not been included in years, it is because you can expect problems from some of the "optimizations" described here.

----------

## P0w3r3d

Any updates about this topic??

----------

## shgadwa

The suggestions on this thread are REALLY old. I tried one of them and it broke my system and then I had to chroot into it and put it back the way it was before.

----------

## dE_logics

Yep, though bout that.

----------

## VinzC

Hi.

I have installed prelink a long time ago (don't even remember what command I needed but I know prelink provided that) and ever since now emerge <any kernel sources> takes aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaages to complete. I can from the process hierarchy that prelink --verify <... path to c source file in /usr/src/xxx-sources-yyy/...> is run against c files from the kernel source tree. I think that is what slows down the emerge process.

Is it normal? Is there something I can do?

----------

