[Arm-dev] Using zram-swap

Robert Moskowitz rgm at htt-consult.com
Mon Oct 8 13:32:22 UTC 2018



On 10/7/18 11:57 AM, Pablo Sebastián Greco wrote:
> Too many questions together... ;-)
>
> El 7/10/18 a las 08:58, Robert Moskowitz escribió:
>> I have very recently learned about zram-swap.  Fedora-29-arm is using 
>> it.  It supposedly makes a considerable difference even over HD swap.
> Do you have a link for me to read about that? I'd like to see some 
> numbers on performance, specially on the CPU, because small ARM 
> devices are not exactly fast to compress.

I did a quick check of my F29-arm system's use of zram.  It is running 
zram 0.2-1.  A quick look at usage with an Xfce DE accessed via vnc that 
has Firefox running:

# swapon -s
Filename                Type         Size      Used Priority
/dev/zram0              partition    487304    10752    -2

# zramctl
NAME       ALGORITHM DISKSIZE  DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lz4         475.9M 11.2M  4.3M  4.9M       2 [SWAP]


I would suspect the performance of lz4 over SD I/O is superior, plus 
less wear and tear of memory over SD.  Here are a couple files and the 
systemctl status:


# cat /etc/zram.conf
# The factor is the percentage of total system RAM to allocate to the 
ZRAM block device(s).
FACTOR=2

# cat /etc/systemd/system/swap.target.wants/zram-swap.service
[Unit]
Description=Enable compressed swap in memory using zram
DefaultDependencies=no
Before=swap.target

[Service]
Type=oneshot
RemainAfterExit=yes
TimeoutStartSec=30sec
ExecStart=/usr/sbin/zramstart
ExecStop=/usr/sbin/zramstop

[Install]
WantedBy=swap.target

# systemctl -l --no-pager status zram-swap
\u25cf zram-swap.service - Enable compressed swap in memory using zram
    Loaded: loaded (/usr/lib/systemd/system/zram-swap.service; enabled; 
vendor preset: disabled)
    Active: active (exited) since Fri 2018-06-22 11:12:12 EDT; 3 months 
16 days ago
   Process: 437 ExecStart=/usr/sbin/zramstart (code=exited, 
status=0/SUCCESS)
  Main PID: 437 (code=exited, status=0/SUCCESS)

Jun 22 11:12:12 localhost zramstart[437]: Setting up swapspace version 
1, size = 475.9 MiB (498999296 bytes)
Jun 22 11:12:12 localhost zramstart[437]: no label, 
UUID=ba3bf62f-7bb0-4295-ad8c-2d26b000c3f8
Jun 22 11:12:12 localhost zramstart[437]: Activated ZRAM swap device of 
499 MB
Jun 22 11:12:12 localhost systemd[1]: Started Enable compressed swap in 
memory using zram.




More information about the Arm-dev mailing list