Pages

Boost System Performance (RAM specifically) in Ubuntu using zRam!

I gotta admit that apart from all the criticism, MS Windows Kernel is pretty good at managing memory and system resources. Although the GNU/Linux Kernel is certainly one of the most robust & highly secured ones out there, but sometimes I do feel a bit "sluggish" performance while the Memory gets filled and when it's time to move the data between SWAP (virtual memory, a file, stored on or as a partition in GNU/Linux) to the RAM or vice versa when comparing with the Windows Kernel.

What the heck is "SWAP"?

If you're a bit new to all this hype :)... then SWAP is the temporary storage location that holds programs and other whatnots just before they're loaded into your actual/physical RAM for execution.

Anyhow, apparently there are few solutions for enhancing the performance and one in particular called zRam (successor of a project known as "Compcache", link below) that's integrated into the GNU/Linux Kernel. But the integration is "unofficial" meaning that, it's not included in the Kernel by default (unless the developers manually put it there).
Image via: Compcache (the original project)...
Concerning the Ubuntu users, Ubuntu also does not come it integrated by default but thanks to one of the core developers of the Elementary OS, Sergey Davidoff, not only he has made a PPA which makes the installation a breeze but also has made optimisations of is own which enhances the performance a bit more too!.

In his own words...
"... 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... got almost the same results on a 6-year-old laptop with Pentium M and 1Gb of RAM!...

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..."
You can install the zRam memory performance optimizer in Ubuntu 11.10 Oneiric Ocelot and 11.04 Natty Narwhal by using the below commands.
sudo add-apt-repository ppa:shnatsel/zram

sudo apt-get update

sudo apt-get install zramswap-enabler
Now I used it for very short period thus cannot say much about its performance (it's still in my system, I'm gonna keep it this time :D), so I let you decide that. But after considering Sergey and few others who've used it... it seems worth installing!.

But I'm just wondering whether this could have a somewhat negative effect on computers with lower-end processors (such as Netbooks for instance) since the idea here is to compress some of the data on the RAM and store it within the RAM itself which requires some decent amount of your CPU cycles.

So I'm just wondering it could result in a somewhat, shortened battery life, perhaps. But then again while reading the original "Compache" developers' page, he says...
"Market is now getting flooded with these "lightweight laptops". These are memory constrained but have CPU enough to drive on compressed memory"
So then perhaps after all, it may not has a huge effect on your CPU, unless it's really slow :D. But later if you wanted to remove it... then just open the terminal window and enter the below command to completely un-install it.
sudo apt-get remove zramswap-enabler
Enjoy!.

5 comments:

  1. Nice article!

    In Ubuntu 12.04 the PPA is not even needed. Instead, just install "zram-config" which provides the similar functionality:

    apt-get install zram-config

    - michael

    ReplyDelete
  2. For information, I wanted to uninstall zramswap-enabler (zram-config) COMPLETELY (including the zram swap partitions it created), and "sudo apt-get remove zramswap-enabler" ("sudo apt-get remove zram-config") did NOT suffice! The script /etc/init/zramswap.conf (/etc/init/zram-config.conf) remained and loaded again on the next boot (and made a swapon /dev/zram0 .. /dev/zramN again). (I ran "swapon -s" and there were still the lines starting with /dev/zram...)
    What I needed is to *PURGE*:

    $ sudo apt-get purge zramswap-enabler

    (
    $ sudo apt-get purge zram-config
    )

    NB: In my case, I had already run the "remove" command (then rebooted), and even after running "purge" on top of that, "swapon -s" was still giving the same results. I had to re-install, then purge.

    ReplyDelete
  3. @Anonymous,

    Thanks for sharing your experience mate, appreciate it :).

    ReplyDelete
  4. just use dpkg --purge instead.

    sudo dpkg --purge zramswap-enabler
    sudo dpkg --purge zram-config

    and no need to reinstall

    ReplyDelete