On Wed, Oct 12, 2011 at 8:52 PM, Pandu Poluan <pa...@poluan.info> wrote:
> Just stumbled upon this blog:
>
> http://www.webupd8.org/2011/10/increased-performance-in-linux-with.html
>
> anyone got any experience with zram/compcache on Gentoo?

I'm using zram in a gentoo server with only 256mb of RAM, only used
for a few weeks so far. It seems to work and the server hasn't crashed
yet. :) I have allocated 128MB of compressed swap (64x2, actually, to
theoretically utilize both CPU cores for compression at the same time)
followed by normal on-disk swap at lower priority. Usually my total
swap used is less than 128MB so the real disk swap is rarely touched.
It's difficult to say if there is any improved performance, but I
haven't experienced any slowdown, which occasionally I did when swap
became heavily used in the past. Keep in mind the 128MB zram is the
uncompressed size, so the actual amount of RAM used by this should be
much less, depending on contents of the swap. Some even recommend
using zram equal to the amount of RAM but that idea scares me.

After enabling the CONFIG_ZRAM module in kernel 3.0.6, I did this:

modprobe zram num_devices=2
echo $((64*1024*1024)) > /sys/block/zram0/disksize
echo 1 > /sys/block/zram0/reset
mkswap /dev/zram0
swapon -p 11 /dev/zram0

(repeat for /dev/zram1 and so on)

you can then swapoff your disk swap partition to empty it, then swapon
with lower priority than the zram swap devices.

Also note that zram is really just a generic compressed RAM drive. You
don't have to use it for swap, you can mkfs anything you like onto it,
to use as compressed tmp space or whatever... just know that it'll be
gone when you reboot.

I think zram can be beneficial in an environment where CPU power is
plentiful but RAM needs to be conserved (i.e. fitting more virtual
servers onto one physical box). I seem to recall there is a way for a
virtual host to utilize zram automatically/transparently for the
virtualized guests, but I don't personally know anything about that.

Reply via email to