Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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 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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.