Tweaking GNU/Linux performance
From TheLinuxVault
GNU/Linux usually has a perfectly stable configuration out-of-the-box, but it is always possible to tweak things to speed up the performance in our system. This guide will head you to different tweaks that will increase the performance of your system, BUT:
Be aware that all modifications are made as root user, so you may need to omit some steps if you don't know what exactly are you doing!
Contents |
[edit] System tweaking
[edit] Swappiness
Swappiness is the amount of virtual memory (swap partition) your computer is ordered to use. It is set to 60% in newer kernels, but computers with a high amount of RAM can run faster if less memory is swapped and more is directly used. For computers with 1GB RAM or more, a value between 0 and 5 works well. You can check the performance you get modifying the swappiness with the command:
sysctl -w vm.swappiness=[value]
Where value is the amount of memory that will be swapped. When you find a value which fits you (I use 0 or 5), you can make the changes permanent editing the file /etc/sysctl.conf by adding this line at the end:
vm.swappiness=5
[edit] DMA
Direct memory access (DMA) is a feature of modern computers, that allows certain hardware subsystems within the computer to access system memory for reading and/or writing independently of the central processing unit. Enabling DMA may improve performance in your disk drives.
Let's imagine the unit where DMA wants to be enabled is /dev/hdb. You can check whether you have DMA enabled or not with the command:
hdparm /dev/hdb
If you get the output:
using_dma = 1 (on)
DMA is already enabled. If not, you can enable it by typing:
hdparm -d1 /dev/hdb
or, for setting it to the highest level:
hdparm -u1 -S60 -a1024 /dev/hda
However, in order for the settings to be automatically applied at boot there you need to edit the /etc/hdparm.conf script, adding the following to the end of it:
/dev/hdb {
dma = on
}
[edit] Removing unused tty's
By default, many Linux distributions have six tty's (command prompts) which are accesible through the key bindings CTRL+ALT+F1 to CTRL+ALT+F6. They are a handy option in case X server crashes or you have any other problems with tty7 (the visual enviroment), but you may not need the six of them, and deactivating some of them will speed up your system. For doing that, edit the file /etc/inittab and comment the lines:
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6
if you want to deactivate tty2, 3, 4, 5 and 6.
[edit] Prelinking
Prelink is intended to speed up a system by reducing the time a program needs to begin. Actual results have been mixed, but it seems to aid systems with a large number of libraries by sharing them between programs, such as KDE. To install Prelink just type:
apt-get install prelink
And configure it editing the file /etc/default/prelink by modifying the line:
PRELINKING=unknown
to:
PRELINKING=yes
You should execute prelink periodically in order to refresh its library database. It takes a while the first time, and it should be called with:
/etc/cron.daily/prelink
[edit] Removing junk files
Several commands are using for cleaning up rubbish in your system (in case you don't have them, you can install them with apt-get install [commandname], like:
apt-get clean
apt-get autoclean
deborphan
or
debfoster
localepurge
An automated way for cleaning up is:
sudo apt-get update; apt-get dist-upgrade; apt-get remove; apt-get autoremove; apt-get clean; apt-get autoclean; rm -r /tmp/*
[edit] X.Org
We can tweak the file /etc/X11/xorg.conf when using OpenSource Drivers by modifying the Device section, as it shows below (only neccesary for ATI cards):
Option "EnablePageFlip" # improves performance on 3d acceleration
Option "AGPMode" "1/2/4/8" # agp speed (choose one)
Option "AGPSize" "32/64/128" # manually set agp aperture, kinda like shared memory (choose one)
Option "AccelMethod" "xaa" # exa is still rigged, use xaa until they solve the 2d acceleration issues.
Option "XAANoOffscreenPixmaps" # generic optimization for 2d acceleration, disables XAA offscreen pixmaps
Option "DynamicClocks" "on"
Option "ColorTiling" "on"
Option "FBTexPercent" "95"
If you don't mind, you also can improve the general performance of the visual enviroment reducing DefaultDeph color from "24" to "16".
[edit] Turn off (mute) system beep
To permanently disable the PC speaker even after reboots, add this to /etc/rc.local before the last line (exit 0):
modprobe -r pcspkr
[edit] Redistributing RAM usage
The following command will redistribute the way your RAM memory does output graphic information. This would considerably speed up the way buttons, scrollbars, and other items show up when a window is maximized or restored, for example.
echo "base=0x98000000 size=0x8000000 type=write-combining" >| /proc/mtrr
[edit] Optimizing KDE
Executing kcontrol, we can modify a lot of parameter about the visual enviroment, and some of them can be set in order to improve performance. Those are:
Look & Feel - Style - Effects - Deactivate all effects.
Look & Feel - Background - No background (if you don't need it).
Look & Feel - Launch Notification - Busy passive cursor, set all values to 0 seconds.
Desktop - Window Behaviour - Animate minimizing and restoring - Deactivate it.
Desktop - Desktops - Set it to 1 (if you don't need more).
Sounds and Multimedia - Notifications - Deactivate all sounds.
Sounds and Multimedia - Sound system - Deactivate it (use ALSA instead).
I also recommend to install Dolphin instead Konqueror. It is much faster and lightweight.
[edit] Speeding up boot time
[edit] Removing unnecessary services
We can speed up our boot time by reducing the number of services started with the system. For doing that, we are going to use the tool sysv-rc-conf, which can let us manage easily the services we want to enable or not when my computer boots. We can install it through the official repositories:
apt-get install sysv-rc-conf
When executed on a terminal, we will see the list of services we have activated and in which init mode they are. It is important to say that there are some services you shouldn't change in order to keep things functioning internally. Those are:
acpid, binfmt-support, bootlogd, dbus, klogd, halt, ifplugd, ifupdown, kdm, klogd, libdevmap, module-init-tools, networking, rc.local, reboot, sendsigs, single, stop-bootlogd, sysklogd, udev, udev-mtab, umontfs, umountroot, urandom, x11-common...
Plus any others you should need due to specific hardware, as alsa-utils, atievetsd, bluetooth, fuse...
More information is avaiable on here in case of doubt: Please make sure you know what you are doing; otherwise, you may harm your system.
[edit] Starting services in concurrency mode
Another way for improving our boot time is to make all services start paralelly. To do so, you only need to open the file:
/etc/init.d/rc
and change:
CONCURRENCY=none
to:
CONCURRENCY=shell
Done. Now your boot time should be much quicker than before.
[edit] Internet Tweaking
[edit] IPV6
To deactivate IPV6, you need to edit the file:
/etc/modprobe.d/aliases
by adding the lines:
alias net-pf-10 ipv6 off
alias net-pf-10 off
alias ipv6 off
and commenting / removing the line:
alias net-pf-10 ipv6
This will speed up noticeably Internet applications, including Firefox and Google Earth.
[edit] Firefox
You can access quite a lot of network parameters in Firefox by typing in the address bar about:config. Once there, the following variables may be modified / added:
network.dns.disableIPv6 of the type boolean, set to true
nglayout.initialpaint.delay of the type integer, set it to 10
content.interrupt.parsing of the type boolean, set to true
content.max.tokenizing.time of the type integer, set it to 8
content.notify.backoffcount of the type integer, set it to -1
content.notify.interval of the type integer, set it to 2
content.notify.ontimer of the type boolean, set to true
For general tweaking in Firefox / IceWeasel / Swiftfox, get FasterFox, a very powerful extension that will greatly increase your browsing speed in these clients.
As for the system networking tweaking, this command will speed things up a bit:
perl -pi -e s/ipv6/off/ /etc/modprobe.d/aliases && echo "net.ipv4.tcp_moderate_rcvbuf=0" >> /etc/sysctl.conf && echo "net.ipv4.tcp_default_win_scale=0" >> /etc/sysctl.conf
[edit] MTU
The term Maximum Transmission Unit (MTU) refers to the size (in bytes) of the largest packet that a given layer of a communications protocol can pass onwards. MTU parameters usually appear in association with a communications interface (NIC, serial port, etc.). Adjusting MTU can improve your network experience, and in some cases even speed it up. You can adjust the MTU with the following command:
ifconfig [interface] mtu [value]
Where [interface] refers to your network interface (in my case, ath0) and [value] to the value you want to assign MTU. I've experienced that 1450 works fairly good in my box, so I adjusted:
ifconfig ra0 mtu 1450
[edit] Checking /etc/resolv.conf
Make sure that you /etc/resolv.conf file only has your DNS servers, in order to let the system access faster to them. In my case, I use OpenDNS, which I higly recommend, so my entire content of this file is:
nameserver 208.67.222.222
nameserver 208.67.220.220
A corrupted /etc/resolv.conf file may cause several problems in DNS look up, so double-cheking this file is more important than it seems to be, as far as some distributions add rubbish lines to this file.
[edit] /etc/hosts
The file /etc/hosts may content by default:
127.0.0.1 localhost
127.0.1.1 [youhostname]
Replacing the previously lines with:
127.0.0.1 localhost [yourhostname]
127.0.1.1 [yourhostname]
is believed to speed up applications launch which use network functions.
[edit] Checking /etc/syctl.conf
This are some values to optimize broadband settings, although they are not tested
net.core.rmem_default = 524288
net.core.rmem_max = 524288
net.core.wmem_default = 524288
net.core.wmem_max = 524288
net.ipv4.tcp_wmem = 4096 87380 524288
net.ipv4.tcp_rmem = 4096 87380 524288
net.ipv4.tcp_mem = 524288 524288 524288
net.ipv4.tcp_rfc1337 = 1
net.ipv4.ip_no_pmtu_disc = 0
net.ipv4.tcp_sack = 1
net.ipv4.tcp_fack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_ecn = 0
net.ipv4.route.flush = 1
You have to reset your sysctl for these to take effect.
sudo sysctl -p
[edit] Concluding...
You have just made a lot of changes to your system. Re profiling your boot will reorganize it and make it faster on boots afterwards. For doing so, Reboot your PC. When you come to your grub list, hit escape to see your grub menu and edit the topmost line and add the word below to the end of it:
profile
Once finished, reboot one last time.

