Chunk Size

Files can be accessed on RAM disks (or any media, for that matter) in a variety of ways. "Chunk Size" refers to the size of data accessed from the RAM disk. The smallest possible chunk size is 512 bytes, or 1/2 K. The largest theoretical chunk size is the size of the whole RAM disk!

Sometimes the system chooses what the chunk size should be, and sometime the application software decides. For example, if the application software tries to read a file one character at a time, the system reads 512 bytes and remembers what's there when the application reads the next character.

On the other hand, an application can choose to read large chunks, and these large chunk sizes are essentially the chunk sizes seen by the RAM disk driver.

Typically, larger chunk sizes lead to higher throughput, since most of the time can be spent actually reading the file instead of figuring out where on the RAM disk the file is, and other overhead tasks.

RAM disk

RAM disks are a convenient way to achieve high performance in many applications. Hard drive accesses are hundreds of times slower than memory accesses. RAM disks set aside an amount of memory that the system can then use as a "normal" hard drive, floppy drive, or any other storage device -- except that they're much faster.

Typical advantages of RAM disks include:

  • The biggest advantage of RAM disks is speed. As mentioned above, memory accesses are much faster than hard drive, floppy disk, or network accesses.
  • RAM disks can provide safety as well. Many people use RAM disks as web browser cache volumes for this reason. If the disk somehow becomes corrupted, then the damage is localized to the RAM disk and doesn't affect the system hard drive.
  • Another advantage of RAM disks is small file overhead. In versions of the MacOS before 8.1, each file grows in increments of 1/65536 of the total hard drive size. In other words, even if a file is only a few characters long, on a one-gigabyte hard drive it will take up 16K! Since a RAM disk is typically a very small volume, the space lost to file allocation is minimized.
  • Security is a concern for many people. By using a RAM disk that is easily mounted and unmounted from the desktop, you can more easily isolate sensitive material. Note that using a RAM disk is no substitute for rigorous encryption; nevertheless, it can help prevent casual snoopers from digging through your material.

Typical disadvantages of RAM disks include:

  • Many RAM disk programs do not save the contents of the RAM disk to a file on a (real) disk. This means that crashes or power failures cause the contents of the RAM disk to be lost. Some RAM disks that do save the contents do so only when the RAM disk is put away. ramBunctious has a write-through feature available that saves the contents as soon as the RAM disk changes.
  • Most RAM disk programs only allow one RAM disk to be available at a time. If you have a RAM disk mounted, and realize that you have important information on another RAM disk, it can be frustrating to juggle RAM disks to access your information. ramBunctious allows you to mount as many RAM disks as you have memory for.
  • Many RAM disk programs require you to reboot before you can see the RAM disk. They also require you to reboot before you can reclaim the memory used by the RAM disk. ramBunctious uses the same memory that applications use, so it can create a RAM disk without rebooting, and you can reclaim memory used by the RAM disks instantly by putting them away.

Virtual Memory ("VM") refers to how the MacOS can use hard drive space to simulate extra memory. If the OS tries to access a memory address that's currently not really in RAM, it needs to load it from the hard drive, then continue accessing it as usual. Since hard drive accesses are much slower than RAM accesses (that's why a RAM disk is so interesting, after all) those occasional accesses when a "page fault" occurs are much slower than accesses where everything is already in physical RAM.

An interesting dilemma arises when you have virtual memory enabled while using a RAM disk.

Should the RAM disk honor VM and allow itself to be paged out to a hard drive? Or should it force its contents to stay resident in RAM?

If it forces itself to stay resident in RAM (ie, does not honor VM), that provides the fastest performance — for the RAM disk itself. But it ensures that other programs will be paged to disk more frequently. So overall system performance will likely suffer.

We had a tough decision when we faced this issue. 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 honors VM: because it's more clearly what the user wants.

Of course, ramBunctious's performance is maximized when virtual memory is turned off. The people who have typically found ramBunctious RAM disks to be the most useful have been people with lots of RAM available; this leads us to recommend that for best ramBunctious performance, virtual memory should be turned off.