Hire me if you like: blake.irvin@gmail.com

Friday, February 22, 2008

Limiting RAM Used by ZFS (Limiting the ARC)

The principle is fairly simple. We add a tunable to /etc/system that looks like this:

set zfs:zfs_arc_max = 0x[hex value for the RAM usage limit we specify]

So, to limit ARC usage to 512mb, we multiply by 1024 to get 524288kb, then multiply this by 1024 to get 536870912 bytes. Converting this number to hex with a scientific calculator or hex converter (doing it on paper is tedious) gives us 20000000. We prepend '0x' to the number to make sure that ZFS/Solaris knows that we are talking about hex, not binary, decimal, or octal numbers. Our final value looks like this:

set zfs:zfs_arc_max = 0x20000000

You might ask why we need to do this. The answer is that in some situations, when you know that a program will use a large amount of RAM, and will want it very quickly, waiting for the ARC to self-shrink can hinder performance. Desktop installs of Solaris are good examples - running a fat GUI app together with AGP graphics can rapidly suck up RAM that ARC seems reluctant to let go of. ZFS performance will suffer a little if we limit ARC, but the tradeoff is appropriate in this case.

(Thanks to http://www.solarisinternals.com/wiki/index.php/ZFS_Evil_Tuning_Guide#ARCSIZE for the technicals on this - they just didn't cover the hex conversion bits)

No comments: