Ubuntu QA:
BlogBrainstormPackage status
Log in
Ubuntu QA
The Ubuntu community has contributed 21986 ideas, 135057 comments, 2615221 votes
Idea sandbox Idea sandbox
Popular ideas Popular ideas
Ideas in development Ideas in development
Implemented ideas Implemented ideas
Idea #5481: Swappiness to 10, not to 60

Written by gcc the 23 Mar 08 at 10:44. Category: System. Related project: Nothing/Others. Status: New
Rationale
Swap the rows come controlled and managed from one variable of the kernel called swappiness. This variable is valued from 0 to 100. IF the value is high there are greater probabilities of writing on the rows of swap.
A way in order to obtain of the better performances, consists in diminishing the value of this variable one. The "increase of performances" famous above all in the computers not of last generation.
Now it's automatically at 60. I think it would be better to put it at 10
There are some comments asking if it really works. OK. I did it in my ubuntu and it goes faster than with swappiness to 60 (when I open many programs). This doesn't mean that this work... but it's somenthing to think about! (try it at your systems and post the results)
I found this at Ubuntu's guide in spanish so it should work ;)
Tags: swap

118
votes
up equal down
Solution #1: Auto-generated solution of idea #5481
Written by gcc the 23 Mar 08 at 10:44.
Ubuntu Brainstorm was updated in January 2009. Since the idea #5481 was submitted before this update, its rationale and solution are not separated. Please vote accordingly, and if you have the necessary rights, please separate the rationale from the solution. Thanks!
5
votes
up equal down
Solution #2: Adjust swappiness based on maximum memory, memory speed, and swap speed
Written by undecim the 11 Dec 09 at 06:29.
A swappiness of 60 is a default which works for almost all machines. However, to take advantage of addition Ram in a computer, default swappiness should be adjusted on boot based upon:
1: Total amount of memory available to the OS
2: The speed of the memory available to the OS
3: The speed of the swap partition(s) used

Propose your solution

Attachments
No attachments.


Duplicates


Comments
tenplus1 wrote on the 23 Mar 08 at 12:10
+1 ... Windows also uses the swap constantly unless told otherwise and it really slows things down...

Auzy wrote on the 23 Mar 08 at 12:28
ok, hold on a sec.. Have you actually tested this. First test and benchmark.. I'm not voting anything, unless you have evidence this will help (other then theoretical, remember, the swap file is not only there for when ram runs out). .

Eldmannen wrote on the 23 Mar 08 at 15:24
This needs some scientific scrutinity and benchmarks.

Mike Graham wrote on the 23 Mar 08 at 16:22
Voted yes.

This vote does NOT indicate that I believe this should be implemented; this vote indicates this idea should get some attention.

XVIIarcano wrote on the 23 Mar 08 at 18:09
Just as Mike Graham... if this could help (and I really do not know enough to say) the it should be done...

If the choice of this variable is made a priori due to some needs of older (or newer) pcs, wouldn't it be possible to detect the amount of ram and of swap memory during installation and set the parameter accordingly?
I really don't know, maybe I am just saying something stupid ^_^'

Auzy wrote on the 24 Mar 08 at 00:17
I guess your right.. You earnt a +1 off me now. Doesn't constitute it will happen, just allow us to research the best swappiness factor for different amounts of ram (60 may be good for some ram amounts, 10 for others)..

Brilliant idea. +1

LostOverThere wrote on the 24 Mar 08 at 02:16
Try it out for yourself now. Its pretty easy:

http://cheesemedia.net/newsblog/?p=13

Its Tweak #2 on that blog post.

mp3phish wrote on the 24 Mar 08 at 23:13
Also please read my post about lower power states, and maybe there should be different "modes" where swappiness is automatically adjusted.

http://brainstorm.ubuntu.com/idea/4779/

Ralf.Nieuwenhuijsen wrote on the 25 Mar 08 at 20:01
The thing is, the default is optimized for server usage. To keep the troughput as high as possible, not on desktop behavior.

It's wether you want your pc to be faster assuming it is constantly working, or wether you want your pc to be more interactive.

alberge204 wrote on the 2 Apr 08 at 07:10
-1

Ubuntu is, generally speaking, already much less swappy than Windows.

On my system (1 GB RAM, 3 GB swap) it doesn't start actually using any of the swap partition until memory usage goes above around 85%. On Windows, it'd be using the swap file no matter what the memory usage was. No change is needed here.

s3a wrote on the 11 Aug 08 at 08:59
I voted it down because there is a reason why it is set to 60. And in my opinion that reason is, we need a default settings that suits ALL computers in a good way and that setting is a default swappiness value of 60. If you have a better system, you should manually edit the swappiness. Changing the setting will basically cause problems for weaker computers.

mwlundgren wrote on the 6 Sep 08 at 15:57
The default setting of 60 was thrashing my wife's laptop... in combination with recent problems with Adobe Flash the laptop was always running the hard drive and the whole computer was hot to the touch. With swappiness set to 10 (Ubuntu recomended) the computer runs cool again and is much more responsive.

As a newbie it seems that it would have been nice for this to be set to 10 by default at least for laptops. Even my machine was noticeably faster and quieter after setting swappiness to 10.

It's not hard to do, I agree, unless you don't know about it. A question or hardware check during install seems warranted. Does this computer have X amount of ram? Is this computer a notebook?

cousteau wrote on the 22 Dec 08 at 04:41
+1
I had problems with Evince and a very large .pdf - filled up 1.5 GiB RAM and 1.2 SWAP; then my system began to behave randomly.
After setting swappiness down to 10, SWAP didn't get full so fast.

Maybe the default value should be configured automatically while installing Ubuntu, depending on how much RAM and SWAP does the user have.

BikeHelmet wrote on the 9 Oct 09 at 03:31
+1

@evince: I call bullshit.

"Ubuntu is, generally speaking, already much less swappy than Windows."

Vista, perhaps. Windows XP though is lightyears ahead of Ubuntu in responsiveness, when swappiness is set at 60.

"On my system (1 GB RAM, 3 GB swap) it doesn't start actually using any of the swap partition until memory usage goes above around 85%. On Windows, it'd be using the swap file no matter what the memory usage was. No change is needed here."

On my NAS (1GB RAM, 1GB swap) Ubuntu starts swapping at about 200MB. It usually has about 180MB mem usage, 260MB swap usage. When I changed swappiness to 10, programs started coming up about 3x quicker, and the menus stopped lagging for a second when being opened. My NAS is a Ubuntu-Desktop install, modified to have a Samba server. Sometimes I watch videos on it, which is where I really noticed how much swappiness 10 helped.

To me, swappiness 10 puts it in the same league as regular XP - ahead of Vista/Win7.

OpenNingia wrote on the 9 Oct 09 at 08:02
Here is a good discussion:

http://kerneltrap.org/node/3000

undecim wrote on the 11 Dec 09 at 06:35
It would be difficult to benchmark this. What we are looking at improving here is not overall performance (if that were the case, high swappiness would be better), but desktop latency.

There are also a lot of variables to this: User habits, amount and speed of memory and swap available, etc.

Though I would like to say that after hearing my younger siblings complaining about their Ubuntu netbooks being slow, I changed the default swappiness without them knowing, and they both commented on how the netbooks were running faster (both netbooks had 1GB of RAM and 1GB of swap on SSD)

Dima Q wrote on the 9 Aug 10 at 13:54
Here's an outline of a proper explanation why swappiness should be kept low on desktops and other low-latency devices.

Basically swappiness controls whether process memory is evicted (swapped) or disk cache is cleared. If swappiness is high, files are cached, while old, unusef program bits are swapped; if swappiness is low, programs are kept in memory, but files are not cached.

Why swappiness is an issue now?
1. Now, more than ever, very large long-running programs are often used on desktops (firefox, thunderbird, X, games, etc), and on servers (mysql, etc).
2. Programs usually operate on much larger data sets than program size. While files are allocated on disk in large sequential chunks and can be pulled in quickly, swapped out program is pulled a random page at a time and are pulled in much slower. Moreover large files easily create high memory pressure compared to relatively small processes.
3. Modern disks are so large that modern desktops and laptops are almost always equipped with just one. Which means that swap is a partition next to data, thus trying to read swapped program and a data file at the same time is very slow due to head seeks. Here sensible swappiness values could be 0% or 100% but definitely not anything close to 50%.

It is a good idea not to drop swappiness to 0 and not to cut off swap entirely, because then memory pressure would quickly kill programs that are not "saved" by swap.

Recommendations:
Desktop, 1 hard drive: swappiness 5
Web server, 1 raid array, LAMP: swappiness 5

Desktop, dedicated swap: swappiness high, needs testing
Laptop or desktop, hybrid harddrive: needs testing
Laptop or desktop, SSD: needs testing

Further ideas:
Ideally large processes (e.g. thunderbird) could be split into light-weight UI and heavy backend...
Ideally kernel vm subsystem knew that md5sum dvd-image.iso will only use the data once and never again and not cache it, there are even ioctls for this already...
Ideally kernel vm could cluster program memory and bring larger chunks from swap at a time, currently normal swapin rate I get is 200-700 when system grinds at swappiness 60 compared to blockin 6000-16000 readin random files (vmstat, in KB/s (?))
Swap io could be faster in general, swapoff -a generates 1000-8000 (KB/s?) on swapped, unloaded system, about the same as ls -lR > /dev/null, while sum *gz *bz2 generates 16000-29000 (KB/s?). So in effect swap operates on chunks the size of filesystem metadata, hardly efficient...


Post your comment