• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

zram! It's what's for (your cpu's) dinner!

Recommended Posts

Unobscured Vision    2,630

Just when we thought the advanced features, tips-n-tricks and doing-more-with-less was a thing of the past, I go and stumble upon an interesting project called zram.

Made a default part of the Linux Kernel since version 3.14 (30-3-2014), this handy little feature, when enabled, will enable part of your physical memory (RAM) to act as compressed swap space before using the dedicated swap partition (normally created during system install) -- the idea being that if you run into a situation where you are running out of memory and beginning to swap, it'll go into the vastly quicker zram space(s) before thrashing your hard disk (hampering performance by a factor of 10,000) and keeping your system more-or-less at the usual speed (90%).

Yes, there's a slight performance overhead (10%) to decompress the data in the zram swap locations, but it'll allows my 8 gb of physical RAM to perform as if I had 11.3 gb installed with the default dettings. In my case it's an extra 1.65 gb x2 zram, and the system will call upon those two 1.65 gb zram mounts *before* it begins to swap to my dedicated 8 gb swap partition (created when I installed my distro of choice several months ago). You can make these mount points larger, as well as how aggressive the compression level is, but at the cost of more CPU overhead; but I'm finding the default settings are more than adequate.

You still have your full 8 gb of RAM available to you -- you're not actually giving anything up when these zram mount points aren't in use. No, they come into play at a time when the system determines that you actually need to begin "swapping pages", and the default setting for most Ubuntu-based distributions is 60% (and you can see this yourself by typing the command "cat /proc/sys/vm/swappiness" in a terminal. When we are at 60% of physical memory limits, we begin swapping pages. Of course, like most everything in Linux, that setting can be changed to suit the needs of the user and the machine. I'm still personally exploring the uses and application of zram, so changing the swappiness setting is not something I've done yet. Can the machine's entire RAM cache be compressed using this method? It would be really, really spiffy ... getting 12 gb effective use out of 8 gb of physically installed RAM has certainly gotten my attention and admiration. :yes:

And best of all, I am seeing no adverse effects thus far -- in fact, my system seems strangely happy and smooth-running. I'll put zram through its' paces with some memory-intensive Kerbal Space Program (plus mods that I know will max out the memory count) and I'll reply with my findings. :)

For those interested in finding out more, I'll direct you to the following:

https://en.wikipedia.org/wiki/Zram

https://www.kernel.org/doc/Documentation/blockdev/zram.txt

https://wiki.archlinux.org/index.php/Maximizing_performance#Root_on_RAM_overlay

http://askubuntu.com/questions/174579/how-do-i-use-zram

http://ubuntuforums.org/showthread.php?t=2253256

Enjoy!

Edited by BetaguyGZT
Typos!
  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.