LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-23-2015, 11:25 AM   #1
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: Slackware®
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
How to change the Swappiness of your Linux system


Hi,

How to change the Swappiness of your Linux system
Quote:
Most of Linux users that have installed a distribution before, must have noticed the existence of the “swap space” during the partitioning phase (it is usually found as /sda5). This is a dedicated space in your hard drive that is usually set to at least twice the capacity of your RAM, and along with it constitutes the total virtual memory of your system. From time to time, the Linux kernel utilizes this swap space by copying chunks from your RAM to the swap, allowing active processes that require more memory than it is physically available to run.

Swappiness is the kernel parameter that defines how much (and how often) your Linux kernel will copy RAM contents to swap. This parameter's default value is “60” and it can take anything from “0” to “100”. The higher the value of the swappiness parameter, the more aggressively your kernel will swap.
 
Old 06-23-2015, 12:00 PM   #2
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
The article you linked promotes terrible misinformation on the meaning and effect of swappiness.

Don't tweak what you don't understand.

Quote:
The parameter value set to 60 means that your kernel will swap when RAM reaches 40 capacity.
That part of the article is total garbage. The rest of the article is based on that fundamental misunderstanding, so the whole article will just misinform.

A much more insightful simplification of the meaning of swappiness, would be to say that it represents the relative cost of spilling and reloading anonymous memory vs. non anonymous memory, where a swappiness of 100 implies equal cost and a swappiness of 0 implies non anonymous memory spills and reloads at zero cost.

Using a single traditional hard drive, anonymous memory spills and reloads (through swap space) for on average twice the cost of non anonymous memory reloading from its file backing. A non symmetric performance media (flash) would tend to increase that two to one difference (so optimum swappiness would be lower than the default, but not as low as zero). Multiple and/or mixed media may have a complex impact, generally not worth micro managing. If most rereads are from flash (rather than traditional hard drive) lower swappiness for better performance.

Last edited by johnsfine; 06-23-2015 at 12:11 PM.
 
Old 06-23-2015, 05:10 PM   #3
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: Slackware®
Posts: 13,925

Original Poster
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Member response

Hi,

As with most things there are always others who sense of how things should be setup;
http://unix.stackexchange.com/questi...-60-by-default
Quote:
The default value has most likely been chosen as an approximate middleground between these two extremes. As with any performance parameter, adjusting vm.swappiness should be based on benchmark data comparable to real workloads, not just a gut feeling.
In the original post I found that argument interesting. I setup my Laptop SSD install
Code:
~# cat /proc/sys/vm/swappiness
1
I have found better performance utilizing that setting for my system. Each too their own. I feel that since pages that are anonymous have no filesystem backing then the lose may cause issue with these pages which should remain in memory as long as needed unless swap space is available.

Just my thoughts.
 
Old 06-24-2015, 07:54 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,124

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
swappiness is up there with loadavg - might have seemed like a good idea at the time. Pity no-one understands them.
I wonder if Linus regrets ever allowing either to be included.

Last edited by syg00; 06-24-2015 at 08:27 AM.
 
Old 06-24-2015, 08:37 AM   #5
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by syg00 View Post
swappiness is up there with loadavg - might have seemed like a good idea at the time. Pity no-one understands them.
I wonder if Linus regrets ever allowing either to be included.
Swappiness can be an important and useful feature if you understand it. I would hope some distribution install programs understand it, detect flash devices and reduce swappiness (but I don't know whether any do).

I think the name of the parameter greatly increases the misunderstanding by those who think they know what it means. I don't know a good name. But if someone in control had regrets about the feature, it shouldn't be about having the feature. It should be about giving the feature a name that people think they understand. With an obscure name that no one understands, the feature would be just as useful and much less harmful.

Long ago, very expensive servers might have expensive high-speed, low-capacity hard drives combined with other lower-speed higher-capacity drives, all with inadequate ram. Then placing swap on the faster drive and tuning swappiness above default would be a key performance tweak. With current hardware, I can't think of any reason for above default swappiness. But most systems that do their program loading from flash should have below default swappiness, and those which also have data files and/or swap in flash, even more so.

Last edited by johnsfine; 06-24-2015 at 08:46 AM.
 
  


Reply

Tags
kernel parameter, swap, swappiness



Posting Rules
You may not post new threads
You may not 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



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to change the Swappiness of your Linux system LXer Syndicated Linux News 0 06-19-2015 08:20 AM
What does swappiness do ? LostObjext Linux - Newbie 2 10-16-2013 09:03 PM
Reducing swappiness value 5.2.8 starkadder Puppy 8 11-26-2011 01:22 AM
Swappiness Jake_B Red Hat 1 10-21-2005 02:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration