Linux Performance Tuning - Overclock.net - An Overclocking Community
Forum Jump: 

Linux Performance Tuning

Reply
 
Thread Tools
post #1 of 77 (permalink) Old 09-21-2008, 04:09 PM - Thread Starter
Retired Staff
 
error10's Avatar
 
Join Date: Sep 2008
Location: Manchester, New Hampshire
Posts: 13,477
Rep: 1516 (Unique: 918)
You're running Linux, now it's time to make it run faster! I've been using Linux since 1993 () and I learned a few things along the way.

Most of these changes will improve your performance, a few I threw in because they'll make your system more stable. Enjoy!

Sysctl

The system control facility lets you tune dozens of little bits of the Linux kernel. For performance gains only a few of them are really relevant. You change these by editing the /etc/sysctl.conf file and then running sysctl -p (or rebooting).

vm.oom_kill_allocating_task = 1
By default when Linux runs out of memory it goes through the process list and starts killing off processes that it thinks are using too much memory. This sysctl makes Linux kill the runaway process that made the system run out of memory instead, which is usually what you want.

vm.page-cluster = 5
When Linux reads from the swap file it reads 2^page-cluster pages at once. It won't help to raise it past 5 because the swap is laid out in 32-page clusters.

Disk I/O

relatime
This option is a more intelligent way of tracking disk accesses that dramatically reduces disk writes and increases disk performance. Check your /etc/fstab file and for your filesystems that are listed as ext2/ext3 in the third column, in the fourth column take out "defaults" or "noatime" if they're present and replace them with "relatime". If neither of those two are present in the fourth column, then add ",noatime" to whatever is there. You need to reboot for this to take effect.

Defragmentation
This comes up often enough I may as well say a word. You don't have to. Seriously, you don't have to. The Linux ext2/ext3 filesystem is much more efficient and requires no defragmentation. Its performance does start degrading once it's around 95% full, though, so if you're at that point, go delete some ISO images or buy a new hard drive. Use the df -h command to check your filesystem capacity.

Readahead
When Linux reads a part of a file from disk, it can also "readahead" past the requested data blocks, before the program using the file requests them. (This is subtly different from the userspace readahead discussed below.) By default Linux will read ahead 128KB of data so that it's already in memory cache before the program needs it. For today's systems (RAID arrays, etc.) this may be too low. For instance, with the Dell PERC 5/i RAID card, OCN members found that turning off the RAID card's internal readahead and using a Linux readahead of 16MB gave the fastest performance. You can set the Linux readahead using the blockdev command. Some examples:

blockdev --getra /dev/sda
Shows you (in 512-byte blocks) the system readahead.

blockdev --setra 32768 /dev/sda
Sets the system readahead to 16MB (32768 512-byte blocks).

You'll probably need to experiment and benchmark to find the best value for your particular system, but any value above the default should give you better disk performance.

Memory

Your hard drive might have a 16MB or 32MB onboard cache and be linked to your CPU via a 100MHz PCI Express bus. Wouldn't it be nicer if you had, say, 2GB of disk cache linked 1:1 with your FSB? Well, with Linux, you do! Linux uses any free memory as a dynamically expanding and shrinking disk cache, and several of the tips below take advantage of this. To be fair, Windows does this too, just not as well, as anyone who's played with Vista's SuperFetch knows. So the performance tip here is: Buy more RAM.

Applications

preload
This package does for Linux what SuperFetch does for Windows Vista: it monitors your application usage and then whenever you boot up your system it will load your most frequently used applications into RAM while you're staring at the login prompt. The Linux version is different, though: It actually works. And Linux had it first. Preload isn't installed by default so you'll have to install it from your package manager. (It's a boot service; be sure to enable it.)

readahead
This package is related to preload but it's tuned specifically for the boot process. It starts early in the boot process and starts preloading a list of files into memory which will be used in the startup scripts that run later. This will help shave a few seconds off the boot process because these files can load while the system is busy doing other things like getting a network address. Readahead is installed by default on some distributions but not others, so you'll want to check and see if you have it, and if not, install it from your package manager and enable its boot services. (On Fedora the services are readahead_early and readahead_later; on old versions of Ubuntu it's just readahead, and in current versions the service names are are early-readahead and later-readahead. In all cases, the package name to install is readahead.)

I had better mention how to enable boot services:
On Fedora you run su -c /sbin/chkconfig <servicename> on
On Ubuntu you run sudo update-rc.d <servicename> defaults

That's all for now!

I might think of a few things later; if I do, I'll update this post and bump it. Enjoy your performance tuned Linux box!

I will not be pushed, filed, stamped, indexed, briefed, debriefed, or numbered! My life is my own.
I did error10's Windows Challenge and I now am an MCSE: Minesweeper Consultant and Solitaire Expert! graduated.gif
Sorry, I'm unable to provide technical support in private messages.


error10 is offline  
Sponsored Links
Advertisement
 
post #2 of 77 (permalink) Old 09-21-2008, 06:04 PM
New to Overclock.net
 
hybrid-kernel's Avatar
 
Join Date: Jun 2008
Posts: 407
Rep: 60 (Unique: 56)
I have a few more:

Mount ext2/3 partitions with writeback
It generally speeds up the system, but not a whole lot. You need to add data=writeback to /etc/fstab to the parameters column and add rootflags=data=writeback to your /boot/grub/menu.lst

Low swap priority
Just google vm.swappiness.

Disable unneeded daemons
It really does speed your boot up. I usually disable things like anacron, system log and virtualbox daemons. Helps quite a bit.

Use both cores on boot
By default, your system probably only uses 1 core, having more will help, but usually I'm bottlenecked by slow disk reading speeds. If you use a debian based distro, in the file /etc/ini.d/rc change concurrency=none to concurrency=shell.

Compile a custom kernel
Take out those unused modules and components. Most distros come with a generic kernel that supports a multitude of hardware. But since you probably don't have all of it, it makes sense to remove unused components. You can google for a guide for compiling for your distro.

Thats all from the top of my head.
hybrid-kernel is offline  
post #3 of 77 (permalink) Old 09-22-2008, 01:41 AM - Thread Starter
Retired Staff
 
error10's Avatar
 
Join Date: Sep 2008
Location: Manchester, New Hampshire
Posts: 13,477
Rep: 1516 (Unique: 918)
Hm, some of these options I like, some I don't.

data=writeback will definitely improve your performance a bit, but it runs the risk of data corruption in the event your system suddenly goes south (e.g. because you overclocked too far).

vm.swappiness I considered adding in, but it's a tricky parameter and there is no one good setting for it. It's something you have to play with. And if you've got 4GB or more of RAM you aren't likely to run into many situations where changing it will help you.

Disabling unnecessary services is a good one. Though what one person considers unnecessary another considers vital. I'd never disable the system log or the VirtualBox service; I use both of those!

concurrency=shell is something specific to Ubuntu (or maybe all Debian based systems) though most distributions have some means of parallel startup.

And I wasn't even about to attempt to explain how to build a custom kernel. Though it's true you'll save some hard drive space, the performance benefits are negligible. And what happens when you upgrade? All those modules mean you can plug almost anything into your box and the system will bring it up without even bothering you about it.

So those are all good ideas but they have their downsides which people should be aware of before they go and do them.

I will not be pushed, filed, stamped, indexed, briefed, debriefed, or numbered! My life is my own.
I did error10's Windows Challenge and I now am an MCSE: Minesweeper Consultant and Solitaire Expert! graduated.gif
Sorry, I'm unable to provide technical support in private messages.


error10 is offline  
Sponsored Links
Advertisement
 
post #4 of 77 (permalink) Old 09-22-2008, 02:57 AM
New to Overclock.net
 
thiussat's Avatar
 
Join Date: Apr 2008
Location: USA
Posts: 1,560
Rep: 222 (Unique: 156)
Quote:
Originally Posted by hybrid-kernel View Post
I have a few more:

Disable unneeded daemons
It really does speed your boot up. I usually disable things like anacron, system log and virtualbox daemons. Helps quite a bit.
I can see disabling anacron if you never use it, but I think disabling the system logger is a big mistake.

thiussat is offline  
post #5 of 77 (permalink) Old 09-22-2008, 03:03 AM
New to Overclock.net
 
thiussat's Avatar
 
Join Date: Apr 2008
Location: USA
Posts: 1,560
Rep: 222 (Unique: 156)
Quote:
Originally Posted by error10 View Post
Hm, some of these options I like, some I don't.


And I wasn't even about to attempt to explain how to build a custom kernel. Though it's true you'll save some hard drive space, the performance benefits are negligible. And what happens when you upgrade? All those modules mean you can plug almost anything into your box and the system will bring it up without even bothering you about it.
I prefer to customize my kernel. Then again I run Gentoo and it is pretty much standard to compile your own (I prefer manual compiling and not "genkernel.")

While taking out unused modules may not really impact anything other than a couple of megs of HD space, there are several other performance advantages you can gain by customizing (like setting your processor architecture).

When I use binary distros, I don't usually fool with the kernel because none of the non-kernel apps are compiled locally anyway. With Gentoo I compile everything on my system myself (except for the stage3 tarball libs).

thiussat is offline  
post #6 of 77 (permalink) Old 09-22-2008, 03:05 AM - Thread Starter
Retired Staff
 
error10's Avatar
 
Join Date: Sep 2008
Location: Manchester, New Hampshire
Posts: 13,477
Rep: 1516 (Unique: 918)
Quote:
Originally Posted by thiussat View Post
When I use binary distros, I don't usually fool with the kernel because none of the non-kernel apps are compiled locally anyway. With Gentoo I compile everything on my system myself (except for the stage3 tarball libs).
emerge --emptytree world

I will not be pushed, filed, stamped, indexed, briefed, debriefed, or numbered! My life is my own.
I did error10's Windows Challenge and I now am an MCSE: Minesweeper Consultant and Solitaire Expert! graduated.gif
Sorry, I'm unable to provide technical support in private messages.


error10 is offline  
post #7 of 77 (permalink) Old 09-22-2008, 03:21 AM
Starting to become a BOFH
 
legoman786's Avatar
 
Join Date: Mar 2006
Location: Tucson, AZ
Posts: 10,463
Rep: 364 (Unique: 304)
Interesting...

Repped.

Quote:
Originally Posted by Syrillian go_quote.gif
The persistance of a human may never win against the persistance of time, but the fruits of the labors are wonderous to behold, even in our brevity.
⚜ R.I.P Syrillian ⚜
8/13/2011


legoman786 is offline  
post #8 of 77 (permalink) Old 09-22-2008, 05:59 AM
Retired Staff
 
-iceblade^'s Avatar
 
Join Date: Apr 2008
Location: Equestria :D
Posts: 16,925
Rep: 814 (Unique: 613)
i agree this IS interesting...

compiling your own distro? not something i would dare do, being still very young at all this

R.I.P Syrillian
Blitz6804, ... you watch too many telecomunications commercials XD
staryoshi: Your wallet is tight like a clam. Let it breathe like a fish
JCG: you spent half of your life studying for a job, and the other half complaining about the said job
Afrodisiac; You are such a hypocrite it's not even funny
Herschel
(12 items)
CPU
Intel Core i7 4770K
Motherboard
ASRock Z87M Extreme4
GPU
Sapphire RX 5700 Pulse 8GB
Hard Drive
1x 60GB SSD 1x 500GB, 1x 640GB, 1x 1TB
Optical Drive
Asus something or other
Power Supply
Seasonic X650
Case
Antec P180 Mini White
Operating System
Windows 7 Ultimate x64
Monitor
Acer H236HLbid (23" 1920x1080)
Monitor
Asus VE198 (19". 1440x900)
Keyboard
Microsoft Sidewinder X4
Mouse
Logitech G500
▲ hide details ▲


-iceblade^ is offline  
post #9 of 77 (permalink) Old 09-22-2008, 01:21 PM
New to Overclock.net
 
jul3z's Avatar
 
Join Date: Jan 2008
Location: Round Lake, IL
Posts: 749
Rep: 61 (Unique: 56)
I'd be interested to learn about that also, but just barely getting into Linux.
The one thing i have going for me is that regarding computers and systems, i learn fast and am not affraid of breaking things that are fixable. (thanks to my dad letting me rip the guts outta the family pc when i was 9. or wait, maybe he didn't let me....)

jul3z is offline  
post #10 of 77 (permalink) Old 09-22-2008, 01:45 PM - Thread Starter
Retired Staff
 
error10's Avatar
 
Join Date: Sep 2008
Location: Manchester, New Hampshire
Posts: 13,477
Rep: 1516 (Unique: 918)
Quote:
Originally Posted by jul3z View Post
I'd be interested to learn about that also, but just barely getting into Linux.
The one thing i have going for me is that regarding computers and systems, i learn fast and am not affraid of breaking things that are fixable. (thanks to my dad letting me rip the guts outta the family pc when i was 9. or wait, maybe he didn't let me....)
You can try building a Linux From Scratch. You get to learn how all the internals are put together and feel the distro maintainers' pain.

I recommend doing it in a virtual machine.

I will not be pushed, filed, stamped, indexed, briefed, debriefed, or numbered! My life is my own.
I did error10's Windows Challenge and I now am an MCSE: Minesweeper Consultant and Solitaire Expert! graduated.gif
Sorry, I'm unable to provide technical support in private messages.


error10 is offline  
Reply

Quick Reply
Message:
Options

Register Now

In order to be able to post messages on the Overclock.net - An Overclocking Community forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.
User Name:
If you do not want to register, fill this field only and the name will be used as user name for your post.
Password
Please enter a password for your user account. Note that passwords are case-sensitive.
Password:
Confirm Password:
Email Address
Please enter a valid email address for yourself.
Email Address:

Log-in



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page


Forum Jump: 

Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off