You are not logged in.

#1 2018-08-13 22:00:58

gribblygook
Member
Registered: 2018-08-12
Posts: 23

How much damage does swap actually do?

Hi!

I'm getting my first computer with an SSD (Laptop with 256GB SSD) and getting slightly paranoid about all the responses to people saying swap is bad and I was curious about a few things
- Is swap still that bad with new SSD's?
- If I was to have a swap partition that was 8GB, if the swap eventually started to slow down the SSD would it only affect those 8GB allocated to swap or would it affect the whole SSD?
- If you didn't set swap, I assume when you closed the laptop the power would just stay on and waste more battery? Assuming Suspend to RAM wasn't in use
- At what amount of RAM does it become unnecessary to use swap?

Thanks smile

Offline

#2 2018-08-13 22:04:17

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: How much damage does swap actually do?


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2018-08-13 23:19:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: How much damage does swap actually do?

gribblygook wrote:

- Is swap still that bad with new SSD's?

That depends how it is used.  I only have one machine with swap activated at all - and I don't recall the last time the swap space was even touched by the system.

If swap space is abused, then it potentially can achieive *very* high numbers of write cycles over the same area of this disk.  This isn't nearly as big of a concern with modern SSDs, but at some point they too could be affected.

gribblygood wrote:

- If I was to have a swap partition that was 8GB, if the swap eventually started to slow down the SSD would it only affect those 8GB allocated to swap or would it affect the whole SSD?

Slow down?  That is not the risk.  If (big if) there are too many write cycles on a region of an SSD, that region will not slow down, it will wear out and be completely non-functional.  But this would only affect that region, the rest of the disk would be unaffected.

gribblygood wrote:

- If you didn't set swap, I assume when you closed the laptop the power would just stay on and waste more battery?

This has nothing to do with whether or not you have swap set up.  What happens when you close a lid is dictated by how you configure systemd or another relevant power manager.  Options include doing nothing, turning off the screen, suspending, hybernating, and powering off.  Of course hibernation will fail if you do not have swap.

gribblygood wrote:

- At what amount of RAM does it become unnecessary to use swap?

256MB.  YMMV.

Last edited by Trilby (2018-08-13 23:23:01)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2018-08-13 23:28:38

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: How much damage does swap actually do?

Trilby wrote:
gribblygood wrote:

- If I was to have a swap partition that was 8GB, if the swap eventually started to slow down the SSD would it only affect those 8GB allocated to swap or would it affect the whole SSD?

Slow down?  That is not the risk.  If (big if) there are too many write cycles on a region of an SSD, that region will not slow down, it will wear out and be completely non-functional.  But this would only affect that region, the rest of the disk would be unaffected.

I thought all modern SSDs had wear levelling which would distribute the wear across the device?

Offline

#5 2018-08-14 01:06:59

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: How much damage does swap actually do?

Across the device?  Not that I know of, but I could be wrong.  Across the file system sure.  But the swap filesystem would be relatively small, so each sector would still be written to frequently.  I can't imagine wear leveling would be rearranging the physical sectors assigned to different partitions.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2018-08-14 04:36:42

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: How much damage does swap actually do?

"Swap is bad" is an over-simplification.

The worst thing about swap, is swappiness defaulting to 60, so it's *overly* used.

The next worst thing about swap, is the confusion it causes wink

Offline

#7 2018-08-14 10:27:44

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: How much damage does swap actually do?

Consider using a swap file instead of a swap partition. A swap file provides the exact same functionality and speed as a partition, but can also easily be resized or deleted at any time.

My computer had 4 GB of RAM. Over the past 10 years using Arch Linux I have never needed to use swap space because of insufficient RAM, so I don't bother setting up swap space any more.

Please understand the differences between Suspend to RAM and Suspend to Disk. If you end up telling your laptop to Suspend to RAM when you close the lid, then you have no need for swap space in that regard.

In summary, you probably don't need any swap space. If you do need swap space, create a swap file instead of a swap partition.

...as for me, I HATE it when my laptops sleep when I close the lid. Instead, I just configure it so the screen turns off when the lid is closed, and I'd try to set it up to boot as quickly as possible. If I really want the computer to sleep, I'll press the "sleep" button that's on every laptop keyboard. tongue

Offline

#8 2018-08-14 13:13:12

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: How much damage does swap actually do?

drcouzelis wrote:

Consider using a swap file instead of a swap partition. A swap file provides the exact same functionality and speed as a partition, but can also easily be resized or deleted at any time.

It provides mostly the same functionality.

One functionality it does not provide, is "works on btrfs filesystems". smile


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#9 2018-08-14 13:26:11

ugjka
Member
From: Latvia
Registered: 2014-04-01
Posts: 1,794
Website

Re: How much damage does swap actually do?

your browser is probably doing more writes to your disk than swap will ever do.


https://ugjka.net
paru > yay | webcord > discord
pacman -S spotify-launcher
mount /dev/disk/by-...

Offline

Board footer

Powered by FluxBB