http://code.google.com/p/compcache/
Quote:
This project creates RAM based block device (NOW named zram) which acts as swap disk (AND a generic in memory self-compressing block device). Pages swapped to this disk are compressed and stored in memory itself.
FYI: They have removed the redundant backing disk option that activates if the page is not compressable. I guess this is for the short term so if it can't swap a page you still need your old swapdisk as a backup.
Compressing pages and keeping them in RAM virtually increases its capacity. This allows more applications to fit in given amount of memory. That's more for less money on your monthly linode bill.
The usual argument I get is - memory is so cheap so why bother with compression? So I list here some of the use cases. Rest depends on your imagination

* Netbooks: Market is now getting flooded with these "lightweight laptops". These are memory constrained but have CPU enough to drive on compressed memory (e.g. Cloudbook features 1.2 GHz processor!).
* Virtualization: With compcache at hypervisor level, we can compress any part of guest memory transparently - this is true for any type of Guest OS (Linux, Windows etc.). This should allow running more number of VMs for given amount of total host memory. * Embedded Devices: Memory is scarce and adding more memory increases device cost. Also, flash storage suffers from wear-leveling issues, so its useful if we can avoid using them as swap device.
Just use this if you want FASTER SWAP traded in for a smaller amount of memory. I think it sells itself
I wonder if Linode is over-subscribing their server's memory transparently yet using this technology.... Sounds interesting.
Please confirm or deny this on the record linode admins. I'm hoping the answer is NO but I'd just like to hear it from you guys.
Also I wonder if the competitors will do this.... With everyone on dreamhost being pushed to run debian, I'd assume they just free the duplicate pages in memory as their $$$ saver.
I'd like to know because if they aren't there will be a performance boost if power users do this in some cases.
Could the linode admins confirm or deny if this is use.
[update: Crackpots comments aside, it's worth documenting exactly what kind of Xen implementation a linode IS and IS NOT
Linode doesn't admins say they don't use this
]
I'm testing now. All the more reason to roll your own kernel
(or at least reconfigure the linode one).
And the testing is done! I've rolled out my implementation to a gentoo bug.
http://bugs.gentoo.org/show_bug.cgi?id=252987
Here's the ebuild and the init.d scripts for those who are interested.
compcache-0.7-r9999.ebuild
Code:
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI="2"
inherit eutils linux-mod toolchain-funcs mercurial
DESCRIPTION="Compressed RAM as fast swap"
HOMEPAGE="http://compcache.googlecode.com/"
#SRC_URI="http://compcache.googlecode.com/files/${P}.tar.gz"
EHG_REPO_URI="https://compcache.googlecode.com/hg/"
S="${WORKDIR}/compcache"
LICENSE="GPL-2 LGPL-2.1"
KEYWORDS="~arm ~amd64 ~x86"
IUSE="swap_free_notify"
DEPEND=">=virtual/linux-sources-2.6
dev-vcs/mercurial
"
RDEPEND="${DEPEND}"
pkg_setup() {
BUILD_PARAMS='KV_OUT_DIR="${KV_OUT_DIR}"'
BUILD_TARGETS="all"
CONFIG_CHECK="LZO_COMPRESS LZO_DECOMPRESS SWAP !RAMZSWAP"
MODULE_NAMES="zram(compcache:${S}:${S})"
MODULESD_ZRAM_DOCS="Changelog README"
MODULESD_ZRAM_EXAMPLES=('zram num_devices=1')
linux-mod_pkg_setup
}
src_prepare() {
find . -name Makefile -exec sed -i \
-e 's:make:$(MAKE):g' \
-e "s:@gcc:$(tc-getCC) :g" \
-e 's#/lib/modules/$(shell uname -r)/build#"$(KV_OUT_DIR)"#' \
{} \; || die
cd "${S}"
use swap_free_notify && epatch "${FILESDIR}"/${P}-free_notify.patch
}
src_compile() {
linux-mod_src_compile
}
src_install() {
linux-mod_src_install
dosbin sub-projects/scripts/zram_stats || die
newinitd "${FILESDIR}/init.d-${PN}" ${PN} || die
newconfd "${FILESDIR}/conf.d-${PN}" ${PN} || die
dodoc Changelog README || die
dodoc patches/patch_swap_notify_core_support_2.6.33.diff || die
}
init.d-compcache
Code:
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
depend() {
need localmount
after bootmisc modules
}
start() {
if [ "${LOAD_ON_START}" = "yes" ] ; then
if ! grep zram /proc/devices >/dev/null ; then
einfo "Loading zram module..."
modprobe zram num_devices=${NUM_DEVICES}
eend $?
fi
fi
# exit if the driver is not yet installed
grep zram /proc/devices >/dev/null || exit 1
for I in `seq 0 \`expr ${NUM_DEVICES} - 1\`` ; do
eval _a=\${ZRAM_SIZE_${I}}
einfo "Enabling swap /dev/zram${I}..."
if test ! -z ${_a} && test -f /sys/block/zram${I}/disksize ; then
echo $(($_a*1024)) > "/sys/block/zram${I}/disksize"
mkswap -L zram${I} /dev/zram${I} ${_a}
fi
if test -b "/dev/zram${I}" ; then
swapon ${SWAPON_OPTS} "/dev/zram${I}"
fi
eend $?
done
}
stop() {
for I in `seq 0 \`expr ${NUM_DEVICES} - 1\`` ; do
einfo "Disabling swap /dev/zram${I}..."
swapoff "/dev/zram${I}" && \
echo 1 > "/sys/block/zram${I}/reset"
eend $?
done
if [ "${UNLOAD_ON_STOP}" = "yes" ] && grep zram /proc/modules >/dev/null ; then
einfo "Unloading zram module..."
rmmod zram
eend $?
fi
}
info() {
for I in `seq 0 \`expr ${NUM_DEVICES} - 1\`` ; do
zram_stats "/dev/zram${I}"
done
}
reload() {
for I in `seq 0 \`expr ${NUM_DEVICES} - 1\`` ; do
swapoff "/dev/zram${I}" && \
echo 1 > "/sys/block/zram${I}/reset"
swapon ${SWAPON_OPTS} "/dev/zram${I}"
done
}
restart() {
stop
start
}
conf.d-compcache
Code:
# CompCache settings...
# load ramzswap kernel module on start?
LOAD_ON_START="yes"
# unload ramzswap kernel module on stop?
UNLOAD_ON_STOP="yes"
# number of device
NUM_DEVICES="4"
# uncompressed size in Kilobytes of each compressed ram swap disk
# (numbered from 0 to $NUM_DEVICES-1)
# only allocated / used / non-zeroed memory is actually used and will be less than this figure
# example 32 MB
ZRAM_SIZE_0="32768"
ZRAM_SIZE_1="32768"
ZRAM_SIZE_2="32768"
ZRAM_SIZE_3="32768"
# options for swapon
# (if this number is higher than your disk swap drive zram will be used for swap)
SWAPON_OPTS="-p 666"
If you run gentoo you can get the latest version from source (mercurial / googlecode) and RTFM or maybe someone cares can add it to the linode library.
You need the latest version if you want to install a module under linux-2.6.34+! refer to this bug
http://code.google.com/p/compcache/issues/detail?id=68
I think mysql locks memory so it can't be swapped, so there is no substitute for the real thing.
Let's be honest, linode IO is pretty constrained so a ramzswap might be your answer to trade CPU clicks you may not be using for some more memory....
Gentoo users see
here
Others see here:
http://library.linode.com/linode-platfo ... led-kernel
All this reminds me of the days when we had constrained memory on SIMMs on the 486 and some 3rd party commercial software for windows claimed to boost performance.
If your linode is SWAPPING due to load, this seriously might deserve a look in.
Cheers,
Luke