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.
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
If you don't want to add the PPA, you can manually download and install the .deb from HERE. The script should work with Linux kernel 2.6.37.1+.
If you're not using Ubuntu, you can download the script from HERE or get the source from BZR. This is an Upstart script so you need to place the "zramswap.conf" file under /etc/init and then start it using "sudo start zramswap". Please note that Fedora 15 has replaced upstart with systemd.
Update:
- For Fedora 15+ (which uses systemd instead of upstart), see: Enable Zram in Fedora
- For Arch Linux, see THIS comment (script converted to rc.d).
More about compressed caching for Linux:
- http://code.google.com/p/compcache
- http://weirdfellow.wordpress.com/2011/05/04/compressed-ram-with-zram/
Many thanks to Sergey for the tip and all the info!
No comments:
Post a Comment