I copied the zram config and settings from https://gist.github.com/sultanqasim/79799883c6b81c710e36a38008dfa374
[code]#!/bin/bash
Raspberry Pi ZRAM script
Tuned for quad core, 1 GB RAM models
put me in /etc/init.d/zram.sh and make me executable
then run “sudo update-rc.d zram.sh defaults”
modprobe zram
echo 3 >/sys/devices/virtual/block/zram0/max_comp_streams
echo lz4 >/sys/devices/virtual/block/zram0/comp_algorithm
echo 268435456 >/sys/devices/virtual/block/zram0/mem_limit
echo 536870912 >/sys/devices/virtual/block/zram0/disksize
mkswap /dev/zram0
swapon -p 0 /dev/zram0
sysctl vm.swappiness=70[/code]
I must admit rather impressed with Zram and have to say I am perplexed by the 100mb file swap provided by Raspberian. If swap on SD = Bad then why a 100mb file based one. Also can partitions fail on a SD and still allow other partitions run? Or because of the serial nature its ‘Game over’ as a partition at the end of the disk from a noob perspective makes much more sense.
Anyway I did a little bit of a test with Zram and just loaded web pages into chromium. Some of these are pretty heavy like logged onto Outlook.com (god knows what it does), Facebook, Youtube playing a stream of music videos, twitter,bbc, guardian, independent, github, wikipedia, the independent.
When you start to get to 9 pages things start to get heavy until the page loads 12 or 13 in tabs then as you will see in the little info output I created Zram works perfect but when it approaches nearly full then things start to slow considerably.
If you want to test it yourself and have some comparisons here is my little bit of a script.
echo "****************************************************************" >> info
echo "****************************************************************" >> info
echo "Tab $1 /procs/swaps" >> info
cat /proc/swaps >> info
echo "*********************" >> info
echo "Tab $1 /procs/meminfo" >> info
cat /proc/meminfo >> info
echo "***********" >> info
echo "Tab $1 free" >> info
free -m >> info
echo "*************" >> info
echo "tab $1 vmstat" >> info
vmstat >> info
echo >> info
echo >> info
Here is the output waiting for each tab to settle and load then running sh info.sh
Here is my results and as you can see the above Zram script is working wonderfully and seems to be extremely well optimised.
[code]****************************************************************
Tab 1 /procs/swaps
Filename Type Size Used Priority
/var/swap file 102396 0 -1
/dev/zram0 partition 524284 0 0
Tab 1 /procs/meminfo
MemTotal: 882772 kB
MemFree: 228504 kB
MemAvailable: 576088 kB
Buffers: 47408 kB
Cached: 378432 kB
SwapCached: 0 kB
Active: 385092 kB
Inactive: 223296 kB
Active(anon): 183168 kB
Inactive(anon): 43644 kB
Active(file): 201924 kB
Inactive(file): 179652 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 626680 kB
SwapFree: 626680 kB
Dirty: 80 kB
Writeback: 0 kB
AnonPages: 182568 kB
Mapped: 194340 kB
Shmem: 44244 kB
Slab: 25440 kB
SReclaimable: 13932 kB
SUnreclaim: 11508 kB
KernelStack: 2144 kB
PageTables: 5184 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1068064 kB
Committed_AS: 1508928 kB
VmallocTotal: 1179648 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
CmaTotal: 8192 kB
CmaFree: 3720 kB
Tab 1 free
total used free shared buffers cached
Mem: 862 638 223 43 46 369
-/+ buffers/cache: 223 639
Swap: 611 0 611
tab 1 vmstat
procs -----------memory---------- —swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 228392 47408 378432 0 0 37 14 227 130 2 0 94 3 0
Tab 2 /procs/swaps
Filename Type Size Used Priority
/var/swap file 102396 0 -1
/dev/zram0 partition 524284 0 0
Tab 2 /procs/meminfo
MemTotal: 882772 kB
MemFree: 186408 kB
MemAvailable: 537384 kB
Buffers: 47480 kB
Cached: 388268 kB
SwapCached: 0 kB
Active: 416576 kB
Inactive: 232800 kB
Active(anon): 214228 kB
Inactive(anon): 50248 kB
Active(file): 202348 kB
Inactive(file): 182552 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 626680 kB
SwapFree: 626680 kB
Dirty: 436 kB
Writeback: 0 kB
AnonPages: 213628 kB
Mapped: 202796 kB
Shmem: 50848 kB
Slab: 25656 kB
SReclaimable: 14072 kB
SUnreclaim: 11584 kB
KernelStack: 2232 kB
PageTables: 5828 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1068064 kB
Committed_AS: 1656596 kB
VmallocTotal: 1179648 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
CmaTotal: 8192 kB
CmaFree: 3720 kB
Tab 2 free
total used free shared buffers cached
Mem: 862 680 182 49 46 379
-/+ buffers/cache: 254 607
Swap: 611 0 611
tab 2 vmstat
procs -----------memory---------- —swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 0 186408 47480 388268 0 0 37 14 228 132 3 0 93 4 0
Tab 3 /procs/swaps
Filename Type Size Used Priority
/var/swap file 102396 0 -1
/dev/zram0 partition 524284 0 0
Tab 3 /procs/meminfo
MemTotal: 882772 kB
MemFree: 97988 kB
MemAvailable: 476096 kB
Buffers: 47732 kB
Cached: 422400 kB
SwapCached: 0 kB
Active: 475792 kB
Inactive: 261284 kB
Active(anon): 267536 kB
Inactive(anon): 57612 kB
Active(file): 208256 kB
Inactive(file): 203672 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 626680 kB
SwapFree: 626680 kB
Dirty: 4 kB
Writeback: 0 kB
AnonPages: 266952 kB
Mapped: 210388 kB
Shmem: 58212 kB
Slab: 25892 kB
SReclaimable: 14276 kB
SUnreclaim: 11616 kB
KernelStack: 2320 kB
PageTables: 6620 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1068064 kB
Committed_AS: 1901576 kB
VmallocTotal: 1179648 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
CmaTotal: 8192 kB
CmaFree: 3720 kB
Tab 3 free
total used free shared buffers cached
Mem: 862 766 95 56 46 412
-/+ buffers/cache: 307 554
Swap: 611 0 611
tab 3 vmstat
procs -----------memory---------- —swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 0 97840 47732 422400 0 0 38 14 229 134 3 0 93 4 0
Tab 4 /procs/swaps
Filename Type Size Used Priority
/var/swap file 102396 0 -1
/dev/zram0 partition 524284 0 0
Tab 4 /procs/meminfo
MemTotal: 882772 kB
MemFree: 62068 kB
MemAvailable: 440468 kB
Buffers: 47816 kB
Cached: 431356 kB
SwapCached: 0 kB
Active: 507940 kB
Inactive: 264016 kB
Active(anon): 293376 kB
Inactive(anon): 66332 kB
Active(file): 214564 kB
Inactive(file): 197684 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 626680 kB
SwapFree: 626680 kB
Dirty: 20 kB
Writeback: 0 kB
AnonPages: 292776 kB
Mapped: 220272 kB
Shmem: 66932 kB
Slab: 25964 kB
SReclaimable: 14220 kB
SUnreclaim: 11744 kB
KernelStack: 2408 kB
PageTables: 7268 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1068064 kB
Committed_AS: 2060328 kB
VmallocTotal: 1179648 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
CmaTotal: 8192 kB
CmaFree: 3720 kB
Tab 4 free
total used free shared buffers cached
Mem: 862 801 60 65 46 421
-/+ buffers/cache: 333 528
Swap: 611 0 611
tab 4 vmstat
procs -----------memory---------- —swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 0 61748 47816 431356 0 0 38 14 230 136 3 1 93 4 0
Tab 5 /procs/swaps
Filename Type Size Used Priority
/var/swap file 102396 0 -1
/dev/zram0 partition 524284 4784 0
Tab 5 /procs/meminfo
MemTotal: 882772 kB
MemFree: 32140 kB
MemAvailable: 381172 kB
Buffers: 47500 kB
Cached: 409016 kB
SwapCached: 0 kB
Active: 500352 kB
Inactive: 299548 kB
Active(anon): 308388 kB
Inactive(anon): 108884 kB
Active(file): 191964 kB
Inactive(file): 190664 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 626680 kB
SwapFree: 621896 kB
Dirty: 2144 kB
Writeback: 0 kB
AnonPages: 343280 kB
Mapped: 232768 kB
Shmem: 73996 kB
Slab: 26632 kB
SReclaimable: 14724 kB
SUnreclaim: 11908 kB
KernelStack: 2480 kB
PageTables: 8036 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1068064 kB
Committed_AS: 2257416 kB
VmallocTotal: 1179648 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
CmaTotal: 8192 kB
CmaFree: 3720 kB
Tab 5 free
total used free shared buffers cached
Mem: 862 830 31 72 46 399
-/+ buffers/cache: 384 477
Swap: 611 4 607
tab 5 vmstat
procs -----------memory---------- —swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 4784 32224 47500 409016 0 0 37 14 231 138 3 1 93 4 0
Tab 6 /procs/swaps
Filename Type Size Used Priority
/var/swap file 102396 0 -1
/dev/zram0 partition 524284 4968 0
Tab 6 /procs/meminfo
MemTotal: 882772 kB
MemFree: 38780 kB
MemAvailable: 304264 kB
Buffers: 47868 kB
Cached: 345820 kB
SwapCached: 0 kB
Active: 459344 kB
Inactive: 333160 kB
Active(anon): 303744 kB
Inactive(anon): 189672 kB
Active(file): 155600 kB
Inactive(file): 143488 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 626680 kB
SwapFree: 621712 kB
Dirty: 8456 kB
Writeback: 0 kB
AnonPages: 398884 kB
Mapped: 253876 kB
Shmem: 94608 kB
Slab: 26604 kB
SReclaimable: 14712 kB
SUnreclaim: 11892 kB
KernelStack: 2568 kB
PageTables: 8836 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1068064 kB
Committed_AS: 2494292 kB
VmallocTotal: 1179648 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
CmaTotal: 8192 kB
CmaFree: 3720 kB
Tab 6 free
total used free shared buffers cached
Mem: 862 824 37 92 46 337
-/+ buffers/cache: 439 422
Swap: 611 4 607
tab 6 vmstat
procs -----------memory---------- —swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 0 4968 38592 47868 345820 0 0 37 14 233 141 3 1 92 4 0
Tab 7 /procs/swaps
Filename Type Size Used Priority
/var/swap file 102396 0 -1
/dev/zram0 partition 524284 24976 0
Tab 7 /procs/meminfo
MemTotal: 882772 kB
MemFree: 49172 kB
MemAvailable: 192788 kB
Buffers: 1944 kB
Cached: 268884 kB
SwapCached: 204 kB
Active: 412288 kB
Inactive: 363072 kB
Active(anon): 321340 kB
Inactive(anon): 276040 kB
Active(file): 90948 kB
Inactive(file): 87032 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 626680 kB
SwapFree: 601704 kB
Dirty: 2416 kB
Writeback: 0 kB
AnonPages: 504400 kB
Mapped: 230216 kB
Shmem: 92848 kB
Slab: 25172 kB
SReclaimable: 13188 kB
SUnreclaim: 11984 kB
KernelStack: 2784 kB
PageTables: 10400 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1068064 kB
Committed_AS: 2952076 kB
VmallocTotal: 1179648 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
CmaTotal: 8192 kB
CmaFree: 3720 kB
Tab 7 free
total used free shared buffers cached
Mem: 862 814 48 90 1 262
-/+ buffers/cache: 549 312
Swap: 611 24 587
tab 7 vmstat
procs -----------memory---------- —swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 0 24976 49172 1948 268880 0 2 35 17 272 205 4 1 91 5 0
Tab 8 /procs/swaps
Filename Type Size Used Priority
/var/swap file 102396 0 -1
/dev/zram0 partition 524284 240624 0
Tab 8 /procs/meminfo
MemTotal: 882772 kB
MemFree: 47836 kB
MemAvailable: 92908 kB
Buffers: 1524 kB
Cached: 210312 kB
SwapCached: 2636 kB
Active: 302556 kB
Inactive: 374404 kB
Active(anon): 275784 kB
Inactive(anon): 320572 kB
Active(file): 26772 kB
Inactive(file): 53832 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 626680 kB
SwapFree: 386056 kB
Dirty: 0 kB
Writeback: 64 kB
AnonPages: 464860 kB
Mapped: 190512 kB
Shmem: 131140 kB
Slab: 23236 kB
SReclaimable: 10852 kB
SUnreclaim: 12384 kB
KernelStack: 2848 kB
PageTables: 11284 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1068064 kB
Committed_AS: 3337872 kB
VmallocTotal: 1179648 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
CmaTotal: 8192 kB
CmaFree: 3720 kB
Tab 8 free
total used free shared buffers cached
Mem: 862 815 46 128 1 205
-/+ buffers/cache: 608 253
Swap: 611 234 377
tab 8 vmstat
procs -----------memory---------- —swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 240624 47372 1816 210464 0 19 42 18 368 386 4 1 88 6 0
Tab 9 /procs/swaps
Filename Type Size Used Priority
/var/swap file 102396 0 -1
/dev/zram0 partition 524284 383132 0
Tab 9 /procs/meminfo
MemTotal: 882772 kB
MemFree: 38096 kB
MemAvailable: 141384 kB
Buffers: 6588 kB
Cached: 212592 kB
SwapCached: 7396 kB
Active: 328640 kB
Inactive: 299156 kB
Active(anon): 251844 kB
Inactive(anon): 237288 kB
Active(file): 76796 kB
Inactive(file): 61868 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 626680 kB
SwapFree: 243548 kB
Dirty: 0 kB
Writeback: 8 kB
AnonPages: 402312 kB
Mapped: 148272 kB
Shmem: 80232 kB
Slab: 23964 kB
SReclaimable: 11168 kB
SUnreclaim: 12796 kB
KernelStack: 2784 kB
PageTables: 11612 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1068064 kB
Committed_AS: 3481016 kB
VmallocTotal: 1179648 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
CmaTotal: 8192 kB
CmaFree: 3720 kB
Tab 9 free
total used free shared buffers cached
Mem: 862 825 37 78 6 207
-/+ buffers/cache: 610 251
Swap: 611 374 237
tab 9 vmstat
procs -----------memory---------- —swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 383132 37684 6588 212740 5 26 37 19 639 911 6 1 86 7 0
Tab 10 /procs/swaps
Filename Type Size Used Priority
/var/swap file 102396 0 -1
/dev/zram0 partition 524284 410772 0
Tab 10 /procs/meminfo
MemTotal: 882772 kB
MemFree: 40220 kB
MemAvailable: 84376 kB
Buffers: 1336 kB
Cached: 146260 kB
SwapCached: 3736 kB
Active: 318552 kB
Inactive: 300932 kB
Active(anon): 269880 kB
Inactive(anon): 269760 kB
Active(file): 48672 kB
Inactive(file): 31172 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 626680 kB
SwapFree: 215908 kB
Dirty: 236 kB
Writeback: 0 kB
AnonPages: 468272 kB
Mapped: 140112 kB
Shmem: 67816 kB
Slab: 23412 kB
SReclaimable: 10544 kB
SUnreclaim: 12868 kB
KernelStack: 2800 kB
PageTables: 11892 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1068064 kB
Committed_AS: 3576252 kB
VmallocTotal: 1179648 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
CmaTotal: 8192 kB
CmaFree: 3720 kB
Tab 10 free
total used free shared buffers cached
Mem: 862 823 38 66 1 142
-/+ buffers/cache: 678 183
Swap: 611 401 210
tab 10 vmstat
procs -----------memory---------- —swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 410772 39612 1356 146388 6 29 39 19 662 950 6 2 85 7 0
Tab 11 /procs/swaps
Filename Type Size Used Priority
/var/swap file 102396 69408 -1
/dev/zram0 partition 524284 483252 0
Tab 11 /procs/meminfo
MemTotal: 882772 kB
MemFree: 34896 kB
MemAvailable: 83612 kB
Buffers: 1020 kB
Cached: 175488 kB
SwapCached: 20760 kB
Active: 297088 kB
Inactive: 291876 kB
Active(anon): 247620 kB
Inactive(anon): 256912 kB
Active(file): 49468 kB
Inactive(file): 34964 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 626680 kB
SwapFree: 74020 kB
Dirty: 2320 kB
Writeback: 4 kB
AnonPages: 392116 kB
Mapped: 160808 kB
Shmem: 92048 kB
Slab: 23572 kB
SReclaimable: 10488 kB
SUnreclaim: 13084 kB
KernelStack: 2848 kB
PageTables: 12236 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1068064 kB
Committed_AS: 3721032 kB
VmallocTotal: 1179648 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
CmaTotal: 8192 kB
CmaFree: 3720 kB
Tab 11 free
total used free shared buffers cached
Mem: 862 828 34 89 1 171
-/+ buffers/cache: 655 206
Swap: 611 539 72
tab 11 vmstat
procs -----------memory---------- —swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 552660 34724 1040 175616 11 41 43 24 677 976 7 2 84 8 0
Tab 12 /procs/swaps
Filename Type Size Used Priority
/var/swap file 102396 79028 -1
/dev/zram0 partition 524284 518712 0
Tab 12 /procs/meminfo
MemTotal: 882772 kB
MemFree: 43980 kB
MemAvailable: 88976 kB
Buffers: 1524 kB
Cached: 170856 kB
SwapCached: 7900 kB
Active: 282844 kB
Inactive: 279252 kB
Active(anon): 230864 kB
Inactive(anon): 250452 kB
Active(file): 51980 kB
Inactive(file): 28800 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 626680 kB
SwapFree: 28940 kB
Dirty: 128 kB
Writeback: 0 kB
AnonPages: 382592 kB
Mapped: 159252 kB
Shmem: 91584 kB
Slab: 23468 kB
SReclaimable: 10352 kB
SUnreclaim: 13116 kB
KernelStack: 2840 kB
PageTables: 12260 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1068064 kB
Committed_AS: 3718588 kB
VmallocTotal: 1179648 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
CmaTotal: 8192 kB
CmaFree: 3720 kB
Tab 12 free
total used free shared buffers cached
Mem: 862 819 42 89 1 167
-/+ buffers/cache: 650 211
Swap: 611 583 28
tab 12 vmstat
procs -----------memory---------- —swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 597696 43576 1544 171112 14 46 45 25 700 1015 7 2 83 8 0
Tab 13 /procs/swaps
Filename Type Size Used Priority
/var/swap file 102396 102384 -1
/dev/zram0 partition 524284 524268 0
Tab 13 /procs/meminfo
MemTotal: 882772 kB
MemFree: 37236 kB
MemAvailable: 62760 kB
Buffers: 1212 kB
Cached: 128836 kB
SwapCached: 20592 kB
Active: 290876 kB
Inactive: 271320 kB
Active(anon): 248668 kB
Inactive(anon): 252192 kB
Active(file): 42208 kB
Inactive(file): 19128 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 626680 kB
SwapFree: 84 kB
Dirty: 1100 kB
Writeback: 0 kB
AnonPages: 412340 kB
Mapped: 115124 kB
Shmem: 68544 kB
Slab: 23476 kB
SReclaimable: 10296 kB
SUnreclaim: 13180 kB
KernelStack: 2840 kB
PageTables: 12412 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1068064 kB
Committed_AS: 3761080 kB
VmallocTotal: 1179648 kB
VmallocUsed: 0 kB
VmallocChunk: 0 kB
CmaTotal: 8192 kB
CmaFree: 3720 kB
Tab 13 free
total used free shared buffers cached
Mem: 862 825 36 66 1 124
-/+ buffers/cache: 698 163
Swap: 611 611 0
tab 13 vmstat
procs -----------memory---------- —swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 4 626656 40348 1188 126272 18 50 49 26 716 1041 7 2 82 10 0
[/code]