View Single Post
Posts: 155 | Thanked: 61 times | Joined on Nov 2009
#322
Originally Posted by craftyguy View Post
I don't get it, why would you use a ramdisk for swap? The whole reason the kernel even uses swap is to take inactive pages out of memory so there is room for active pages. By creating a ramdisk, you reduce the amount of RAM you can use for these active pages. Maybe to reduce wear on the flash device? I think this would ultimately reduce performance since your usable RAM size will be significantly reduced?
The point is that the swap is compressed. Lets say you allow zram0 to be a device that is 128MB (half your ram) and that zram achievs a 50% compression. Without going to physical swap (flash) you now have effectively 128+(128*2) = 384MB ram to work with - yes stuff is going to have to be compressed in and out mean CPU load, but the compression is lite and fast, and if your physical swap is slow, thats still preferable.

It's been a huge win for me on other constrained devices even with faster storage.

For example on a VPS I use:

DiskSize: 524288 kB
OrigDataSize: 104852 kB
ComprDataSize: 36712 kB
MemUsedTotal: 37848 kB

So I've given up 37MB to store 105MB - thats a gain (on a fairly small vps) of 68MB - if the compression stays the same and I use all the allocation - thats approx gain of 300MB on a 1GB system by using 200MB of RAM for the compression. I could be more aggressive too...

I use it on my laptop and desktop as well to great effect.

Last edited by phedders; 2011-02-02 at 05:07.
 

The Following User Says Thank You to phedders For This Useful Post: