Good-enough solutions for an imperfect world

Menu

Compcache on Ubuntu on Amazon EC2

The following fully-automatic Bash script downloads, compiles, and initializes compcache version 0.6.2 on Ubuntu Karmic Koala (9.10). This script creates two swaps with a maximum of 4GB uncompressed size each. Two swaps are used to take advantage of 2 CPUs (or CPU cores in a multicore CPU).

Compcache is a fascinating memory compression system. The old alternative to compcache is to use a swap file backed by a hard disk (without using compression), but this kind of swapping is extremely slowed to physical memory or memory compressed by compcache. Compcache creates a swap device backed by compressed memory or by another swap file. Basically, you get more RAM—almost for free—though compcache adds a small overhead for compression. Compression should actually increase performance when backed by a hard drive because it reduces expensive disk I/O. When memory pages are empty (which happens more often than you’d think), compcache stores nothing. I run data analysis using party in R, and it needs huge amounts of memory (well over 10GB). Amazon EC2 gives me a large starting memory capacity, and compcache extends the physical RAM.

The script doesn’t install or make permanent changes, so if you don’t like it, reboot to start over. It was tested on Amazon EC2 with Canonical 64-bit server (ami-55739e3c), and it should work fine with other most Ubuntu versions such as the new Lucid Lynx LTS (10.04) [update: see fix for asm/asm-offsets.h error on Lucid Lynx]. For other ways to use Compcache, see compcache: Compiling And Using New .