8 10 2013
android zram
android 内核中引入zram
Compressing pages and keeping them in RAM virtually increases its capacity. This allows more applications to fit in given amount of memory.
The usual argument I get is – memory is so cheap so why bother with compression? So I list here some of the use cases. Rest depends on your imagination 🙂
Netbooks: Market is now getting flooded with these “lightweight laptops”. These are memory constrained but have CPU enough to drive on compressed memory (e.g. Cloudbook features 1.2 GHz processor!).
Virtualization: With compcache at hypervisor level, we can compress any part of guest memory transparently – this is true for any type of Guest OS (Linux, Windows etc.). This should allow running more number of VMs for given amount of total host memory.
Embedded Devices: Memory is scarce and adding more memory increases device cost. Also, flash storage suffers from wear-leveling issues, so its useful if we can avoid using them as swap device.
缺点:需要更多cpu运算,功耗会增加.
50c50
< CONFIG_SWAP=y
—
> # CONFIG_SWAP is not set
2393,2395d2392
< CONFIG_ZRAM=y
< # CONFIG_ZRAM_DEBUG is not set
< CONFIG_ZSMALLOC=y
busybox swapoff /dev/block/zram0
dd if=/dev/zero of=/dev/block/zram0
echo 1 >/sys/block/zram0/reset
echo 167772160>/sys/block/zram0/disksize
busybox mkswap /dev/block/zram0
busybox swapon /dev/block/zram0
echo 100 > /proc/sys/vm/swappiness //根据需要来调,当系统有大内存时,可以完全不用交換,写为0.
Comments are currently closed.