Jump to content

Photo

Swappiness and Trim - Recommendations?

SSD Swap Swappiness TRIM

  • Please log in to reply
9 replies to this topic

#1 Oblio

Oblio

    Bodhi Team

  • Team
  • 165 posts
  • LocationA desk in the Midwest

Posted 12 January 2017 - 02:50 PM

Hello Community,

 

I was reading through another user's post and some discussion came up about swappiness, which got me thinking about the TRIM command, SSD performance, etc.

 

My current PC set up a 16GB swap during install due to having 16GB of RAM...I personally think this is incredible overkill, as filling up 16GB of RAM, esp. in Bodhi, would take a fair amount of processes/services/etc.  And even if my RAM were to max out, I would have bigger issues going on if I were to utilize a full 16GB of swap...I mean, that is a HUGE amount of space (for swap)!  

 

That said, I used to run closer to a 4GB swap (still overkill IMHO - my system *never* swaps), would set swappiness to 10 and go from there.  Since my new system has 16GB vs. 8GB of RAM, inherently would there be less chance of swapping, so even if I left my system at 60 for swappiness, it wouldn't swap?

 

***

 

Regarding TRIM, my old system used a first generation SSD - evidently these drives were known to not do very good "garbage collection" and as such, many forums recommended running TRIM on the drive every so often.  Out of habit, I would just run the command everyday, since I was always in my terminal.  

 

Does anyone know if this is a worthwhile practice with modern drives?  I'm suspecting that my Samsung SM863, which is an enterprise drive, wouldn't need someone to trim it everyday in a production environment - is this accurate?  It doesn't seem like setting up a cron job would be needed, but thought I would ask in case anyone is an expert in all things drive related.

 

Thank you All!

 

 


Xeon E3-1220 v3 3.1GHz Quad, ASRock Rack E3C224, 2x 8GB Kingston KVR16E11/8I DDR3-1600 ECC CL11 Intel Chips (Dual Channel), EVGA GeForce GTX 570, Samsung SM863 120GB OS SSD, 2x WD RED 3TB HDDs (Raid 0), Focusrite Scarlett 2i4, Antec Earthwatts EA-750 80 Plus Platinum 750w PSU - Bodhi 4.1.0 64

AMD Phenom II X4 940 3.0GHz Quad, Gigabyte GA-MA78GPM-DS2H, 2x 2GB Kingston KHX8500D2K2 DDR2-1066 (Dual Channel), EVGA GeForce GTX 570, Intel 30GB OS SDD, Seagate ST31000340AS 1TB HDD, Seagate STBD4000400 4TB HDD, EVGA 500w Bronze Plus 80+ PSU - Bodhi Linux 3.2.1 64




A big thank you to everyone who contributes to Bodhi Linux


#2 Elw3

Elw3

  • Moderators
  • 1769 posts

Posted 12 January 2017 - 05:23 PM

Do you need swap? If you cant answer this, the answer is no and you can delete it.

There are only two usages for swap and these are rather rare cases that normal users not encounter. 

It is a huge mistery for me why ppl create it. Is it one of these "i do it because i can it" cases? 


Bad Wolf

#3 Charles@Bodhi

Charles@Bodhi

    Old Faithful

  • Moderators
  • 4359 posts
  • LocationZeist, The Netherlands

Posted 12 January 2017 - 06:59 PM

Hmm,

 

- Sleep means saving your machine state to memory and if needed to Swap.

- Hybernation means saving your machine state to Swap only, as power needed for memory is cut off.

 

Two reasons normal users don't encounter? 

 

Running  a video player, a browser with a few tabs open, compiling some stuff in the background, Gimp open for another image you plan to edit and having a virtual machine running at the same time, even in Bodhi this adds up. 

 

Just looking at my RAM usage with only Chromium with 4 tabs open shows over 1.7Gib (out of 4Gib) of Ram in use.

An idle system here takes 260 Mib. Count your blessings with todays internet.

 

Enjoy,

Charles

 

PS. I would prefer to run TRIM (or UNMAP) in a cronjob. The built in "cleaner" on modern SSDs does not all of what trim does, so the risk of wear slower performance is still present.


  • sef likes this

Medion S4216 Ultrabook, 4GB RAM, 1TB HDD, WIN 10 & Bodhi 4.1.0-64 

Asus eeepc 901, 1GB RAM, 12 GB SSD, Bodhi 3.0.0-32-Legacy & Bodhi 4.1.0-32 Legacy


#4 Elw3

Elw3

  • Moderators
  • 1769 posts

Posted 12 January 2017 - 07:49 PM

 

Running  a video player, a browser with a few tabs open, compiling some stuff in the background, Gimp open for another image you plan to edit and having a virtual machine running at the same time, even in Bodhi this adds up. 

Yes charles, that is exactly what normal users do.

 

Personally i am OK with 500mb and only need swap when playing widelands.


Bad Wolf

#5 Oblio

Oblio

    Bodhi Team

  • Team
  • 165 posts
  • LocationA desk in the Midwest

Posted 13 January 2017 - 01:16 AM

It is a huge mistery for me why ppl create it. Is it one of these "i do it because i can it" cases? 

I just did it really because Bodhi just set it up when it created my partitions - no other reason.  I'm still relatively new to all of the partitions Linux should have (needs?) to operate.  I tried to run an install without swap and got nervous about building my environment with an improperly setup hard drive  - the worry of having to start all over again wasn't super appealing as I nuked everything trying to get my RAID set up...a few times :D

 

From what I can tell, by default, Bodhi creates three partitions.  Can you operate with only one?  Any recommendations would be greatly appreciated - thank you, Elw3!

 

Hmm,

 

- Sleep means saving your machine state to memory and if needed to Swap.

- Hybernation means saving your machine state to Swap only, as power needed for memory is cut off.

 

Two reasons normal users don't encounter? 

 

Running  a video player, a browser with a few tabs open, compiling some stuff in the background, Gimp open for another image you plan to edit and having a virtual machine running at the same time, even in Bodhi this adds up. 

 

Just looking at my RAM usage with only Chromium with 4 tabs open shows over 1.7Gib (out of 4Gib) of Ram in use.

An idle system here takes 260 Mib. Count your blessings with todays internet.

 

Enjoy,

Charles

 

PS. I would prefer to run TRIM (or UNMAP) in a cronjob. The built in "cleaner" on modern SSDs does not all of what trim does, so the risk of wear slower performance is still present.

I don't use sleep or hibernation - for some reason I have always been against them...I just have my system power way down (Xeons are pretty intelligent for power management).  If I had to guess why I don't use hibernation/sleep, I would guess this is probably a remnant from when drives took a long time to spin back up, etc.  I realize times have changed. 

 

That is what I suspected about running TRIM as a cron - I'll check out how to script something (definitely not my strength in Linux yet...).

 

I feel rather spoiled having 16GB of RAM...if I didn't have a "purpose built" server that I made to use as my everyday workstation, I likely wouldn't have nearly this much.  Let's just say, the "purpose" didn't work out as expected (shouldn't internet face FreeNAS, especially with Plex...found out after the fact).  That said, I won't be considering 32GB anytime soon.

 

Thank you, everyone - sound like I don't need swap at all but TRIM is still relevant/useful.


Xeon E3-1220 v3 3.1GHz Quad, ASRock Rack E3C224, 2x 8GB Kingston KVR16E11/8I DDR3-1600 ECC CL11 Intel Chips (Dual Channel), EVGA GeForce GTX 570, Samsung SM863 120GB OS SSD, 2x WD RED 3TB HDDs (Raid 0), Focusrite Scarlett 2i4, Antec Earthwatts EA-750 80 Plus Platinum 750w PSU - Bodhi 4.1.0 64

AMD Phenom II X4 940 3.0GHz Quad, Gigabyte GA-MA78GPM-DS2H, 2x 2GB Kingston KHX8500D2K2 DDR2-1066 (Dual Channel), EVGA GeForce GTX 570, Intel 30GB OS SDD, Seagate ST31000340AS 1TB HDD, Seagate STBD4000400 4TB HDD, EVGA 500w Bronze Plus 80+ PSU - Bodhi Linux 3.2.1 64


#6 Oblio

Oblio

    Bodhi Team

  • Team
  • 165 posts
  • LocationA desk in the Midwest

Posted 13 January 2017 - 06:11 AM

It appears Ubuntu 16.04/Bodhi come with a TRIM cron setup out of the gates - excellent!

 

https://www.digitalo...n-linux-servers

 

I used a gparted live session to repartition my drive - /dev/sda1 is my root/boot, /dev/sda2 is extended (not sure what for?), but "nested"  (not sure if that is the term - the graphical representation in gparted makes it appear this way...) within sda2 is a partition /dev/sda5 - my swap.  I was able to shrink sda2 and sda5 to 1GB down from 16GB - seems more reasonable for my system.  Expanded sda1 to fill the rest.  Moved everything "right". 

 

My previous attempt at creating this same scheme during an install of Bodhi left me without the sda2 extended partition (that I am not sure what it's use is).  My system appeared to run fine, but I didn't want to find out it wasn't down the road...

 

***

 

I made a permanent adjustment to my swappiness by:

 

sudo nano /etc/sysctl.conf
, added some comments about permanently adjusting swappiness, then added
vm.swappiness = 10
and saved.

 

For anyone not familiar with swappiness:  0 = a system that will not swap unless nearly out of memory and 100 would be a very aggressively swapping machine.  60 is the default (for Bodhi, Ubuntu anyway).  10 seems to be the consensus for systems with sufficient memory (*completely dependent on your system use - someone processing video or running many plugins on an audio/photo workstation will inherently use more, etc).

 

This exploration helped me - I hope it helps others pursuing an optimized system!  Thank you Elw3 and Charles for your feedback and suggestions!


Xeon E3-1220 v3 3.1GHz Quad, ASRock Rack E3C224, 2x 8GB Kingston KVR16E11/8I DDR3-1600 ECC CL11 Intel Chips (Dual Channel), EVGA GeForce GTX 570, Samsung SM863 120GB OS SSD, 2x WD RED 3TB HDDs (Raid 0), Focusrite Scarlett 2i4, Antec Earthwatts EA-750 80 Plus Platinum 750w PSU - Bodhi 4.1.0 64

AMD Phenom II X4 940 3.0GHz Quad, Gigabyte GA-MA78GPM-DS2H, 2x 2GB Kingston KHX8500D2K2 DDR2-1066 (Dual Channel), EVGA GeForce GTX 570, Intel 30GB OS SDD, Seagate ST31000340AS 1TB HDD, Seagate STBD4000400 4TB HDD, EVGA 500w Bronze Plus 80+ PSU - Bodhi Linux 3.2.1 64


#7 Astroboy

Astroboy

    Member

  • Members
  • 332 posts
  • LocationZacatecas, Mexico

Posted 13 January 2017 - 12:42 PM

Since you want your PC to be used for music production (as you said in another thread), may I suggest to install realtimeconfigquickscan, at https://github.com/r...configquickscan

 

That script checks your computer and suggest the best parameters for that purpose -including a recommended value for swappiness-

 

I believe that trim is not needed in newer SSD drives, and its use is not recommended in those.



#8 Elw3

Elw3

  • Moderators
  • 1769 posts

Posted 13 January 2017 - 03:09 PM

Well the installer sucks. There is absolutely no point in making three partitions neither in nesting them, which is a nightmare when you change stuff or recover data in the future.

Make one partiton, install, done. Nice and easy.

Of course i cant say if this changed at this day and ages, uefi for example needs a boot partition so far i know. 

But for normal worlds: The simpliest way is the best way.

 

Regarding the swap: Again, do you need it? If not then just delete it.

There are several cons and absolutely no benefit in your scenario. It just sits there, doing nothing but eating space. But IF a program runs havoc doing a memory leak and eat all your ram it will just eat you swap too and thus will destroy you ssds lifetime. 

Well this is unlikely, but still more likely than that you ever need it.


Bad Wolf

#9 Charles@Bodhi

Charles@Bodhi

    Old Faithful

  • Moderators
  • 4359 posts
  • LocationZeist, The Netherlands

Posted 13 January 2017 - 04:10 PM

Hmm, you think there are 3 partitions, but in fact there are only 2.

The MBR partition scheme can handle 4 partitions max. and people often need more. So there is an escape: use 3 partitions qualified as "primary" and then qualify the 4th as "extended". The extended partition can not be formatted, iy serves as a box to hold "logical volumes" that are seen as partitions. In your case the swap is created inside the extended (traditional in linux) using it for 100%. But an extended partition can hold 128 volumes max. iirc. FYI, Windows can only boot from primary partitions, linux doesn't care.

 

Without TRIM, even on modern ssd's like the Samsung 850 Pro, write time eventually slows down. Trim zero's blocks with deleted data so they are ready for re-use. If not there are remains of previous data that needs cleaning "on the fly" before writing new data to that block. These cleaned bits are stored elsewhere, causing garbage. The ssd's firmware cleans garbage, but doesn't write zeros.

TRIM executioning takes time itself and therefor a cronjob at quiet moments is a very good option. 

 

Enjoy,

Charles


Medion S4216 Ultrabook, 4GB RAM, 1TB HDD, WIN 10 & Bodhi 4.1.0-64 

Asus eeepc 901, 1GB RAM, 12 GB SSD, Bodhi 3.0.0-32-Legacy & Bodhi 4.1.0-32 Legacy


#10 Oblio

Oblio

    Bodhi Team

  • Team
  • 165 posts
  • LocationA desk in the Midwest

Posted 13 January 2017 - 10:54 PM

Since you want your PC to be used for music production (as you said in another thread), may I suggest to install realtimeconfigquickscan, at https://github.com/r...configquickscan

 

That script checks your computer and suggest the best parameters for that purpose -including a recommended value for swappiness-

I'll check that out - DAWs can get pretty wild with the resources in a hurry :)

 

 

 

Regarding the swap: Again, do you need it? If not then just delete it.

There are several cons and absolutely no benefit in your scenario. It just sits there, doing nothing but eating space. But IF a program runs havoc doing a memory leak and eat all your ram it will just eat you swap too and thus will destroy you ssds lifetime. 

Well this is unlikely, but still more likely than that you ever need it.

I'm still trying to decide if I need it.  I thinking following Astroboys' suggestion should help me decide or a few weeks of using my workstation.  I suppose if I have a memory leak I am going to have other issues anyway...  Simple is good!

 

 

Hmm, you think there are 3 partitions, but in fact there are only 2.

 

The ssd's firmware cleans garbage, but doesn't write zeros.

TRIM executioning takes time itself and therefor a cronjob at quiet moments is a very good option. 

 

Enjoy,

Charles

That is what I was kind of thinking about the "3" partitions...and the one being "nested".  Thank you for clarifying.

 

As far as TRIM goes, sort of what I am reading is a debate online, however, I have read that the garbage collection doesn't write zeros and SSDs can only write to zero'd out blocks.  I may just ask Samsung or dig in their information to see what is best for my SM863.  For now, I think I'll keep the default TRIM cron!

 

Thank you all for the input and feedback - very useful on this journey!


Xeon E3-1220 v3 3.1GHz Quad, ASRock Rack E3C224, 2x 8GB Kingston KVR16E11/8I DDR3-1600 ECC CL11 Intel Chips (Dual Channel), EVGA GeForce GTX 570, Samsung SM863 120GB OS SSD, 2x WD RED 3TB HDDs (Raid 0), Focusrite Scarlett 2i4, Antec Earthwatts EA-750 80 Plus Platinum 750w PSU - Bodhi 4.1.0 64

AMD Phenom II X4 940 3.0GHz Quad, Gigabyte GA-MA78GPM-DS2H, 2x 2GB Kingston KHX8500D2K2 DDR2-1066 (Dual Channel), EVGA GeForce GTX 570, Intel 30GB OS SDD, Seagate ST31000340AS 1TB HDD, Seagate STBD4000400 4TB HDD, EVGA 500w Bronze Plus 80+ PSU - Bodhi Linux 3.2.1 64






Also tagged with one or more of these keywords: SSD, Swap, Swappiness, TRIM

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users