From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org)
	by finch.gentoo.org with esmtp (Exim 4.60)
	(envelope-from <gentoo-user+bounces-129932-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1RG2HN-0006mn-Ce
	for garchives@archives.gentoo.org; Tue, 18 Oct 2011 05:31:57 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id DD8AF21C046;
	Tue, 18 Oct 2011 05:31:45 +0000 (UTC)
Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com [74.125.82.181])
	by pigeon.gentoo.org (Postfix) with ESMTP id 68BB821C036
	for <gentoo-user@lists.gentoo.org>; Tue, 18 Oct 2011 05:30:44 +0000 (UTC)
Received: by wyh5 with SMTP id 5so219176wyh.40
        for <gentoo-user@lists.gentoo.org>; Mon, 17 Oct 2011 22:30:43 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=mime-version:sender:in-reply-to:references:from:date
         :x-google-sender-auth:message-id:subject:to:content-type;
        bh=qBJEaQh8mwAOhtjKmDMQUqCmZV7kGXjASJxIS7WO0J0=;
        b=V3jHf3npACucgojDNDwrhnn5EoiUUkh6ZJgokxSvTR05qY6plPVqSLkSgWQgReMYND
         o7bnYVcBQXMLnEFlN0HItRzpBm51YHSOJTYrVHmQZ913zhxP57N/TALnU/Yxu3vgEFP7
         adpPd4XHECJkYNADgjuRMcx3M/YIBPp8Dv4Wk=
Received: by 10.227.10.144 with SMTP id p16mr268641wbp.114.1318915842157; Mon,
 17 Oct 2011 22:30:42 -0700 (PDT)
Precedence: bulk
List-Post: <mailto:gentoo-user@lists.gentoo.org>
List-Help: <mailto:gentoo-user+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-user+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-user+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-user.gentoo.org>
X-BeenThere: gentoo-user@lists.gentoo.org
Reply-to: gentoo-user@lists.gentoo.org
MIME-Version: 1.0
Sender: paul.hartman@gmail.com
Received: by 10.227.59.193 with HTTP; Mon, 17 Oct 2011 22:16:38 -0700 (PDT)
In-Reply-To: <CAA2qdGWb1fhF2ENnNbipQKU08tPj3gwkmqD46C+-z+REX9u7dw@mail.gmail.com>
References: <CAA2qdGWb1fhF2ENnNbipQKU08tPj3gwkmqD46C+-z+REX9u7dw@mail.gmail.com>
From: Paul Hartman <paul.hartman+gentoo@gmail.com>
Date: Tue, 18 Oct 2011 00:16:38 -0500
X-Google-Sender-Auth: DtRPAHMwuz63Iocslz-l6pb7jp4
Message-ID: <CAEH5T2OSGBC++wf0eG8LUjbKmsx39=QT=3p_sp+EpK83fzPOKw@mail.gmail.com>
Subject: Re: [gentoo-user] zram / compcache, anyone?
To: gentoo-user@lists.gentoo.org
Content-Type: text/plain; charset=ISO-8859-1
X-Archives-Salt: 
X-Archives-Hash: 63678b8d6271e2e004981c168539a2cc

On Wed, Oct 12, 2011 at 8:52 PM, Pandu Poluan <pandu@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.