You are not logged in.

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

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

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

Board footer

Powered by FluxBB