You are not logged in.

#1 2020-11-07 01:03:03

Gyscos
Member
Registered: 2009-09-19
Posts: 33

Zram reporting shows no compression

I am using zram (using the systemd-swap package) with this config:

$ cat /etc/systemd/swap.conf
zram_enabled=1
zram_size=$(( RAM_SIZE / 3 ))
zram_count=1
zram_streams=${NCPU}
zram_alg=zstd
zram_prio=32767

(My system has 16GB memory, so the resulting zram device is ~5GB).
I have no other swap device.

After some time, the swap is used a bit, and I run zramctl to check the status:

$ zramctl
NAME       ALGORITHM DISKSIZE  DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 zstd          5.2G 11.6M 11.6M 11.6M       4 [SWAP]

This is consistent with the mm_stat file:

$ cat /sys/block/zram0/mm_stat
12124160 12120122 12124160        0 23826432        0        0     2959

It _seems_ to indicate that there is ~11.6MB of data in swap, which, once compressed, stayed at 11.6MB - so incompressible data? Sure, I guess it's possible.
The last field here is the number of "huge pages", I guess 4096 bytes each. 2959 * 4096 = 12120064, _very_ close to the total data stored, so I guess everything is huge pages here? But does "huge page" mean "incompressible page"? :S

I can check the content of /dev/zram0

$ sudo cat /dev/zram0 | wc -c
5574463488
$ sudo cat /dev/zram0 | zstd | wc -c
12207514

So ~5GB total, 11.6MB compressed. I can believe that. It doesn't tell me how much of the 5GB is non-zero though (how much "useful data" got compressed to 11.6MB). Was it also close to 11.6MB?

On the other hand:

$ free -h
              total        used        free      shared  buff/cache   available
Mem:           15Gi       9.6Gi       2.6Gi       795Mi       3.4Gi       4.9Gi
Swap:         5.2Gi       892Mi       4.3Gi

Also consistent with the output from `swapon --summary`.
So maybe there's actually 892MB of swap used? Is that what is compressed down to 11.6MB?
`htop` shows 892MB swap used as well.

I'm not sure how to interpret all that. Is zram reporting broken, and it should really be 893MB of uncompressed data, which got compressed down to 11.6MB? Or is it actually 11.6MB of uncompressed (and incompressible) data, while htop and free report some different value?

Last edited by Gyscos (2020-11-12 22:00:14)

Offline

#2 2021-09-29 10:37:01

kleku
Member
Registered: 2013-06-08
Posts: 1

Re: Zram reporting shows no compression

Same problem here:

t410:~:# zramctl
NAME       ALGORITHM DISKSIZE  DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lz4         931,5M 48,2M 48,2M 48,2M       4 [SWAP]
t410:~:# swapon
NAME       TYPE        SIZE   USED  PRIO
/dev/zram0 partition 931,5M 288,3M 32767

But on debian seems ok:

pve:~:# zramctl
NAME       ALGORITHM DISKSIZE  DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 zstd            8G  5.4G  1.4G  1.4G      24 [SWAP]
pve:~:# swapon
NAME       TYPE      SIZE USED PRIO
/dev/zram0 partition   8G 5.4G  100

Offline

#3 2021-09-29 17:56:37

adventurer
Member
Registered: 2014-05-04
Posts: 119

Re: Zram reporting shows no compression

You should switch to zram-generator  which works on my system as advertised:

zramctl
NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 zstd         15,5G  41M 18,8M 19,5M       8 [SWAP] 

Offline

#4 2021-09-29 20:37:58

agapito
Member
From: Who cares.
Registered: 2008-11-13
Posts: 641

Re: Zram reporting shows no compression


Excuse my poor English.

Offline

#5 2021-09-29 20:58:29

foutrelis
Developer
From: Athens, Greece
Registered: 2008-07-28
Posts: 705
Website

Re: Zram reporting shows no compression

Gyscos wrote:

Is zram reporting broken, and it should really be 893MB of uncompressed data, which got compressed down to 11.6MB? Or is it actually 11.6MB of uncompressed (and incompressible) data, while htop and free report some different value?

It's likely 893M cached by zswap, of which 11.6M has been pushed to zram (by zswap treating zram as a backing store).

If you use RAM-based swap only, consider disabling zswap. (As per the tip here.)

Last edited by foutrelis (2021-09-29 21:04:24)

Offline

#6 2021-09-29 22:21:02

agapito
Member
From: Who cares.
Registered: 2008-11-13
Posts: 641

Re: Zram reporting shows no compression

foutrelis is right, you should add:

zswap.enabled=0

to your kernel parameters.


Excuse my poor English.

Offline

Board footer

Powered by FluxBB