Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Should swappiness be lowered for a SWAP partition on an SSD?

  1. #1
    Join Date
    Jan 2009
    Location
    Romania, Bucharest
    Posts
    887

    Default Should swappiness be lowered for a SWAP partition on an SSD?

    As the results I found on this are inconclusive, I wanted to bring up the question here as well just to hear an extra opinion. I use an SSD for my root drive, with the SWAP partition being 4 GB large and the system having a total of 16 GB of RAM. Technically I don't even need SWAP with so much RAM, but just in case my RAM ever fills up I wanted to have a little safety margin. Although my SSD is a recent model and high quality MLC drive, I'm still on the lookout to avoid writing to it more than I need to, as to not wear out its relatively sensible lifespan. Although some openSUSE Tumbleweed snapshots can dump +1 GB of updates in one day (eg: game packages) my attention has been on SWAP as the default configuration causes it to be used very quickly.

    The default swappiness is 60. What bothered me about it is that, whenever the system gets past roughly 6 GB of used memory, it begins filling the SWAP at once. With some software it can reach and stay at over 9 GB of RAM for a while, which in a few hours causes the SWAP to be filled up to 100 MB. This is pretty fast for barely exceeding half of my available RAM! As this makes rather nervous I decided to edit /etc/sysctl.conf and readd the commonly recommended vm.swappiness = 10 at the end.

    Like I said I wanted to hear second thoughts just to know if this is the right approach: Do you believe the default swappiness of 60 is considered acceptable for SWAP partitions on SSD drives? Or do others agree that for an SSD a swappiness of 10 is better?
    openSUSE Tumbleweed x64, KDE Framework 5

  2. #2
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    20,844
    Blog Entries
    14

    Default Re: Should swappiness be lowered for a SWAP partition on an SSD?

    Rule: Do not change the defaults. They are there by design and for the safety of you and your systems.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  3. #3
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    29,704
    Blog Entries
    15

    Default Re: Should swappiness be lowered for a SWAP partition on an SSD?

    Quote Originally Posted by MirceaKitsune View Post
    As the results I found on this are inconclusive, I wanted to bring up the question here as well just to hear an extra opinion. I use an SSD for my root drive, with the SWAP partition being 4 GB large and the system having a total of 16 GB of RAM. Technically I don't even need SWAP with so much RAM, but just in case my RAM ever fills up I wanted to have a little safety margin. Although my SSD is a recent model and high quality MLC drive, I'm still on the lookout to avoid writing to it more than I need to, as to not wear out its relatively sensible lifespan. Although some openSUSE Tumbleweed snapshots can dump +1 GB of updates in one day (eg: game packages) my attention has been on SWAP as the default configuration causes it to be used very quickly.

    The default swappiness is 60. What bothered me about it is that, whenever the system gets past roughly 6 GB of used memory, it begins filling the SWAP at once. With some software it can reach and stay at over 9 GB of RAM for a while, which in a few hours causes the SWAP to be filled up to 100 MB. This is pretty fast for barely exceeding half of my available RAM! As this makes rather nervous I decided to edit /etc/sysctl.conf and readd the commonly recommended vm.swappiness = 10 at the end.

    Like I said I wanted to hear second thoughts just to know if this is the right approach: Do you believe the default swappiness of 60 is considered acceptable for SWAP partitions on SSD drives? Or do others agree that for an SSD a swappiness of 10 is better?
    Hi
    I change mine to use ram before swap with a /etc/sysctl.d/98-<hostname>.conf

    Code:
    #disable swap
    vm.swappiness=1
    vm.vfs_cache_pressure=50
    I'm only running < 4GB swap on ssd's with 8 and 16GB of ram....

    It all depends on what your doing, swap can save a headache with a runaway process if I'm working on something, so can either run systemd-zram-service (A package I built/maintain), there are a few other zram tools/services available. Or just create a swap file to use on the fly and delete when finished...
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  4. #4
    Join Date
    Jan 2009
    Location
    Romania, Bucharest
    Posts
    887

    Default Re: Should swappiness be lowered for a SWAP partition on an SSD?

    Fun fact: It seems that even with a swappiness of 10, I still get roughly 10 MB of SWAP being used once my system RAM exceeds 8 GB from my total of 16 GB. This is a lot less though and something I find acceptable, I'll be leaving it at that but it's interesting to know this.

    Quote Originally Posted by Knurpht View Post
    Rule: Do not change the defaults. They are there by design and for the safety of you and your systems.
    I agree with that as a general rule. In this case I know what I'm doing, and swappiness is a safe setting to adjust especially if you have enough RAM. I went without having any SWAP at all for a few years... main reason why I added it back is that I switched from a motherboard with 24 GB of RAM to one with only 16 GB, due to the old one being DDR3 and the new one using DDR4 memory which I couldn't afford to buy as much of.
    openSUSE Tumbleweed x64, KDE Framework 5

  5. #5
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    12,772
    Blog Entries
    2

    Default Re: Should swappiness be lowered for a SWAP partition on an SSD?

    First,
    I don't know of any risk or danger in modifying swappiness, AFAIK it's a setting that modifies only the tendency of swap functionality and even at its extreme settings impose no hard limits.

    As for whether you should change the setting, I tend to say not to do so. You can tinker if you wish, but unless your setup is unusual or you're doing something very specific that's not "typical" what you do probably won't affect the system much.

    Back a ways, but not very far back I came to understand that how the OS uses the swap file had changed and wouldn't surprise me if has changed in more ways since. You may think that swap is used mainly for scenarios when you have inadequate physical RAM, but today that's only a small part of the equation, at least as important is that modern OS has learned to use RAM in more efficient ways. One important way might be to write any seldom used data to disk, leaving more addresses available for actively running processes. This would be especially true immediately after boot, when a number of processes that might have run during boot might have resulted in processed data that might be used only rarely but should not be deleted. So, write to swap.

    This might also be true in modern Linux where as much as possible seems to be mounted in RAM using tmpfs which will fill up your physical RAM quickly. That's good if your applications can use the data in those mount points but not so good if the data is rarely or not used at all. So, maybe some of this might be written to swap? I'd hope so.

    But, those and similar OS optimization are what other people who create and maintain Linux do, I'm perfectly happy to allow them to make these kinds of decisions for me until I experience some kind of noticeable latency.

    TSU
    Beginner Wiki Quickstart - https://en.opensuse.org/User:Tsu2/Quickstart_Wiki
    Solved a problem recently? Create a wiki page for future personal reference!
    Learn something new?
    Attended a computing event?
    Post and Share!

  6. #6

    Default Re: Should swappiness be lowered for a SWAP partition on an SSD?

    I am using 2 SSD and one rotating disk and 16 Gig Ram.
    My swap is 20 Gig in the rotating disk.
    People who do not break things first will never learn to create anything

  7. #7
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    29,704
    Blog Entries
    15

    Default Re: Should swappiness be lowered for a SWAP partition on an SSD?

    Quote Originally Posted by MirceaKitsune View Post
    Fun fact: It seems that even with a swappiness of 10, I still get roughly 10 MB of SWAP being used once my system RAM exceeds 8 GB from my total of 16 GB. This is a lot less though and something I find acceptable, I'll be leaving it at that but it's interesting to know this.



    I agree with that as a general rule. In this case I know what I'm doing, and swappiness is a safe setting to adjust especially if you have enough RAM. I went without having any SWAP at all for a few years... main reason why I added it back is that I switched from a motherboard with 24 GB of RAM to one with only 16 GB, due to the old one being DDR3 and the new one using DDR4 memory which I couldn't afford to buy as much of.
    Hi
    Have a read here: https://forums.opensuse.org/showthre...f-ram-and-swap
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  8. #8

    Default Re: Should swappiness be lowered for a SWAP partition on an SSD?

    I have 32 GB of RAM and use a 1 TB SSD for my OS install. With that much RAM, I haven't used a swap partition in quite a few years. I've never had a single problem. That's 32 GB of RAM vs your 16 GB so I don't know how that compares as far as the need for swap, but I figured I'd mention my experience anyway.

  9. #9
    Join Date
    Jan 2009
    Location
    Romania, Bucharest
    Posts
    887

    Default Re: Should swappiness be lowered for a SWAP partition on an SSD?

    Quote Originally Posted by melioratio View Post
    I have 32 GB of RAM and use a 1 TB SSD for my OS install. With that much RAM, I haven't used a swap partition in quite a few years. I've never had a single problem. That's 32 GB of RAM vs your 16 GB so I don't know how that compares as far as the need for swap, but I figured I'd mention my experience anyway.
    I'm planning to upgrade to 32 GB myself once I can afford another set of two RAM boards identical to my current two. In the meantime 16 GB is just enough. Only problem is that since I easily reach half of that, it will trigger the SWAP... which isn't even affecting my performance, but I'm concerned about my drive being written to more often than I feel it needs to be.
    openSUSE Tumbleweed x64, KDE Framework 5

  10. #10
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    29,704
    Blog Entries
    15

    Default Re: Should swappiness be lowered for a SWAP partition on an SSD?

    Quote Originally Posted by MirceaKitsune View Post
    I'm planning to upgrade to 32 GB myself once I can afford another set of two RAM boards identical to my current two. In the meantime 16 GB is just enough. Only problem is that since I easily reach half of that, it will trigger the SWAP... which isn't even affecting my performance, but I'm concerned about my drive being written to more often than I feel it needs to be.
    Hi
    What are the specs for your SSD... I wouldn't even worry about it, there are probably more writes to the journal....
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •