Saturday, May 16, 2009

Make SecondLife Use a Ramdisk Cache

Here's some simple instructions and information on how to make SecondLife store it's cached files on a RAM Disk.

1) What's a RAM Disk?
A RAM Disk is a segment of RAM that is used in a fashion similar to a hard drive. Files and directories can be created in it, and it functions in all respects like the normal file system of a computer, and can be accessed by your applications.

2) Advantages
RAM has historically been much faster than hard drives. For example, DDR2-800 RAM has a maximum data transfer rate of 6.4 gigabytes/s, while a Sata3 hard drive has a maximum data transfer rate of 3 gigabytes/s. However, this is the maximum speed of the Sata3 interface. In reality, the data transfer rate of the hard drive itself is somewhat slower. As well, the faster speed of RAM allows for faster indexing operations and loading, making Second Life run more efficiently in this respect. Also, if you are worried about stressing your hard drive, using a RAM Disk cache helps a lot.

3) Disadvantage
RAM is volatile memory, meaning all of the data stored is lost when the computer is shut down. As a result, shutting down or rebooting your computer causes Second Life's cache to be lost, and it is recreated the next time Second Life is run. If you are using Linux, this is not as much of a problem as rebooting and shutting down frequently is not usually necesary. Also, If you have an ISP such as Comcast or AT&T (especially AT&T) that caps your monthly bandwidth, I would not advise using this method if you shutdown frequently, as it increases your risk of going over your bandwidth limit.

--------------------------------------------------------------------

Instructions (Linux)

First, you fire up your favorite text editor as root, and open the /etc/fstab file. Add the following line to the file, replacing all instances of /path/to/ramdisk below with the desired mounting point for the RAM Disk:

none /path/to/ramdisk tmpfs defaults,size=1G 0 0

After you've added the entry to /etc/fstab, you (while still in root) create the directory that the RAM Disk will be mounted to by running the command "mkdir /path/to/ramdisk". After that, check to see if the ramdisk's directory is set with the proper permissions (allow any user or any group to view and modify contents). If it doesn't have the correct permissions, set them or set yourself as the directory's owner. Note that if the directory has the improper permissions, you'll have to set them each time you reboot. Once the above done, you mount the directory with "mount /path/to/ramdisk".

After this, you fire up Second Life and open the Network tab in the Preferences menu. Click the button that says "Set" and set it to /path/to/ramdisk. After that, apply the changes, and close the preferences menu. You'll need to restart Second Life in order to take advantage of the RAM Disk. When Second Life next starts up, it'll clear the old cache and begin using the RAM Disk.

--------------------------------------------------------------------

Instructions (Mac OS)

To do this under Mac, you open up a terminal, and run these commands (excluding the "$" and the space following it). The instructions assume the cache size is 500mb. Replace the 524,288,000 with 1,048,576,000 for a 1000mb cache. Be warned, however, that larger caches produce lag.

Also, the hdid command may produce a disk with a different name, such as /dev/disk4. If that happens, you replace all instances of /dev/disk1 below with whatever name it gives the disk.

$ hdid -nomount ram://524288000
$ newfs_hfs /dev/disk1
$ mkdir /tmp/ramdisk1
$ mount -t hfs /dev/disk1 /tmp/ramdisk1

After you've mounted the RAM Disk, follow the steps of the last paragraph for the Linux instructions.

--------------------------------------------------------------------

Instructions (Windows)
I don't have a windows machine to test this on, though the instructions are easy to find through Google, though you'll need to install drivers in order to create the RAM Disk. Once the RAM Disk is created, you follow the steps in the last paragraph of the instructions for Linux.

This page seems to be a good resource for learning how to create a RAM Disk:
http://www.mydigitallife.info/2007/05/27/free-ramdisk-for-windows-vista-xp-2000-and-2003-server/
--------------------------------------------------------------------

Citations:
http://wiki.archlinux.org/index.php/Ramdisk
http://osxdaily.com/2007/03/23/create-a-ram-disk-in-mac-os-x/

1 comment:

  1. And yes people, this does work with Hippo/OpenSim as well ;-)

    ReplyDelete