You are not logged in.

#1 2013-09-10 17:04:48

nbvcxz
Member
From: Poland
Registered: 2007-12-29
Posts: 202

ZSWAP is coming

Seems that long awaiting (if fact present from few months) memory comperssion technology is now aviable in mainline kernel and in ArchLinux core kernel line. (For tests I think it is better to disable zram service if auto started)

To enable You have to use linux >=3.11-1 (in ArchLinux config it is default on), add to your grub line zswap.enabled=1 eg.:

linux	/vmlinuz-linux root=/dev/sda5 zswap.enabled=1 init=/usr/lib/systemd/systemd

Be sure there is no zcache parameter as it prevents form working of zswap ( https://lkml.org/lkml/2013/7/17/147 ).
You can check if zswap is started by: dmesg | grep zswap and if it is working: cd /sys/kernel/debug/zswap & grep * grep . *
Here is short doc: https://www.kernel.org/doc/Documentation/vm/zswap.txt . According to this you can also change compressor type (lzo is default) but I'm going to give a try for lz4 by adding to kernel line zswap.compressor=lz4. But here I have an error that it is not aviable and swithed back to lzo.
Anybody experienced with testing this?

lz4 is working with stock kernel. Tested also with ZEN kernel - see next page for solution

Last edited by nbvcxz (2014-01-10 09:24:37)


Lenovo G50 | LXQT-git | compton | conky

Offline

#2 2013-09-10 17:19:10

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: ZSWAP is coming

I thought that the merge of lz4 was for ARM specifically… at least initially.  I'm not sure that it's in-kernel functionality has been made fully available to other architectures as of yet.

I was wondering why all this wasn't something you would put in the wiki, then at the very end, you squeeze a quick question in there smile  I encourage you to put this information in the wiki.  You seem to have played with this a bit and as of now, there is very little info that can be easily understood by the layman.  The only thing I have read is the commit and kernel doc, though admittedly, I have not done a whole lot of searching on the topic.  I have no swap partition, and I use btrfs, so a swap file is out of the question unless I mount it in a loop, which would further degrade the performance of an already not terribly well performing thing (I also have 8GB of RAM which I never even come close to fully utilizing, and an empty RAM slot with a 4GB stick still in the box).

Offline

#3 2013-09-10 17:37:12

nbvcxz
Member
From: Poland
Registered: 2007-12-29
Posts: 202

Re: ZSWAP is coming

@ WonderWoofy : seems that zram which is operating at block device level is ideal solution for you. So I try to write an article to wiki, but now I can see that better not about memory compression - both zram and zswap with comparison.


Lenovo G50 | LXQT-git | compton | conky

Offline

#4 2013-09-10 17:39:04

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: ZSWAP is coming

If he's not maxing out available RAM, zram won't do anything for him.

Offline

#5 2013-09-10 17:43:15

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: ZSWAP is coming

karol wrote:

If he's not maxing out available RAM, zram won't do anything for him.

^^^This.

If I actually got to the point where I was maxing out my RAM, I would just slap my 4GB stick into my machine.  Zram and zswap are great if you don't have the option to incarese RAM, but the proper solution is to actually have the amount of RAM you require.  So I think that the area that this would be the most beneficial would be in embedded systems (or a MacBook Air where Apple has soldered the damn RAM to the board).

Offline

#6 2013-09-10 19:18:46

Grinch
Member
Registered: 2010-11-07
Posts: 265

Re: ZSWAP is coming

So can this be used to compress RAM rather than swap? I don't have swap on any of my machines but I would be interested in compressing ram.

Offline

#7 2013-09-10 19:28:52

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: ZSWAP is coming

Both zswap and zram can do that.
If you've never used e.g. https://aur.archlinux.org/packages/zramswap/ , follow OP and see if it works for you.

Offline

#8 2013-09-10 19:43:09

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: ZSWAP is coming

Just enabled it now, interested in the following potential benefit as per the docs:

zswap.txt wrote:

Desktop/laptop users with limited RAM capacities can mitigate the performance impact of swapping.

I'll post again in a while with some totally subjective impressions.

Offline

#9 2013-09-10 19:53:11

nbvcxz
Member
From: Poland
Registered: 2007-12-29
Posts: 202

Re: ZSWAP is coming

Both do this in "different manner" and "at different level". I have used mentioned zramswap.service (just startup script in fact). My first feeling about them is that zram became more sluggish when RAM became full. The zswap is more fluent and so far works better with heavy load. Probably this is because zswap operates at "kernel level", while zram is treated as compressed block device (something like compressed tmpfs). Moreover zswap has "cleaners" - don't understand it clearly but seems it reclaims unused memory. All tests I make on old computers with max 1 GB RAM (one is even 256 MB wink ) and additional swap partition.


Lenovo G50 | LXQT-git | compton | conky

Offline

#10 2013-09-10 20:14:58

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: ZSWAP is coming

+1
zswap doesn't seem to do this: https://bugs.archlinux.org/task/36574 - a good thing :-)

Offline

#11 2013-09-14 14:29:31

eric
Member
From: under heaven
Registered: 2004-02-11
Posts: 118

Re: ZSWAP is coming

dmesg output:

[    0.577918] zswap: loading zswap
[    0.577934] zswap: using lzo compressor

So, I think zswap is working, but...

nbvcxz wrote:

if it is working: cd /sys/kernel/debug/zswap & grep * grep . *

I don't have this directory because debugfs is not mounted.
Is it needed to mount debugfs to make zswap work?
If the answer is "no", I have an offtopic question: are there other applications that will not work correctly when debugfs is not mounted?

Edit:
I know it's mounted by default. I have manually disabled this because I didn't see why I need debug information.

Last edited by eric (2013-09-14 15:46:43)

Offline

#12 2013-09-14 14:37:58

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: ZSWAP is coming

It seems to be mounted by systemd

$ mount | grep debug
debugfs on /sys/kernel/debug type debugfs (rw,relatime)

I don't recall mounting it by hand or creating any configs but I'm not 100% sure about this.

debugfs is mounted irrespective of using zswap.

Last edited by karol (2013-09-14 14:43:53)

Offline

#13 2013-09-14 14:55:26

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: ZSWAP is coming

karol wrote:

It seems to be mounted by systemd

/usr/lib/systemd/system/sys-kernel-debug.mount

pacman wrote:

sys-kernel-debug.mount is owned by systemd 207-1

Last edited by WonderWoofy (2013-09-14 14:56:13)

Offline

#14 2013-09-18 09:57:43

Vrantheo
Member
Registered: 2012-07-20
Posts: 33

Re: ZSWAP is coming

My laptop have 4 gigs of ram and 2 gigs of /swap. I hardly max out ram at all so /swap usage is always 0. Does it mean zswap is totally useless for me, or furtherly, I actually don't need /swap at all?

Offline

#15 2013-09-18 11:15:21

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: ZSWAP is coming

What do you currently use swap for? Hibernation?

Offline

#16 2013-09-18 12:12:49

Vrantheo
Member
Registered: 2012-07-20
Posts: 33

Re: ZSWAP is coming

karol wrote:

What do you currently use swap for? Hibernation?

I don't use hibernation at all, so I indeed suspect that keeping a /swap is pointless.

I'm just asking if zswap is still effective in improving memory performance even without any swapping taking action. "cd /sys/kernel/debug/zswap & grep . *" gives me all-zero so I doubt if I really need it at all.

Offline

#17 2013-09-18 12:17:36

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: ZSWAP is coming

I think zswap degrades memory performance a bit, but it lets you magically have some more memory.
If you put your computer under memory-related stress and you still get zeros when using zswap, you don't need it :-)

Offline

#18 2013-09-18 16:18:09

nbvcxz
Member
From: Poland
Registered: 2007-12-29
Posts: 202

Re: ZSWAP is coming

Vrantheo wrote:

My laptop have 4 gigs of ram and 2 gigs of /swap. I hardly max out ram at all so /swap usage is always 0. Does it mean zswap is totally useless for me, or furtherly, I actually don't need /swap at all?

In this case I think it is better to use ZRAM and totally switch off hdd swap partition. First you can try with default values (just #systemctl enable zramswap.service). Further you can play with increasing swappiness wink , adding zcache to kernel etc. and see if your laptop works fine.


Lenovo G50 | LXQT-git | compton | conky

Offline

#19 2013-09-19 05:39:11

Vrantheo
Member
Registered: 2012-07-20
Posts: 33

Re: ZSWAP is coming

nbvcxz wrote:

In this case I think it is better to use ZRAM and totally switch off hdd swap partition. First you can try with default values (just #systemctl enable zramswap.service). Further you can play with increasing swappiness wink , adding zcache to kernel etc. and see if your laptop works fine.

I installed zramswap, enabled the service, commented out the /swap line in /etc/fstab, executed "swapoff -a", then rebooted.

"dmesg | grep swap" shows:

[    0.854265] systemd[1]: Cannot add dependency job for unit swap.target, ignoring: Unit swap.target failed to load: No such file or directory. See system logs and 'systemctl status swap.target' for details.
[   15.322862] Adding 198052k swap on /dev/zram0.  Priority:100 extents:1 across:198052k SSFS
[   15.323151] Adding 198052k swap on /dev/zram1.  Priority:100 extents:1 across:198052k SSFS
[   15.323420] Adding 198052k swap on /dev/zram2.  Priority:100 extents:1 across:198052k SSFS
[   15.323716] Adding 198052k swap on /dev/zram3.  Priority:100 extents:1 across:198052k SSFS

System is running so far so good, but I'm not sure if this first line means something wrong.

Offline

#20 2013-09-19 07:58:59

nbvcxz
Member
From: Poland
Registered: 2007-12-29
Posts: 202

Re: ZSWAP is coming

big_smile no idea too. Probably it is just systemd automat trying to start any aviable swap partition (there is no set so it claims that swap.target fails) - nothing to worry. Could you swapon -s and sysctl vm.swappines to be sure? I haven't use zram last time but I am not sure why there is SSFS as it should be in RAM swap formated and this is most ambiguous for me.


Lenovo G50 | LXQT-git | compton | conky

Offline

#21 2013-09-19 08:58:28

Vrantheo
Member
Registered: 2012-07-20
Posts: 33

Re: ZSWAP is coming

nbvcxz wrote:

big_smile no idea too. Probably it is just systemd automat trying to start any aviable swap partition (there is no set so it claims that swap.target fails) - nothing to worry. Could you swapon -s and sysctl vm.swappines to be sure? I haven't use zram last time but I am not sure why there is SSFS as it should be in RAM swap formated and this is most ambiguous for me.

Filename				Type		Size	Used	Priority
/dev/zram0                             	partition	198052	0	100
/dev/zram1                             	partition	198052	0	100
/dev/zram2                             	partition	198052	0	100
/dev/zram3                             	partition	198052	0	100

vm.swappiness = 60

Looks like 4GB of RAM is really more than enough for me most of the time. Well, there still might be occasions when I have a hell lot of tabs in Chrome and such. Now I can consider even more optimizations that trade RAM for speed. Thanks for the tips!

Offline

#22 2013-09-24 06:30:55

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: ZSWAP is coming

I started using the zswap.enabled=1 kernel parameter and noticed a big improvement when waking up from hibernation on my Thinkpad X200 with 8GB RAM. The resuming process is much faster now. Thanks for sharing that information.

Offline

#23 2013-11-08 16:19:09

batagy
Member
Registered: 2013-11-08
Posts: 2

Re: ZSWAP is coming

Hi All,

Is there any way to use zswap in case of older kernel versions?
I would like to use it on an older kernel 3.0.74.

Is there a kernel module that could maybe compiled into an older kernel?
Thanks a lot in advance!

Offline

#24 2013-11-08 17:18:38

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: ZSWAP is coming

@batagy, these forums are for Arch Linux support only.  Our repos contain only the most recent stable kernels, so people here are not likely to know the answer to that question.  Though right now, we are sitting at 3.11.6 since 3.12 is now out and in [testing], awaiting approval to be moved into [core]... which could take some time. 

Also, why are you running 3.0.74?!  Not only is that kernel EOL, but it is also 26 (maybe 27) revisions away from being the most recent in the 3.0-lts releases.  You know that when you have an lts kernel, the revision releases are not done so for entertainment?  They contain bus and security fixes, which can often be critical.

In any case, this is probably not the right place to be asking for this info.  Either install Arch and run an up to date machine (in which case you won't have this question), or ask somewhere where there is more knowledge about old kernels like yours.  Or use google.  BTW, the xda forums regarding android would indicate that patching the kernel with zram is entirely possible since they use older kernels and this feature is often touted as a great feature to some 3rd party kernel.

Offline

#25 2013-11-08 18:51:03

batagy
Member
Registered: 2013-11-08
Posts: 2

Re: ZSWAP is coming

Hi WonderWoofy,

Ok, I understand your points, and then indeed this is not the right place to my question.
Actually I was interesed in to patch SLES11 SP2 (which has 3.0.74) with either zram or zswap, not Arch Linux. This topic I found on google, and I thought maybe interesting to bring this question here, I was thinking the question is not really linux distro specific, the but I fully agree and understand the support here is for Arch Linux.

Good idea that I'll look around on XDA forums then.

Thanks for pointing me to right direction and sorry for troubling on this topic!

Last edited by batagy (2013-11-08 18:52:14)

Offline

Board footer

Powered by FluxBB