4

This article suggests not to create a swap space on an SSD drive in order to reduce its wear. On the other hand, it suggested here that swap space positively affects performance.

Would it be a better option to drop swap? Or maybe some swappiness tweaks could let us have the cake and eat it. The device is ASUS T200TA, the only sure drive is a 32GB eMMC (the HDD is detachable) and has only 2GB RAM.

marmistrz
  • 2,742
  • 1
    I'll warn you that these early MMC-based SSDs can be bloody slow. I suspect if you start swapping the performance will be even worse than with an HDD, unless this is a particularly good example of one of those SSDs.

    If it's at all possible I would highly recommend fitting more RAM, whatever you end up doing.

    – Muzer Jul 24 '15 at 11:22

3 Answers3

4

Note that Linux gained a zRAM feature sometime in the past few years. It's a compressed ramdisk that can be used for swap space, i.e. to compress inactive memory content. The Gentoo Wiki entry on it claims it can achieve a compression ratio of around 3:1.

It sounds worth considering for any desktop with less than ideal ram (4GB is ideal for most current desktop environments). Microsoft started doing the same in Windows 8 (plus Windows Phone at some point, also some Android phones use zRAM).

zRAM requires some manual configuration, but at least for Ubuntu there are packages that will set it up automatically. You might need to investigate a little if you want to run normal swap as well with a lower priority (and whether that works well at all?!). The zram-config package is available from the ubuntu repos. Apparently Fedora 21 will enable zRAM automatically if you have 2GB or less.

sourcejedi
  • 50,249
  • 1
    And what about zswap? Is it a good option too? – marmistrz Aug 01 '15 at 19:04
  • Ye gods I have no idea. Seems more complicated to understand but it got merged first... I would take the Fedora move as an endorsement of zRAM's adequacy. What are the pros and cons - shrug. The obvious advantage of zswap is if you want to use a swap partition as well, you can see the design is supposed to work well with that. With zRAM that seems to be left as another item for the user to configure, and I don't know if it's expected to work well with a swap partition or not. My statement about running normal swap with lower priority came from a user blog so I don't know how reliable it is. – sourcejedi Aug 01 '15 at 19:57
  • The idea of using zram+zswap came from another (Polish) blog :) – marmistrz Aug 02 '15 at 08:41
3

If performance is good - you're not having to wait while switching between apps, with the disk thrashing and the activity LED solid on - then there isn't going to be a lot of wear to worry about either.

You could allocate a 2G space for swap at install time, and later tune the partition/swap size down e.g with GNOME Disks. Personally I would try 512M or 1G to start with. I assume you're not thinking about hibernation (which would usually want 2G+ swap).

Then I could see how much swap I used, and if I hit problems with out-of-memory or slowdowns with full swap. I confess I'm not sure how I'd distinguish thrashing the swap (too much active apps, enabled by too much swap) v.s. the cache (not enough swap to page out inactive app memory). In both cases you'd see the disk light on and pretty full swap. Maybe vmstat 1 and watch the swap column, if I could test a problem case reliably.

I would be cautious about 2GB swap on an eMMC (lower performance than expensive SSDs). Linux desktop memory management has a somewhat checkered history, and the swapping won't have been designed for eMMC.

If you use all that swap you may find the machine's become literally unusable anyway. Running out of memory can be better because you get the machine back without rebooting. Though it may kill programs you wanted & expected to survive.

My GNOME shell with a few apps has about 1G "used" (swapable) plus 1G+ "cached" (read-only data/code, can just be re-read from filesystem).

If you had punted 1G to swap, how long would it take to swap all that back, given your eMMC? (GNOME Disks can benchmark partitions for you :). E.g. 10 seconds to read it? Then if you're swapping the previous working set out at the same time, the (slower) writes on the eMMC are going to take even longer. Doesn't sound great to me.

One small reason for swap is tmpfs. My /run accumulates a meg or so, I doubt all needs to be in ram.

sourcejedi
  • 50,249
1

I wouldn't bother and go ahead with a 2GB swap partition.
You must always have some swap especially with "only" 2GB RAM which is rather sufficient with Linux and a light DE like LXDE or Xfce as long as you do have 2GB swap (or if you don't use any browser, don't compile anything or do anything that eat a lot of RAM!).

cylgalad
  • 186
  • It is planned to use Unity/Gnome shell/KDE 5 on this convertible due to the very good touchscreen support – marmistrz Jul 24 '15 at 09:48
  • zram will be better, esp. on systems with such a limited amount of RAM – phuclv Feb 09 '19 at 12:04
  • I never understood zram: wasting ram to a swap-file, really? That can be "good" if you have very limited storage space, but I wouldn't advise to use it otherwise. With 2 GB, you absolutely need swap. – cylgalad Feb 10 '19 at 09:21