How to optimize a RAM-only (swapless) system?

John McCabe-Dansted gmatht at
Wed Dec 22 11:22:20 MST 2010

On Thu, Dec 23, 2010 at 1:26 AM, Von Fugal <von at> wrote:
>> One thing I have found quite useful is compcache. This allows you to
>> use compressed ram a swap-device. It doesn't need a physical disk and
>> has zero latency so it avoids many of the disadvantages of physical
>> swap devices. It tends to give a 4:1 compression ratio, though I
>> wouldn't recommend a compressed ram swap device much larger than 50%
>> of ram or so.
> Very interesting. So theoretically, by using 1/3 of your memory as
> compcache, you essentially double your ram...
> I wonder if the compcached portions of ram can then be swapped out to
> disk,

Compcache uses kernel ram, which cannot be swapped out, and the
current version of compcache does not support using a swap like
backing store for compressed pages.

> or rather I wonder what happens when you use compcache and regular
> disk swap.

Compcache presents itself as a swap device to the kernel. If that
compcache has a higher priority than the disk swap, the kernel will
fill up compcache first and the start filling up the regular disk
swap. This may not be what you want. My subjective feel is that adding
compcache to a system with disk swap leads to short term gain (as the
compcache is initially empty and so you will have recently used pages
being written and read from the disk swap) but long-term pain as the
compressed swap ends up being filled up with stale pages that should
really be written out to disk.

There has been research into heuristics that allow one to get the best
of compressed ram and disk based swap device, providing performance
that is never worse than disk swap (minus 2% overhead or so). Also
simply compressing the pages being swapped out could be useful for
reducing the number of writes to SSD based swap. However it seems that
neither of these will be supported by compcache in the short term.

One area compcache is already useful is in LiveCDs, for example it is
used by Ubuntu to reduce the amount of memory need to install from the

John C. McCabe-Dansted

More information about the PLUG mailing list