Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
zram strange issue
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Goshanecr
Apprentice
Apprentice


Joined: 17 Aug 2005
Posts: 158
Location: Russia

PostPosted: Tue May 22, 2018 7:32 pm    Post subject: zram strange issue Reply with quote

Good day!

I'm setup zram with wiki.
/etc/conf.d/zram-init
Code:
load_on_start="yes"
unload_on_stop="yes"
num_devices="1"

type0="swap"
flag0=
size0="192"
maxs0=1
algo0=lz4


zramctl
Code:

NAME       ALGORITHM DISKSIZE   DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lz4           192M 191,8M 61,5M 65,4M       1 [SWAP]


cat /proc/swaps
Code:
Filename                                Type            Size    Used    Priority
/dev/sda3                               partition       1048572 183948  -2
/dev/zram0                              partition       196604  196348  16383


And my question is illustrated in zramctl and /proc/swaps output. Why when my zram based swap has 192MB and from zramctl output it compressed size just 61.5MB but it used full and start swapping to disk based swap?!!

I think that for example if I have 100Mb zram based swap with approximately compression ratio 3, then system can fill it to 300MB uncompressed data, but there I have strange statistics.
Please somebody explain that issue to me. Maybe I'm misunderstanding something?
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3345
Location: Rasi, Finland

PostPosted: Tue May 22, 2018 7:53 pm    Post subject: Reply with quote

If your only usage for zram is swap, then I'd suggest you to move to zswap. It's hazzle-free and, as the name suggests, meant for compressing swap (only).

You can search the kernel documentation for it by running
Code:
find /usr/src/ -type f -name 'zswap.txt'


There isn't Gentoo wiki page for it (yet). But Arch wiki page shoud get you started too.

As for the strange behaviour of your zram... I don't have any idea atm...
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
Goshanecr
Apprentice
Apprentice


Joined: 17 Aug 2005
Posts: 158
Location: Russia

PostPosted: Tue May 22, 2018 8:02 pm    Post subject: Reply with quote

Yes, my usage of zram only for swap, but not for additional swap space, but for something like "Trying to expand low RAM amount by cost of some CPU time".
Now I want to understand why zram based swap show compression from zramctl output, but when size of DATA section equals size of zram it ends up, but COMPR section shows more than 3x lower amount.

Zucca wrote:
... then I'd suggest you to move to zswap. It's hazzle-free and, as the name suggests, meant for compressing swap (only).

Zucca thanks for suggestion! When I solve that issue, I'm try to use zswap for disk based swap also and maybe will have zram swap + zswap :)
Back to top
View user's profile Send private message
Goshanecr
Apprentice
Apprentice


Joined: 17 Aug 2005
Posts: 158
Location: Russia

PostPosted: Tue May 22, 2018 8:19 pm    Post subject: Reply with quote

Maybe I understand.... If I think right, amount of ram allocated to zram not piece which cuts from ram, but final size of data (uncompressed) which will fits in it, and amount of ram allocated to it dynamically changes with type of data stored on it, but not more than allocated amount.
So for example if I have 256MB ram and I give 100MB to zram which fills with data with compression ratio 2x, so it consumes 50MB, and I have in that case 256-50+100=306MB virtually RAM.

Am I right? If so, is it possible to set target minimum compression ratio for data stored on zram swap, if not then it sends to backend swap?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum