[SATLUG] Swappiness in Ubuntu

Daniel J. Givens daniel at rugmonster.org
Sat Apr 26 20:09:19 CDT 2008


Chris Lemire wrote:
> 
> ed <horned0wl93 at gmail.com> wrote: Hi Folks;
> 
> I have some rather interesting questions regarding RAM swapping in
> Ubuntu or other Debian-based Linux OS.  I've just increased my Acer
> laptop's RAM from 1GB to 2.5GB by replacing a 512MB SODIMM with a 2GB
> SODIMM (1.8GHz CPU).  BIOS and system both acknowledge the increase, and
> my system now runs somewhat faster.  But, as well as faster, I'm looking
> for "better."  My questions relate to optimizing performance based on
> this new increase.  I've seen/read a lot of debate on modifying the
> "swappiness" value, the percentage of RAM content swapped to disk at any
> given moment.  My current setup looks like this:
> 
>> root at xxxx:/# free -m
>>              total               used       free     shared   
>> buffers     cached
>> Mem:    2470                 809      1660              0            
>> 25          367     (misnomer: 32MB shared to video)
>> -/+ buffers/cache:        416       2054
>> Swap:     721                    0          721
>> root at xxxx:/# cat /proc/sys/vm/swappiness
>> 60
>> root at xxxx:/#
> My questions: 
> 
> 1. Is there a need to change swappiness based on increased RAM?  Note:
> Changing my swappiness (values ~ 0-100) via sysctrl.conf to "1" seemed
> to have an inverse effect on CPU use, increasing cycles tremendously,
> and maxing it out more often than Ubuntu's default setting of "60."

Short answer, no. The long answer summed up is also no. That default of 
60 is the Linux kernel default.

> 2. If I do need to change swappiness, what's a good value?  Why?  Why
> not? What's gained? What's lost?

I've never heard a really good reason one way or the other for changing 
your swappiness higher or lower. You're system isn't using swap now. It 
isn't a bad thing if it does use swap, because it probably needs it at 
that time. I don't think you'll see any gains by adjusting the 
swappiness value. You'll know if you're hitting swap and I'm going to 
bet it won't be because you have a swappiness set to X when it could be 
at Y.

http://forums.gentoo.org/viewtopic.php?t=175419

To a large extent, you're looking at the difference of how the kernel is 
going to likely handle whether cached memory gets swapped to disk or 
just dropped when the system _runs out of memory_. You have 2GB and 
2.5GB of memory. You aren't going to have to worry about swap very much 
unless you're running a server or doing some heavy work.

> 3. Are there any other values besides or instead of swappiness that'll
> increase or optimize performance?  How would these or other changes
> affect system stability?  Hardware performance?  Hardware life-cycle?

Sure there are and they're all dependent on what you're doing with your 
system and what hardware you have. You're asking a much bigger set of 
questions that you realize. If you're really interested in this, you 
need to go do some searching of the Google. There are a lot of factors 
that determine what "performance" means. System tuning and optimization 
is a deep subject that can't be covered in a couple of mailing list 
posts. I wouldn't advise making kernel level changes unless you fully 
understand what it is you're changing and what how it might affect your 
system.

Daniel


More information about the SATLUG mailing list