K.S. Bhaskar on 12 Jul 2015 07:14:37 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] swappiness and ssd

My laptop has 8GiB RAM, and except when I run my 64-bit Win 7 virtual machine and have a lot of browser tabs open, that RAM is plenty.  But on those infrequent occasions when I have both, my system does need to swap - not much, but it does need to swap.  For years, I ran without turning on swap at all, and would monitor RAM and run swapon to turn on swap only when I saw the RAM running low.

The traditional view of swapping is that it is undesirable because reading from swap is slow, and swap should therefore be used only if unavoidable.  Therefore, the received wisdom is to set a low value of swappiness, to swap only when unavoidable, and take a performance hit when that happened.

But, write cycle limits aside, I believe SSDs require a rethink.  Reading from SSD is very fast, much faster than from rotating media.  Writing to SSDs is slow (although still faster than to hard drives).  So, setting a high value of swappiness encourages the OS to write unused pages of memory to SSD early - and the fast reading from SSD means that when a page is needed from swap, it's almost immediately available.  The RAM on the system never goes low enough for performance to take a hit.

Anyway, an ounce of experience beats a pound of speculation and expert opinion.  For me, setting swappiness to 80 with the swap space in an ordinary file in an xfs filesystem (with discard) in an encrypted partition works well, and has worked well for weeks.  So, that's what I intend to continue using.

-- Bhaskar

On Fri, Jul 10, 2015 at 5:59 PM, K.S. Bhaskar <bhaskar@bhaskars.com> wrote:
I wanted to report on my experiments with swappiness (you really have to run with something like this for a while before you can conclude anything).  Swappiness of 80 seems to be a sweet spot for my laptop with an SSD, using a swap file located on a /home partition which is itself encrypted using dm-crypt.

-- Bhaskar

On Thu, Apr 16, 2015 at 10:01 AM, K.S. Bhaskar <bhaskar@bhaskars.com> wrote:
The default swappiness on Ubuntu systems is 60, and presumably takes into consideration the relative performance of writes to and reads from the swap file / partition.  The ratio of write performance to read performance would be higher for SSDs than rotating media, since SSD reads are truly random whereas writes are in pages (in rotating media, seek and latency times would tend to apply to both).  Therefore, it seems to me that if swap is located on SSD, we should increase swappiness, to encourage less frequently used pages to be written out, since they can be brought back in very fast when needed.  Does that seem reasonable or am I missing something?  Thanks.

-- Bhaskar

Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug