Optimizing Linux For Your Processor: or How To Double Your Computers Performance
Optimizing Linux For Your Processor: or How To Double Your Computers Performance
Copyright
c 2000 Frank Kruchio and all the contributers to this tutorial. All
rights reserved. This document is free; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any later
version.
This document is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License along
with this document; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
CONTENTS 3
Contents
1 Introduction 4
1.1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . 4
5 Optimizing KDE 12
5.1 Optimizing KDE in the correct order . . . . . . . . . . . . . . 12
6 Optimizing XFree86 13
6.1 Faster GUI for gamers and all . . . . . . . . . . . . . . . . . . 13
7 Appendix 14
7.1 About the author . . . . . . . . . . . . . . . . . . . . . . . . . 14
7.2 Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
7.3 Useful resources . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1 INTRODUCTION 4
1 Introduction
Before you read any further, please make sure you have the latest version of
this tutorial. The latest version can be downloaded from:
http://homepages.paradise.net.nz/frankkru/page2.html
my website.
The availability of free source code under Linux allows the end user to
optimize software for a specific processor architecture. Once the exclusive do-
main of Linux gurus, today Linux optimization is easy for Linux users around
the world. Linux is fast: but most Linux users I have come across almost
never spend time on optimizing their Linux distribution of choice. Indeed
the benefits are immediately noticeable and it provides a user experience and
performance that no windows user can enjoy on the same hardware. While
Linux distributions such as Slackware and Debian are common, this tutorial
will focus only on the Red Hat Package Manager(RPM) based distributions
such as SuSE, Red Hat and Mandrake... for the following reasons.
• This tutorial is focusing on new Linux users: as such, they are more
likely to use an RPM based distribution when they start out with Linux.
Thanks to RPM, users new to Linux can easily optimize Linux for their
own processor architecture taking full advantage of their hardware. Distri-
butions such as Red Hat are only compiled for i386, Suse i486 and even
Mandrake only comes as i586. This leaves plenty of headroom to optimize
your favorite Linux distribution for Duron, Athlon, Athlon XP, Athlon MP,
Pentium II/III/IV and Celeron. While my example is focusing on optimizing
workstation packages there is nothing holding you back to optimize a Linux
server, firewall, router or any other Linux box.
2 WHAT DO I NEED TO GET STARTED ? 5
to install both packages (SuSE users can use yast → package management
→ install packages → directory).
After installation, you can confirm from a shell that installation was success-
ful:
If RPM reports the version number you successfully installed the required
packages, now you are ready to move onto the next step.
NOTE:
If you would like to learn how the tools autoconf and automake work, you
can visit the
http://sources.redhat.com/autobook/autobook/autobook toc.html
website online book on the subject.
3 OPTIMIZATION FOR ATHLON AND PENTIUM 6
#############################################################
# Canonical arch names and numbers
3 OPTIMIZATION FOR ATHLON AND PENTIUM 7
#############################################################
# Canonical OS names and numbers
os_canon: Linux: Linux 1
#############################################################
# For a given uname().machine, the default build architecture
buildarchtranslate: i686: i686
#############################################################
# Architecture compatibility
arch_compat: i686: i686
and replace i686 with the word athlon everywhere in the file.
If you have an AMD K6-II or K6-III, replace i686 with the word i586
everywhere in the file. Both the K6-II and K6-III can execute MMX instruc-
tions. See:
cat /proc/cpuinfo
other optimization flags such as -ffast-math but I recommend you read the
manual on gcc 1 before applying them. In fact this is all I use on my Athlon
XP 1600+ model 662 for maximum stability:
“The build root is not the root directory under which the software
is built. Rather, it is the root directory for the install phase of
the build. When a build root is not specified, the software being
packaged is installed relative to the build system’s root directory.”
Let’s study the first situation in a bit more detail. Say, for example, that
sendmail is to be packaged. In the course of creating a sendmail package,
the software must be installed. This would mean that critical sendmail files,
such as sendmail.cf and aliases, would be overwritten. Mail handling on the
build system would almost certainly be disrupted. In other words, simply
building a new version RPM without BuildRoot will silently overwrite files
of the installed RPM.
1
Run the command man gcc in a shell.
3 OPTIMIZATION FOR ATHLON AND PENTIUM 9
4. Start optimizing; after making sure you have /etc/rpmrc simply run
the following command:
5. If you have no errors once the compilation finished you will find all the
optimized packages in one of the directories below, depending on what
architecture you set in your rpmrc file.
/usr/src/packages/RPMS/i586/
/usr/src/packages/RPMS/i686/
/usr/src/packages/RPMS/athlon/
6. Just install your freshly optimized RPMs and enjoy the extra speed
they bring to your server or desktop computers. Of course if you have
more than one computer these optimized packages can be installed on
any other with a similar setup.
The -bb option is invoked with one hyphen -bb only as opposed to two in
–rebuild.
By far the easiest way to check if you have all the required packages
installed is to open a shell and type ‘rpm -q ’, next open the qt.spec file,
copy and paste the required package names into the shell and press enter.
Quick and easy to check even 50 package names this way.
5 OPTIMIZING KDE 12
5 Optimizing KDE
5.1 Optimizing KDE in the correct order
I found that upgrading to a newer optimized KDE package to be very simple
given you are following these steps.
• Make sure you optimize and install QT first. See the Optimizing QT
for KDE section.
• Before you can start optimizing kdelibs for your own cpu, you will
need to download and install the kdelibs-devel.rpm package. Kdelibs-
devel.rpm contains libraries and header files that are used in the opti-
mization/compilation process. Optimize kdelibs. Just before installing
the optimized KDE libaries, log out from KDE to a console then install
the new libraries.
• At this point you can optimize and install any of the other KDE pack-
ages in any order.
6 Optimizing XFree86
6.1 Faster GUI for gamers and all
If you are feeling ambitious to rebuild XFree86 from the xf86.src.rpm (some-
times just called xf86.spm) install xdevel, bison, libusb and glidesdk. Down-
load the rather large 45MB xf86.spm file containing the source code for
XFree86 and start optimizing as:
You can see from the output that the Build Host: babe.local (in my case)
is the local computer. Not a difficult process as you can see and thanks to
RPM you can run XFree86 at maximum speed now.
Note:If your build breakes, the rule applies here just like on earlier pages
to check in the specifications file /usr/src/packages/SPECS/xf86.spec the
dependencies to make sure you have all required components installed for a
successful build.
7 APPENDIX 14
7 Appendix
7.1 About the author
Frank Kruchio graduated in 2001 with a B.Sc. in Computer Science from
Victoria University of Wellington, New Zealand. Most of his spare time is
devoted learning about Linux and computers in general; but he also enjoys fly
fishing. You can contact the author at frank.kruchio@paradise.net.nz.
7.2 Feedback
As always there is room for improvement and this tutorial is no exception. If
you have any constructive ideas or comments you like to add or seen included
in the next version of this tutorial please feel free to e-mail your ideas. I look
forward to hearing from you!
2
Linux optimization February 2, 2002