Monday, October 3, 2011

Zram to the Max

While trying to optimize the elementary OS performance, Sergey Davidoff stumbled upon a project called compcache that creates a RAM based block device which acts as a swap disk, but is compressed and stored in memory instead of swap disk (which is slow), allowing very fast I/O and increasing the amount of memory available before the system starts swapping to disk. compcache was later re-written under the name zRam and is now integrated into the Linux kernel.

I decided to give it a try, and the result on my desktop with a quad-core CPU and 2Gb of RAM was fantastic: instead of freezing after running out of RAM, the system worked like nothing happened. I didn't notice any difference at all. It looked just like adding more RAM! Surprisingly, I got almost the same results on a 6-year-old laptop with Pentium M and 1Gb of RAM! So, I've improved the script to automatically adapt to the amount of memory in the system and automatically scale across several CPUs or CPU cores, packaged it in .deb and uploaded to PPA.

- Sergey Davidoff

Sergey also mentions that the only thing that prevents this from being enabled by default in elementary OS Luna for now is the existence of Atom netbooks with fast SSDs for which he doesn't know if this would be useful or not.

This is especially useful for netbooks, old computers (or computers that don't have too much RAM), virtualization or embedded devices but of course, you can use it on any computer.
To install Sergey's script in Ubuntu 11.04 or 11.10, use the following commands:
sudo add-apt-repository ppa:shnatsel/zram
sudo apt-get update
sudo apt-get install zramswap-enabler

THANKS: Webupd8