General System Optimization
Overview
At this stage of your configuration, you should now have a Linux server well configured and secured. Our server contains the most essential package and programs installed to be able to work properly and the most essential general security configuration. Before we continue in our steps and begin to install the services we want to share with our customers, it is important to now tune our Linux server. The tuning we will perform in the following parts will be applied to the whole system. It also applies to present as well as future programs, such as services that we will later install. Generally, if you don’t use a x386 Intel processor, Red Hat Linux out of the box is not optimized for your specific CPU architecture (most people now run Linux on a Pentium processor). The sections bellow will guide you through different steps to optimize your Linux server for your specific processor, memory, and network, as well as your file system.
The “/etc/profile” file
The “/etc/profile” file contains system wide environment stuff and startup programs. All customizations that you put in this file will apply for the entire variable environment on your system, so putting optimization flags in this file is a good choice. To squeeze the most performance from your x86 programs, you can use full optimization when compiling with the -09 flag. Many programs contain -02 in the Makefile. -09 is the highest level of optimization. It will increase the size of what it produces, but it runs faster.
NOTE: It is not always true that the “-09″ flag will make the best performance for your processor. If you have an x686 and above processor, surely, but below x686, not necessarily.
When compiling, use the “-fomit-frame-pointer” switch for any kind of processor you may have. This will use the stack for accessing variables. Unfortunately, debugging is almost impossible with this option. You can also use the -mcpu=cpu_type and -march=cpu_type switch to optimize the program for the CPU listed to the best of GCC’s ability. However, the resulting code will only be run able on the indicated CPU or higher.
Below are the optimization flags that we recommend you put in your “/etc/profile” file depending on your CPU architecture. The optimization options apply only when we compile and install a new program in our server. These optimizations don’t play any role in our Linux base system; it just tells our compiler to optimize the new programs that we will install with the optimization flags we have specified in the “/etc/profile” file.
Stepi
For CPU i686 or PentiumPro, Pentium II, Pentium III
In the “/etc/profile” file, put this line fora PentiumPro, Pentium II and III Pro Processor family:
CFLAGS=’-09 -funroll-loops -ffast-math -malign-double -mcpu=pentiumpro -march=pentiumpro -fomit-frame-pointer-fno-exceptions’
For CPU i586 or Pentium
In the “/etc/profile” file, put this line for a Pentium Processor family:
CFLAGS=’-03 -march=pentium -mcpu=pentium -ffast-math -funroll-loops -fomit-frame-pointer -fforce-mem -fforce-addr -malign-double -fno-exceptions’
For CPU i486
In the “/etc/profile” file, put this line for a i486 Processor family:
CFLAGS=’-O3 -funroll-all-loops -malign-double -mcpu=i486 -march=i486 -fomit-frame-pointer -fno-exceptions’