Situation: to study the effect of zram
's virtual memory compression (wiki) on memory's size and its speed; when swap is not on HDD/SSD; use zswap
if you want to have swap on HDD/SSD
Motivation: I experience no effect on the memory's size but increased amount of errors from systemd
/... with runit
i.e. possible stability issues with the compression, although paging should be avoided more
Code
# http://askubuntu.com/a/800645/25388
modprobe zram
echo lz4 > /sys/block/zram0/comp_algorithm
echo 4G > /sys/block/zram0/disksize
mkswap --label zram0 /dev/zram0
swapon --priority 100 /dev/zram0
Characteristics
Command
cat /sys/block/zram0/orig_data_size
gives4096
.RAM full and swap full. So computation ends when total memory consumption reaches the high about 20 GB, failing the computation.
Command
swapon
baed oncat /proc/swaps
NAME TYPE SIZE USED PRIO /dev/sda3 partition 8G 0B -1 /dev/zram0 partition 4G 0B 100
Command
free -m
total used free shared buff/cache available Mem: 7925 1390 5465 172 1069 6074 Swap: 12226 0 12226
Command
df -k | grep sda2
about current memory use in SSD, possibility to extend it for Swap.Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 108299224 76880916 25893932 75% / % df -h /dev/sda2 104G 74G 25G 75% /
Test code: any memory-heavy Matlab computation.
Output: the size of matrix does not increase with the implementation. Expected output: increase in memory size.
System: Linux Ubuntu 16.04 64 bit
Hardware: Macbook Air 2013-mid
free -m
would be more useful. – cas Jul 24 '16 at 9:30swapon
without the-s
option gives more useful output. – cas Jul 24 '16 at 9:31swapon
(or in /etc/fstab). AFAIK, to change the priority of a swap device you have to runswapoff
on it first, and thenswapon
again with the new priority. – cas Jul 24 '16 at 10:25