Gentoo Archives: gentoo-user

From: Paul Hartman <paul.hartman+gentoo@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] zram / compcache, anyone?
Date: Tue, 18 Oct 2011 05:31:57
Message-Id: CAEH5T2OSGBC++wf0eG8LUjbKmsx39=QT=3p_sp+EpK83fzPOKw@mail.gmail.com
In Reply to: [gentoo-user] zram / compcache, anyone? by Pandu Poluan
1 On Wed, Oct 12, 2011 at 8:52 PM, Pandu Poluan <pandu@××××××.info> wrote:
2 > Just stumbled upon this blog:
3 >
4 > http://www.webupd8.org/2011/10/increased-performance-in-linux-with.html
5 >
6 > anyone got any experience with zram/compcache on Gentoo?
7
8 I'm using zram in a gentoo server with only 256mb of RAM, only used
9 for a few weeks so far. It seems to work and the server hasn't crashed
10 yet. :) I have allocated 128MB of compressed swap (64x2, actually, to
11 theoretically utilize both CPU cores for compression at the same time)
12 followed by normal on-disk swap at lower priority. Usually my total
13 swap used is less than 128MB so the real disk swap is rarely touched.
14 It's difficult to say if there is any improved performance, but I
15 haven't experienced any slowdown, which occasionally I did when swap
16 became heavily used in the past. Keep in mind the 128MB zram is the
17 uncompressed size, so the actual amount of RAM used by this should be
18 much less, depending on contents of the swap. Some even recommend
19 using zram equal to the amount of RAM but that idea scares me.
20
21 After enabling the CONFIG_ZRAM module in kernel 3.0.6, I did this:
22
23 modprobe zram num_devices=2
24 echo $((64*1024*1024)) > /sys/block/zram0/disksize
25 echo 1 > /sys/block/zram0/reset
26 mkswap /dev/zram0
27 swapon -p 11 /dev/zram0
28
29 (repeat for /dev/zram1 and so on)
30
31 you can then swapoff your disk swap partition to empty it, then swapon
32 with lower priority than the zram swap devices.
33
34 Also note that zram is really just a generic compressed RAM drive. You
35 don't have to use it for swap, you can mkfs anything you like onto it,
36 to use as compressed tmp space or whatever... just know that it'll be
37 gone when you reboot.
38
39 I think zram can be beneficial in an environment where CPU power is
40 plentiful but RAM needs to be conserved (i.e. fitting more virtual
41 servers onto one physical box). I seem to recall there is a way for a
42 virtual host to utilize zram automatically/transparently for the
43 virtualized guests, but I don't personally know anything about that.

Replies

Subject Author
Re: [gentoo-user] zram / compcache, anyone? Florian Philipp <lists@×××××××××××.net>