SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2014-01-01 23:49:56

wanakutia
Member
Registered: 2012-12-17
Posts: 33

how to install / enable zRam on Waldorf

Hi everyone!

I need a little help. I have low-resources laptop (2GB RAM/2.16MHz Dual core) and I trying to get best performance as I can from it.
In order to achive that I need to install zRam, but it seems to be not in official repo.
I tryed find it in Synaptic and by sudo apt-get install zram - no luck.

Can you tell me guys, how can I do it on my Waldorf please.

I'm running on kernel 3.10 and I already installed preload - just for the records.

Many thanks for reply
Cheers

Last edited by wanakutia (2014-01-02 10:28:05)

Offline

Be excellent to each other!

#2 2014-01-01 23:57:34

porkpiehat
#! Die Hard
Registered: 2012-10-02
Posts: 880

Re: how to install / enable zRam on Waldorf

http://crunchbang.org/forums/viewtopic. … 55#p150355

But honestly, I would not consider 2G memory and a 2.16GHz dual core "low resource" (unless you really mean that your processor is running at 2.16MHz) -- are you seeing it use swap often? That's the only time using zram is really going to make a difference. I have run Debian distros on 1G or even 512M memory and a single-core P4 at 1.7GHz with no problems at all. Do you have a specific reason for wanting to use zram?

Last edited by porkpiehat (2014-01-02 00:36:56)


There are no stupid questions. Only stupid people.

Offline

#3 2014-01-02 01:59:22

wanakutia
Member
Registered: 2012-12-17
Posts: 33

Re: how to install / enable zRam on Waldorf

Porkpiehhat, thanks for fast respond!

The link to thread you gave me is promising, I certainly start work with it. However, base of the script is on liquorix kernel where I have kernel 3.10 and I'm not really familiar with liquorix and its safety.

My resources... well, I gave up eye-candy DEs like KDE, Unity or Gnome 3.8 with all their usability, because ther were to heavy for my lap ops . Sometime I'm using firefox, vlc, libreoffice and gimp or subtitleeditor alongside that make my laptop very resource hungry. I notice difference only on lubuntu, unfortunately I had to many errors and problems with LXDE... I decided to switch to more stabile distro I used before.

Anyway, as I said before trying to get best what I can from my lap cool

Offline

#4 2014-01-02 02:09:52

wanakutia
Member
Registered: 2012-12-17
Posts: 33

Re: how to install / enable zRam on Waldorf

...

Last edited by wanakutia (2014-01-02 10:34:58)

Offline

#5 2014-01-02 09:51:03

iMBeCil
WAAAT?
From: Edrychwch o'ch cwmpas
Registered: 2012-03-22
Posts: 956
Website

Re: how to install / enable zRam on Waldorf

^just edit your FIRST post ... there you will have chance to edit title, too.

Last edited by iMBeCil (2014-01-02 09:51:14)


Postpone all your duties; if you die, you won't have to do them ..

Offline

#6 2014-01-02 10:37:20

wanakutia
Member
Registered: 2012-12-17
Posts: 33

Re: how to install / enable zRam on Waldorf

iMBeCil wrote:

^just edit your FIRST post ... there you will have chance to edit title, too.


thanks, that worked

Offline

#7 2014-01-02 12:57:07

iann
#! Die Hard
Registered: 2010-09-10
Posts: 714

Re: how to install / enable zRam on Waldorf

zram is part of the kernel.  You don't need anything from the repos to use it.  In the stock Debian kernel it is compiled as a module called zram.ko.

If you load this module it will create a special block file called /dev/zram0.  This file can be used as a swap file and the contents will automatically be compressed and stored in your RAM.  It could also be used for other purposes such as transient storage like a RAMdisk.

You can control the number and sizes of zram devices.  There is a parameter to the zram module called "zram_num_devices".  To add confusion, the name of this parameter changed to num_devices, I think in kernel 3.4.  I think the default number of devices in 3.2 is 2, /dev/zram0 and /dev/zram1.

modprobe zram zram_num_devices=4

The size of the zram devices is set by entering the number of bytes into /sys/block/zram0/disksize.  You probably need to do this as root, a good place is /etc/rc.local.

echo $((256*1024*1024)) > /sys/block/zram0/disksize

Then you define it as a swap device and turn it on.  Usually you want a high priority so that the zram device is used before any non-compressed swap partitions.

mkswap /dev/zram0
swapon -p 100 /dev/zram0

zram for swap has largely been superceded in newer kernels, with support for directly compressing portions of RAM that would otherwise be swapped without the need for an explicit swap device.  zram is useful if you ever use more than a tiny amount of swap space.  It avoids the performance wall you hit when you do a non-trivial amount of swapping, most particularly when pages you need have to be read back from swap.  With 1GB of RAM, I find I quite often use all the RAM although I now use cleancache and fronstswap in kernel 3.9 to do my compression of pages that would get swapped.

Last edited by iann (2014-01-02 13:58:08)

Offline

#8 2014-01-05 17:01:55

wanakutia
Member
Registered: 2012-12-17
Posts: 33

Re: how to install / enable zRam on Waldorf

Iann,

thanks a lot for this explanation, very straightforward. However, I got a couple of questions.

Firstly, you described enabling zRam on kernel 3.2; 3.4 and 3.9, however I'm using kernel 3.10 (and I may upgrade in future) can I assume that this command will do the job?

modprobe zram num_devices=2 

+ all settings lately.

Secondly, If I enable zRam and than upgrade kernel, do I have to do it again?

Just before #! I was using a Lubuntu 13.10 with zRam enabled by default. I notice back then, that there are 2 additional devices(partitions) created, zRam0 and zRam1, each of them of 450MB. So not entirely Ram has been used, just a half of it (I've 2~1.9GB RAM). Should I do the same now, 2x450MB?

Finally, you wrote

Iann wrote:

I find I quite often use all the RAM although I now use cleancache and fronstswap in kernel 3.9 to do my compression of pages that would get swapped.

what's cleancache and fronstswap? Do you consider it as a better solution than zRam with improving performance?

cheers

Offline

#9 2014-01-05 17:58:11

iann
#! Die Hard
Registered: 2010-09-10
Posts: 714

Re: how to install / enable zRam on Waldorf

If you have kernl 3.10 I would suggest not using zram for swap as there are better alternatives.  More later.

Once you configure zram, it should not be an issue to upgrade the kernel.  Assuming it still has zram compiled, and assuming it remains either as a module or compiled in.  When compiled in, you need to specify the num_devices parameter on the boot command line.  In kernel 3.10 the parameter should be as you stated, although I haven't used it in that kernel version.

By default, each zram device is configured with a maximum size equal to a quarter of your RAM.  You can change this as described.  That doesn't mean it takes a quarter of your RAM, but it will allow writes to that device until it has used up that amount of RAM with compressed pages.  The net effect of this as a swap device is that you potentially get around 50% extra RAM (3 pages compressed into 1, more or less) for very little performance loss, before you start hitting the hard drive big time.

Cleancache is a mechanism for compressing and caching clean cache pages smile  These are pages which are being written to disk and hence guaranteed to be exactly the same in memory as they are on disk.  That means that they can simply be discarded at any time that RAM is needed.  It is a standard part of kernel 3.10, although I don't know whether it is enabled in whatever build you have.  When enabled, it should operate invisibly without any assistance from you.  In earlier kernels, operational data was always written out, but in 3.10 you would need to mount debugfs and examine /sys/kernel/debug/zcache/eph_zpages.

Frontswap is a similar system for pages that would otherwise get swapped out.  Overhead is lower than with zram because the pages never actually get swapped, just compressed.  Again it is a part of 3.10 but you may need to enable it and compile the kernel.  Usage is shown in /sys/kernel/debug/zcache/pers_zpages and similar files.

Both these mechanisms use transcendent memory, and specifically an implementation called zcache.  There are other implementations but this one seems to be most accepted at present.  By itself this won't improve performance, but it will prevent performance degrading when you have insufficient memory.  The first effect will be with improved retention of file cache pages, but this is difficult to measure and the effects are subtle.  When it reaches the stage of preventing live pages getting swapped back and forth, you probably already know the performance hit is dramatic, and this can be staved off using these functions.

When cleancache, and particularly frontswap, are in use, which they may well be already with your 3.10 kernel, then having swap on the zram device is counter-productive.  zcache has built-in features to prevent un-compressible (or only slightly compressible) pages being written back into RAM and instead they get flushed to swap.  If you observe these in use (eg. through debugfs) then you will see that a small amount of swap gets used whenever pages are getting compressed.  Having zram try again to compress these pages when we already know if can't be done, and then write them back into main memory, is worse than pointless.

Offline

#10 2014-01-05 18:33:32

iann
#! Die Hard
Registered: 2010-09-10
Posts: 714

Re: how to install / enable zRam on Waldorf

So, too much text from me smile  Short answer, check your kernel config for CONFIG_CLEANCACHE and CONFIG_FRONTSWAP, then decide where to go from there.

Offline

#11 2014-01-06 07:53:27

wanakutia
Member
Registered: 2012-12-17
Posts: 33

Re: how to install / enable zRam on Waldorf

Iann!

Thank you very much for this explanation, it brings the light to many things regarding kernel modules and enhancing performance. I really appreciate your effort.

You convinced me to try cleancache&frontswap, however, I don't really know how deal with them... devil is there any command to check a stat or which file should I edit to enable both boosters? glasses

P.S. I know it's a lot of 'can you's' but... can you also give me a command to disable zRam, so I can freely test all of the modules, separately?

Many thanks

Offline

#12 2014-01-06 12:39:08

iann
#! Die Hard
Registered: 2010-09-10
Posts: 714

Re: how to install / enable zRam on Waldorf

I still don't know what kernel you're running.  For example, the Liquoriz 3.10 kernel has both cleancache and frontswap enabled, but the wheezy-backports 3.10 kernel has neither.  Once they are enabled in the kernel then I don't think you need to do anything to activate them.  They just work.  Neither can be compiled as a module, they're either there or not.

zram is the opposite.  It requires the module to be modprobed (only a custom built kernel will have it built in not as a module), the swap devices to be mapped to it, and the swap to be turned on.  Skip any of those steps, no compressed swap.  Even if you've done all that, a quick swapoff on the zram device and no compressed swap.

Offline

#13 2014-01-06 17:03:35

wanakutia
Member
Registered: 2012-12-17
Posts: 33

Re: how to install / enable zRam on Waldorf

well, my uname -r brings me this result:

3.10.0-031000-generic
Iann wrote:

Once they are enabled in the kernel then I don't think you need to do anything to activate them.  They just work.

I just want to be able to determine, whenever they are enabled/exist or not. Something like command or config file, it would be handy in the future.

Iann wrote:

When cleancache, and particularly frontswap, are in use, which they may well be already with your 3.10 kernel, then having swap on the zram device is counter-productive.

Iann wrote:

Having zram try again to compress these pages when we already know if can't be done, and then write them back into main memory, is worse than pointless

Slowly we getting to conclusion that using zRam, while on kernel with enabled frontswap and cleancache, do not improving performance at all. Whenever we using entire RAM or not... but please, don't tell me that, preload missing the point, to!

Offline

#14 2014-01-06 17:08:48

iann
#! Die Hard
Registered: 2010-09-10
Posts: 714

Re: how to install / enable zRam on Waldorf

Cleancache and Frontswap should both be enabled in that kernel.  Mount debugfs and take a look to see if the zcache diagnostics exist.

Offline

#15 2014-01-06 18:14:06

wanakutia
Member
Registered: 2012-12-17
Posts: 33

Re: how to install / enable zRam on Waldorf

After mounting, under /sys/kernel/debug I can find celancache and frintswap folders with little amount of data in it, however I cannot see anything like zcache at all.

Offline

#16 2014-01-06 19:38:04

iann
#! Die Hard
Registered: 2010-09-10
Posts: 714

Re: how to install / enable zRam on Waldorf

Looks like the zcache debug system is turned off in that kernel which is a shame.  There is a config ZCACHE_DEBUG which is default N in 3.10 but was always on in 3.9 which I use.

Still, those folders mean you have cleancache and frontswap.  I suggest that your work here is done, forget about swap on zram unless you want some other device to be mapped into compressed RAM.  Those debug folders should contain information after you've run the system for a while, although it isn't especially informative.  Cleancache will start to get used first, basically whenever anything gets written into the filesystem, while frontswap will only see use once you fill up RAM.

Offline

#17 2014-01-13 20:23:04

wanakutia
Member
Registered: 2012-12-17
Posts: 33

Re: how to install / enable zRam on Waldorf

Iann wrote:

Looks like the zcache debug system is turned off in that kernel which is a shame.  There is a config ZCACHE_DEBUG which is default N in 3.10 but was always on in 3.9 which I use.

So how can I enabled zcache?
I mounted debugfs after a week of using my laptop with different performance, and still there are folders frontswap and cleancache with a couple text files:

failed_stores       0bytes
invalidates         0bytes
loads                 0bytes
succ_stores        0bytes

If I open them there are a few digits, that's all nothing changed, no more data since...

Offline

#18 2014-01-13 20:33:05

iann
#! Die Hard
Registered: 2010-09-10
Posts: 714

Re: how to install / enable zRam on Waldorf

zcache is off.  You need a different kernel.

Offline

#19 2014-01-13 21:03:20

wanakutia
Member
Registered: 2012-12-17
Posts: 33

Re: how to install / enable zRam on Waldorf

Ok. somehow I though I can turn it on... sweet newbie world...
Unfortunately, I don't know which kernel have zcache enabled, so I need to ask you for some recommendation.
Which kernal you recommend for:
Laptop
Toshiba satellite p300
intel Dual core t3400 2.16 GHz
Ram 2 GB
HDD x2

Cheers

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo