RAM disks on OS X


Is Your Computer Really Smarter Than You?

We've seen some discussion, some debate, some information, and some confusion and misinformation about using RAM disks on OS X.

Taking a brief step back and looking at RAM disks in general, anyone using a RAM disk is implying that they know better than their OS how to allocate or prioritize resources -- memory, in the case of RAM disks. This is a delicate balancing act no matter what OS is being used, and as different OSes are being compared, the balancing point can change.

OS 9 RAM Disk Characteristics

In Mac OS 9.x and below, it's usually pretty easy to figure out whether using a RAM disk is worth it. If there are commonly-accessed files, and if there is lots of memory, then it's fair to assume that a RAM disk will be worthwhile. Tools like Peek-a-Boo can help figure out how much memory is in use, and if there's enough "elbow room" to hold a RAM disk.

Even in OS 9, the picture gets a little more complicated when virtual memory is added to the equation. When virtual memory is used, the OS starts making decisions about what should most effectively be stored in RAM and what can be stored on the hard drive.

When we were designing ramBunctious 1.x, we faced an interesting dilemma when we considered virtual memory banging heads with ramBunctious RAM disks. On the one hand, we could force the RAM disk to ignore virtual memory and stay in memory all the time. On the other hand, we could allow virtual memory preferences to apply to ramBunctious RAM disks equally with everything else.

If we forced the RAM disk to be resident in memory all the time, that would give RAM disk accesses the highest performance possible, which naturally appealed to us. But tying up all that memory in a RAM disk would likely slow down other processes wholly unrelated to the RAM disk. In the end, the answer we came to was this: if the user has turned on virtual memory, then clearly the user accepts the performance-for-memory penalty inherent in using virtual memory. That's why ramBunctious on OS 9.x and below honors VM: because it's more clearly what the user wants.

When we begin to consider OS X and the tradeoffs between the (always-on) virtual memory and typical RAM disk usage, it's helpful to remember that the same tradeoffs existed in OS 9.x and below as well. RAM disk usage is always a calculated balancing act between available memory and achievable performance.

OS X File I/O Characteristics

Parts of OS 9's i/o architecture were positively archaic. For example, every single file access routine has portions written in 68K code, which means that even the most modern Mac machines were forced to perform an expensive switch into 68K emulation mode.

Happily, OS X's i/o architecture eliminates the cruft that had collected over a decade of pre-OS X Mac systems. All file i/o on OS X, whether it's to a RAM disk or to a normal hard drive, is enhanced by OS X's modern architecture.

One implication of OS 9's creaky old architecture is that OS X's architecture is improved across the board. In some cases, the performance improvement that a RAM disk offers over a hard drive will be less in OS X than it was in OS 9. Another way of saying the same thing is that a RAM disk was more effective at masking OS 9's flaws, while OS X's cleaner architecture improves ALL i/o whether it's a RAM disk or a hard drive.

Will You See Enhanced Performance On An OS X RAM Disk?

Earlier I mentioned that using a RAM disk is intrinsically claiming to know more than the system. It's fair to say that OS X generally utilizes caching and virtual memory techniques in a more sophisticated way than OS 9.x and below, but it's also fair to say that people will often have a clearer view of their objectives and their environment than the system, so it will always be good to offer people the opportunity to customize the allocation of resources like memory.

For some computer systems, a RAM disk may make very little sense, as OS X's built-in virtual memory and i/o caching may duplicate some of the features provided by using a RAM disk. If your machine is constrained in memory, you may want to rethink whether a RAM disk is right for you. (Or get more memory! Seriously, cramming all the memory you can into your machine is by far the most cost-effective way to substantially upgrade your machine's performance.)

It's easy to see how constrained your memory situation is. You can use Peek-a-Boo and observe the system memory graph in its header. The striped area, "inactive memory", and the gray area, "free memory", both indicate memory available for a RAM disk to use without negatively affecting other processes. The jelly bean shows recent pageouts; if it's green and not yellow or red, that means your system isn't being thrashed by pageouts. Using this information will help you know whether you're constrained by memory and whether using a RAM disk may be an effective way of boosting your performance.

Basically the theme I'm trying to get across here is that if you have lots of "elbow room" in memory, then using a RAM disk will not conflict with OS X trying to allocate its resources; it makes it pretty easy to figure out whether using a RAM disk is worthwhile. If memory is a little tighter, with low free phys. mem and occasional pageouts, then the decision-making can be harder. You can still concoct scenarios where using a RAM disk makes sense, but you and the OS are fighting about it. This "middle ground" is where OS X is generally better than OS 9 in knowing how to allocate its resources. People will have to find out for themselves where in this middle ground they are smarter than the OS.

Other OS X RAM Disk Considerations

From what we've seen, and from what we've heard from beta testers, ramBunctious RAM disks offer substantial performance gains over hard drive access. But it would be myopic of us to recommend using RAM disks only for performance reasons. There are several other reasons that people use ramBunctious, on OS X as well as earlier OS versions.

RAM disks require less power. For laptop users in particular, using RAM disks in your workflow patterns can dramatically increase battery life.

For users of both laptop and desktop systems who set up hard drive spin-down times, judicious use of a RAM disk will allow the hard drive to spin down sooner and spin up less frequently. This means less hard drive abuse and less noise. This use of RAM disks to avoid small, frequent, annoying hard drive accesses is a big reason why SETI@home users like to use ramBunctious.

Where We Go From Here

We've been pleased by the performance improvements achieved by using ramBunctious on OS X. That doesn't mean we'll be sitting on our laurels. There's room to improve. We had twelve releases of ramBunctious on OS 9.x and below, from minor cosmetic upgrades to significant performance enhancements. We're on our first OS X release. We're monitoring interest in our OS X RAM disk product, and as long as there's a place for us in the OS X marketplace, we anticipate continuing to improve ramBunctious in its new environment.