Kernel: ZRAM?

In short, it’s compressed RAM, that by using our mighty CPU compress 150MB of Real RAM into 300MB ZRAM!


This is simple math:
we have 848MB RAM, + 300ZRAM – 150 Needed for ZRAM = 1GB RAM đŸ™‚

You can see if it’s working by entering “Terminal Emulator“-App, or connection by ADB and type:

[cc lang=’bash’ line_numbers=’false’]free[/cc]

you will see this …

Code:

[cc lang=’bash’ ]
root@android:/ # free
total used free shared buffers
Mem: 848164 801800 46364 0 13456
-/+ buffers: 788344 59820
Swap: 292968 23420 269548

[/cc]

in SWAP filed you see it exist and works!

Also there is one more advanced check đŸ˜‰

type:

[cc lang=’bash’ ]

su
zram_stats

[/cc]

you get:

Code:

[cc lang=’bash’ ]
127|root@android:/ # zram_stats
Swaps Status
Filename Type Size Used Priority
/dev/block/zram0 partition 97656 7804 20
/dev/block/zram1 partition 97656 7804 20
/dev/block/zram2 partition 97656 7808 20
ZRAM STATS
/sys/block/zram0
disksize: 100003840
num_reads: 474
num_writes: 2013
invalid_io: 0
notify_free: 61
zero_pages: 105
orig_data_size: 7565312
compr_data_size: 3465633
mem_used_total: 3563520
avg_compr_ratio: 45 %
mem_overhead: 2 %

/sys/block/zram1
disksize: 100003840
num_reads: 473
num_writes: 2013
invalid_io: 0
notify_free: 61
zero_pages: 106
orig_data_size: 7561216
compr_data_size: 3447524
mem_used_total: 3584000
avg_compr_ratio: 45 %
mem_overhead: 3 %

/sys/block/zram2
disksize: 100003840
num_reads: 477
num_writes: 2014
invalid_io: 0
notify_free: 61
zero_pages: 99
orig_data_size: 7593984
compr_data_size: 3444863
mem_used_total: 3559424
avg_compr_ratio: 45 %
mem_overhead: 3 %
[/cc]

You see 3 ZRAM swaps each 100MB and they work in load balance!
All filled/released in one push, it’s fully auto! it’s will help on heavy RAM load!

 

more Info:

ZRAM (aka CompCache aka RAMZSwap)

ZRAM is an updated version formally known as CompCache and RAMZSwap. It was originally designed for 2.6.38.xx kernels, I have backported to our 3.0.xx kernel. ZRAM allows real-time compression of memory objects in RAM thus reducing memory pressure for the Linux kernel and can keep more apps in memory longer (more apps in RAM == better performance, less fetching from slower MMC or SDCard). Compression, however, is not Free. Some CPU cycles are required to do the compress/decompression, so there’s a slight penalty for it. The original CompCache / RAMZSwap required a user space binary to control its behavior which adds additional penalty to performance, but the new version ZRAM eliminated the need for a separate dedicated daemon, thus reducing the overhead and increased performance from the old CompCache by 20%. Therefore, with the newer implementation of ZRAM interface, the performance penalty is almost negligible.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*