(INFO)What is zram and how does it work???

Status
Not open for further replies.
Search This thread

-CALIBAN666-

Senior Member
I think its better to Post this here,when its not better,than sorry!!!
-----------------------------------------------------------------
Once a brief statement for those who are not traveling so long in the Android scene:
ZRAM = ramzswap = Compcache

In order to explain more precisely ZRAM first need other terms are more clearly defined:
Swap can be compared with the swap file on Windows. If the memory (RAM) to complete the PC the data that are being used not actively outsource (eg background applications) so as to re-evacuate RAM free. To this data is written to a hard disk. If required, this data is then read back from there easily. Even the fastest SSD is slower than the RAM. On Android, there is no swap!

In ZRAM unnecessary storage resources are compressed and then moved to a reserved area in the fixed RAM (ZRAM). So a kind of swap in memory.
This Ram is more free because the data then only about 1/4 of the former storage requirements have. However, the CPU has to work in more because they compress the data has (or unpack again when they are needed). The advantage clearly lies in the speed. Since the swap partition in RAM is much faster than this is a swap partition on a hard drive.

In itself a great thing. But Android does not have a swap partition, and therefore brings Android ZRAM under no performance gain as would be the case with a normal PC.

In normal PC would look like this:
Swap = swap file (on disk) -> Slow
ZRAM (swap in RAM) -> Faster than swap
RAM -> Quick

With Android, there is no swap partition, and therefore brings ZRAM also no performance boost.
The only thing that brings ZRAM is "more" RAM. Compressed by the "enlarged" so to speak of the available memory. That's on devices with little RAM (<256MB) also pretty useful. The S2 has 1GB but the rich, and more than. There must not be artificially pushed up to 1.5 GB.

After you activate the ZRAM also has 2 disadvantages. The encoding and decoding using CPU time, which in turn has higher power consumption.

Roughly one can say (For devices with more than 512MB RAM):
Without ZRAM: + CPU Performance | + Battery | RAM
With ZRAM: CPU Performance |-Battery | + RAM

For devices with too little RAM so it makes perfect sense. But who shoots the S2 already be fully complete RAM and then still need more?

Check whether you can ZRAM runs in the terminal with
free or cat / proc / meminfo

I hope it helps to understand zRam!!!!:eek:
 
Last edited:

nikufellow

Senior Member
May 14, 2012
2,966
845
simcity
Yeah thanks indeed for the info - so does this mean that we must have zram disabled because of low memory ?
 

-CALIBAN666-

Senior Member
not really because the system all the time creates virtual ram and distributed, just as if the ram is not needed, because then the virtual ram not needed and the system distributes it then falls to a normal ram, but I think it also comes to the what and how much the device is made for running multiple concurrent tasks, it is recommended.
 
  • Like
Reactions: nikufellow

irfanbagus

Senior Member
Mar 12, 2012
307
498
@CALIBAN666

ramzswap != compcache. both using compressed data on memory. both even from the same person AFAIR. the different is ramzswap using compressed swap and compcache using compressed cache.
kernel 2.6.35 source code from samsung have ramzswap support, but you need user space program to enable it (need little patch to build it for sgy but it's easy).
 
  • Like
Reactions: savie

hell_lock

Inactive Recognized Developer
Jan 20, 2012
5,970
5,173
27
New Delhi
@CALIBAN666

ramzswap != compcache. both using compressed data on memory. both even from the same person AFAIR. the different is ramzswap using compressed swap and compcache using compressed cache.
kernel 2.6.35 source code from samsung have ramzswap support, but you need user space program to enable it (need little patch to build it for sgy but it's easy).

Can u help me on enabling ramzswap?? Zram is laggy

Sent from my GT-S5360 using XDA
 

Rcain

Senior Member
Jul 9, 2012
128
16
Not understood... Android has no swap? Then what is swapper for? Swapping partition?
 

shubhs4frndz

Senior Member
Sep 29, 2012
64
16
I tried swapper for my galaxy y n i didnt liked it personally
By that time i had stock sd card
Im gonna try zram on my 16 gb class 6 sd card..i wish this thing works for me cuz after installing merruk kernel, my 50 mb ram got stuck

Sent from my GT-S5360 using xda app-developers app
 
May 16, 2012
35
21
ecelis.sdf.org
swapp != zram

Not understood... Android has no swap? Then what is swapper for? Swapping partition?

With swapper you can have an swap file or you can choose to partition your SD-Card to have an swap partition there. Swap is not used by default in Galaxy Y and swap space is optional not really needed in Android (or Unix/Linux in general).

On the other hand, zram is a whole different beast.
 

kurotsugi

Senior Member
Feb 12, 2012
2,507
1,796
yogyakarta
If I'm not mistaken a dev for ace2 already made it several month ago. It using init.d script to control the zram stuff
 
Status
Not open for further replies.

Top Liked Posts

  • There are no posts matching your filters.
  • 120
    I think its better to Post this here,when its not better,than sorry!!!
    -----------------------------------------------------------------
    Once a brief statement for those who are not traveling so long in the Android scene:
    ZRAM = ramzswap = Compcache

    In order to explain more precisely ZRAM first need other terms are more clearly defined:
    Swap can be compared with the swap file on Windows. If the memory (RAM) to complete the PC the data that are being used not actively outsource (eg background applications) so as to re-evacuate RAM free. To this data is written to a hard disk. If required, this data is then read back from there easily. Even the fastest SSD is slower than the RAM. On Android, there is no swap!

    In ZRAM unnecessary storage resources are compressed and then moved to a reserved area in the fixed RAM (ZRAM). So a kind of swap in memory.
    This Ram is more free because the data then only about 1/4 of the former storage requirements have. However, the CPU has to work in more because they compress the data has (or unpack again when they are needed). The advantage clearly lies in the speed. Since the swap partition in RAM is much faster than this is a swap partition on a hard drive.

    In itself a great thing. But Android does not have a swap partition, and therefore brings Android ZRAM under no performance gain as would be the case with a normal PC.

    In normal PC would look like this:
    Swap = swap file (on disk) -> Slow
    ZRAM (swap in RAM) -> Faster than swap
    RAM -> Quick

    With Android, there is no swap partition, and therefore brings ZRAM also no performance boost.
    The only thing that brings ZRAM is "more" RAM. Compressed by the "enlarged" so to speak of the available memory. That's on devices with little RAM (<256MB) also pretty useful. The S2 has 1GB but the rich, and more than. There must not be artificially pushed up to 1.5 GB.

    After you activate the ZRAM also has 2 disadvantages. The encoding and decoding using CPU time, which in turn has higher power consumption.

    Roughly one can say (For devices with more than 512MB RAM):
    Without ZRAM: + CPU Performance | + Battery | RAM
    With ZRAM: CPU Performance |-Battery | + RAM

    For devices with too little RAM so it makes perfect sense. But who shoots the S2 already be fully complete RAM and then still need more?

    Check whether you can ZRAM runs in the terminal with
    free or cat / proc / meminfo

    I hope it helps to understand zRam!!!!:eek:
    18
    I think its better to Post this here,when its not better,than sorry!!!
    -----------------------------------------------------------------
    ...
    With Android, there is no swap partition, and therefore brings ZRAM also no performance boost.
    The only thing that brings ZRAM is "more" RAM. Compressed by the "enlarged" so to speak of the available memory. That's on devices with little RAM (<256MB) also pretty useful. The S2 has 1GB but the rich, and more than. There must not be artificially pushed up to 1.5 GB.

    After you activate the ZRAM also has 2 disadvantages. The encoding and decoding using CPU time, which in turn has higher power consumption.

    Roughly one can say (For devices with more than 512MB RAM):
    Without ZRAM: + CPU Performance | + Battery | RAM
    With ZRAM: CPU Performance |-Battery | + RAM

    For devices with too little RAM so it makes perfect sense. But who shoots the S2 already be fully complete RAM and then still need more?

    Check whether you can ZRAM runs in the terminal with
    free or cat / proc / meminfo

    I hope it helps to understand zRam!!!!:eek:

    Well even though many thanked your post, your statement is wrong in several regards. You say that Android has no swap partition (which is true) and so zram would not bring a performance boost (which is partly wrong). It will also not give you more RAM (just check any program that reports available RAM on the device). It will actually give you LESS free usable RAM, but supply an additional type of memory space (the swap) instead. This Linux "Swap" space is usually not activated with Android on top of it but there is no reason not to try out.

    Despite its name, ZRAM has little to with RAM (except that it uses it). ZRAM is a block device in RAM which can be used only for Swap purposes. It acts as a swapfile however is not on disk but in RAM where the blocks are compressed - so not using the size they would use on uncompressed devices - like a disk.

    For its use just look at the sequence of actions to activate it (from my device):
    Code:
    #!/system/bin/sh
    sysctl -w vm.swappiness=100
    echo '1' > /sys/block/zram0/reset
    echo $((64*1024*1024)) > /sys/block/zram0/disksize
    mkswap /dev/block/zram0
    swapon /dev/block/zram0
    1. set swappiness to max value (this makes sure it also well used) - you may vary here
    2. you must create a block device in \dev\block\zram0
    3. you activate swap on that device
    So you see that actually the normal Linux SWAP is used, but it is on that special ZRAM device. Contrary to assumptions read, the amount of swap space reserved is the offered space to the system (in my case 64MB), but not the RAM eaten away from the system. That is the good part of the story - in my observation the amount of RAM eaten is just 1/3 of the swap space offered. You get the used size be accessing \sys\block\zram0\mem_used_total.

    Well and "performance boost" is not what you may expect here. The swap space can help to keep applications "active" for Android instead of killing them for low memory. So if you switch back from a large gameplay eating all your RAM the Launcher may just swap back from ZRAM which is much faster than having it restart and read all the apps icons again. Same when switching to other apps that were active before.

    Mind that the already sophisticated Android management (with priority levels of RAM use for applications) gets another complexity below that on the Linux layer with Linux SWAP. On Linux level the "swappiness" and on Android the memory levels for the memory manager priorities may need to be aligned with a clever strategy (which I don' have). I am too little expert on memory management but I noticed that Go Launcher much less reloads with ZRAM than without.

    Edit 20121214: I have de-activated swap in the meantime for me. Things are getting too laggy for me in daily use, no matter which swappiness selected. So I pay the price that sometime I could have Go launcher not reload with much more frequently waiting for any other UI action to complete. This is not even predictable well (because of not well linked memory management is my guess) and so I chose the lesser evil for my use.

    Please also consult other sources as your device may have different paths to read data from. The architecture of Linux/Android is however surely the same.
    3
    no its very good for devices with less ram like 289mb and we have less ram,so its useless for higher ram devices with 800-1000,but that can u read in this guide;)
    2
    Is enabling the ZRAM is the correct step to gain performance?!!

    If you really like to speed up your android device (iberry auxus note 5.5) that have 2gb of ram, then activating the zram is the first wrong thing you could do!
    Anyway to activate zram your kernel need to support it, and except if you are running some custom rom on your device with enabled zram functionality, the Manufacture of your device will never let you do this on it by default!
    But even if you do activate the Z-Ram ( aka compcache - Compressed cache) then you will loose some of the CPU's processing power for compressing and decompressing the inactive applications into a separated memory block in the devices Ram memory. Also this lead to less idle state of your device, because the CPU will wake up pretty often trying to compress and decompress the needed data, so this will leed to more battery consuming. And if you like to get some gaming performance you will have to activate the GPU rendering, which will also lead to more battery consuming, and over all you will loose much more than you could get from the Zram!

    Anyway for those devices with 512 mb of ram or even less, my advice is to try to setup the OOM minfree parameters (Out of memory killer - The task manager integrated in the Android kernel) values, so less inactive cached apps will occupy the ram, in other words more free ram for the foreground, Visible and secondary Server(Services) applications.
    The main disadvantage: the more aggressive the minfree values you set, less multitasking you'l get.
    Also you could play around with the sysctl command (system control).

    Finale conclusion: If ZRam was necessary for your device's performances, than it would have been pre-activated by default!
    2
    Sorry for too many questions mate - am the noobest guy here on xda that is why :(

    no problem bro,thats the reason why i open this thread.and hey im noob too :eek: