Personal tools

Navigation

Views

Compcache

Compcache or Ramzswap, hitherto referred as ramz is a method for taking a chunk of 'normal' RAM and using it as a compressed virtual memory (VM) swap space. That is, we use RAM as a sort of a virtual, virtual RAM by compressing the contents on the fly and storing it in RAM that's marked up as a swap device. This is in order to squeeze as much space from the limited RAM as possible. A swap device created from compressed RAM is many times faster than a regular swap device using hard drives or traditional flash memory.

Lack of RAM is considered one on the main performance bottlenecks a N900 user has to contend with. In its stock set-up, the N900 is prone to having massive swapping after even short periods of heavy use. This leads to poor performance, and in the worst cases, a reboot. This is generally alleviated in one or several of four ways.

Swappolube (sic) is a set of VM parameter tweaks initially dreamt up by the user Hawaii. For MOST users, the installation of Swappolube from the repositories and applying the default settings will suffice to alleviate the problem.

It has been found that as the swap space fills up, the OS is eventually more and more unable to allocate continuous space on the swap device. This leads to poor performance, that can be periodically reset by turning the swapping device off and on again, clearing the slate. The package ereswap was created to make this easy.

The article's namesake. The use of compcache has been a contentious issue. Most users have found it to cause extremely poor system performance. For many users, as soon as the ramz space gets full - which is pretty quick, considering it's only tens of megabytes large - the system grinds to a slow crawl.

Some empirical and anecdotal evidence suggests that the 'extreme' swap-retention settings of swappolube (that most users run) are highly unsuitable ramz. Swappolube sets the VM to swap as rarely as possible. This does not work for ramz - likely, an opposite approach must be taken: The device must swap a lot. As in this scenario the swapping is optimally mostly done to the RAM swap device, there will be little penalty in speed.

To enable compcache you must enter these commands as root, the following will create a ramz disk of 64MB:

insmod /lib/modules/current/ramzswap.ko disksize_kb=65536

It will take a short while for the kernel to catch up with this, so you should pair this with a 'sleep 1' command. Once enabled, you must tell the system to use the ramz disk:

swapon /dev/ramzswap0

For any of this to be any benefit, the ramz disk needs to have a higher priority than the 'physical' swap space. Make sure ALL applications are closed and disable then re-enable your physical swap. On a stock setup (swap on eMMC) you can do this:

swapoff /dev/mmcblk0p3 &&sleep1&& swapon /dev/mmcblk0p3

For other setups, i.e. when you have swap on uSD you must substitute 'mmcblk0p3' with the location of your swap space. (If your swap partition is the second partition on the uSD then it will be 'mmcblk1p2').

You can see ramzswap is 64MB AND with a higher priority than mmcblk0p3.

Now you must change your VM settings to effectively use the new ramz setup. The following settings have been found to work with 32MB, 64MB and 128MB (beware!) ramz sizes. They are a work-in-progress and will be updated as they are tuned to the authors' workload (heavy user, treating n900 as a pocket laptop as oppose d to merely a phone).

Paste the below lines into xterm to setup the VM and tune the flash device usage:

There is a package called swapset[2], which attempts to setup swaps and the ramz module automatically. The author of this article has not used it, and thus cannot vouch for its effectiveness. Using swapset AND putting the above settings into swappolube would probably cause all of the above to work automatically. Probably.