Faster Browsing With RAM Disks

esperancedv

A coworker approached us today wondering if they could get a performance boost using Samsung’s newly announced 256GB SSD. Most of their work is done in browser, so we said “no”. They’d only see benefit if they were reading/writing large files. Their system has plenty of RAM, and we decided to take a different approach. By creating a filesystem in RAM, you can read and write files much faster than on a typical hard drive. We decided to put the browser’s file cache into RAM.

We installed the Espérance DV preference pane in OSX to facilitate RAM disk creation. It’s really simple to setup. Just select how much space you want to dedicate to the disk and create it. You can have Espérance DV recreate the RAM disk on start and even have it automatically restore from a disk image. There is a check box for moving Safari’s Web Cache to the RAM disk, which creates the necessary symlink. You can also use it to speed up Xcode builds. Moving Firefox’s cache is fairly simple:

$ rm -r ~/Library/Caches/Firefox
$ ln -s /Volumes/RamDisk/Firefox ~/Library/Caches/Firefox

Since the browser isn’t having to hit the hard disk on every page load anymore, the performance is much snappier. Xbench says our random reads from RAM are now 86.19MB/sec instead of 0.61MB/sec when the cache was on the hard drive.

We immediately began looking for ways to get the entire OS into RAM; Tin Hat is a version of Linux that does that.

We’re very happy with the results of our RAM disk browser upgrade. Let us know in the comments if you’ve had a similar experience doing this in Windows.

70 thoughts on “Faster Browsing With RAM Disks

  1. now that is a handy thing to know.i wonder since your able to have the ram disk get created on boot is there a hack to move the whole os into ram?? did you guys ever get anywhere with that?? I think you would have to worry about data loss if the system crashed or hung up on you ,now if you could have the disk get accessed ever so often say every 5 minutes and dump the files and or changes to files to there respective places “doubtful” this might be a viable way to go I’m sure everything would feel snappier with no hard disk being needed to read and write files.

  2. for those looking to load _an_ entire OS into RAM, the best solution would be to check out a linux distribution. knoppix, for example, has a ‘toram’ parameter that can be used to dump the entire OS into RAM and run from it.

    as for mac os, however, you’d be looking into some uncharted territory since a lot of the mac os is closed source.

  3. Anyone have a suggestion for window user. Any review on different application from window size. I love OSX and work on it at work. At home though, i’m still very windows oriented.

  4. I thought that SSD’s were actually better for many, many small files.

    The advantage comes from the fact that there is practically no seek time compared to hard drives.

    However, once a hard drives finds a file, the actual reading of it is faster than an SSD.

  5. My search for free software for xp for creating ram disks that can be >2gb has failed miserably.

    for those wanting an entire os in ram, uh.. it might not be as hard as you think. it could involve some sort of hibernation sequence, an image of the drive is stored on a hdd or ssd, and then copied directly to ram on boot.

  6. well, i wouldn’t want to put an entire os in ram either, since 4gb of ram isn’t much to put an entire os onto, plus some headroom for apps.

    what i do want to do is cache more than just firefox. how about a holding area for files that need to be compressed or decompressed?

    decompressing a 7z from a flash drive onto the same drive takes forever, so how about extracting it to the ram disk, then transferring it back over.

    or, for my laptop, copy a bunch of songs over to the ramdisk, install a lightweight mp3 player on it, and then start playing the songs, this will allow the hard drive to sleep more while I’m listening to music.

    1. Ha! About that I remember how incredible fast Netscape Navigator (a browser!) was loaded in Windows ’98 with a new Pentium x computer. After a while I switched to newest Firefox. Is was (and is today) loading so slow that I asked myself “is is compiling the browser right now?”

  7. Jaysus, that’s all so lame. Firefox stores data in RAM if the disk cache is set to 0. Of course, you lose cache data once it’s over, but in the meantime it works waaaay much snappier.

    Putting the disk cache in RAM is just like trying to put the SWAP in RAM. Doesn’t it sound, erm, useless?

  8. wow.. seriously.. this is old school Amiga territory. the ram disk was usually implemented by default during os installation, and on all but the lamest cpu upgrade cards, kickstart and the os were loaded directly to a partitioned ram drive.

    sadly, the official implementation of the ramdisk did nothing for saving your work in a crash. but, im sure there were many shareware fixes for that.

    Its kind of sad that something like this needed to be ‘rediscovered.’ I have for a long time lameted the lack of a ram disk on my pc, as well as a truely good file manager. explorer has been s#^t from day one, and still is.

  9. I’m sorry, wtf is wrong with you people? Putting the disk cache in a ramdisk? That’s beyond fail.
    Go to about:config, set browser.cache.disk.enable to false. There. Firefox will use only RAM.
    Oh and welcome to 2008 and the wonders of modern memory management.

  10. Strange, I justed moved the Firefox Cache folder to a RAM disk, then i set browser.cache.disk.enable to false, browser.cache.disk.size to 0 and deleted the Profiles folder and the .DS_Store in the Cache folder.

    Then I started FF and it recreated those Files, claiming 2 MB of space

    One should assume it would not to this once browser.cache.disk.enable is set to false

  11. Well, if you disable disk.cache doesn’t it ditch caching altogether? Then wouldn’t it surf slower anyway? OK it won’t use harddisk for retrieving cached data, but it will wait for downloading them, am I wrong?

    I installed RAMDrive, set a 512MB drive, and pointed Firefox disk cache to a directory in it. Now I hardly restart my machine, it either goes to stand-by, or hibernation. In both cases, cached files are always in RAMDrive (~8MB now).

    Firefox has a snappier feel now.

    Plus, I created a pagefile in my RAMDrive, and disabled C: altogether. XP feels snappier, too.

    But maybe I am just making up that progress, who knows.

    I downloaded RAMDisk from here:
    http://www.mydigitallife.info/2007/05/27/free-ramdisk-for-windows-vista-xp-2000-and-2003-server/

    K.

  12. just to possibly fix the firefox problem that a few people i know were running into with those terminal commands, these are working:

    rm -r ~/library/caches/firefox
    mkdir /volumes/ramdisk/firefox\ \(\cache\)
    ln -s /volumes/ramdisk/firefox\ \(\cache\) ~/library/caches/firefox

    removes cache folder
    makes new cache folder in RamDisk
    creates symlink from HD to RamDisk

  13. My brother used to boot Windows from RAM. I think he was using Windows 98 or 2000. I dont think it is possible for XP. Yes, I realize this article is about MAC but some commments have come up about Windows

  14. Is nobody ever reading an article beyond the first two lines?

    The SSD was only the reason to try a RAM disk. An SSD is a harddrive that uses RAM instead of a spinning disk. A RAM disk on the other hand is a software that simulates a harddisk using the RAM of your PC.

    Even though they were both mentioned in a single article, they are something fundamentally different.

    But apart form that, any kind of disk cahe is used if the RAM cahce is not suffifcient. If redirecting disk cache back into RAM makes a program faster, then the program is configured badly.

  15. i have heard stories about this. apparently they used to do this more back in the old days when hard disks were really slow. and they were searching through “large” files (aka 50-100 kilo Byte)i have heard good things. one idea someone at my school is practicing is installing programs then copying the entire install files into ram before using.

  16. what’s with all of the flamers on here? geez. This may be old news to some people, but I see a lot of potential here.
    Sure, you can set the disk cache to 0 in FF, but now I can have one centralized place (the ramdisk) for ALL my apps, so I don’t have to go to each program and their own memory use.

  17. is there one for safari?

    i notice some pages take a long time to even resolve they just sit at contacting.

    i am thinking maybe safari or the underlying resources are making room in the cache to place the new files so if it could be done entirely in ram so the only time it ever gets written to disk is when ram gets full and spills over to the virtual memory.

  18. note to moderators there seems to be a problem with yahoo it is no longer receiving the anti bot confirmation email so sorry for the duplicate post.

    is there one for safari?

    i notice some pages take a long time to even resolve they just sit at contacting.

    i am thinking maybe safari or the underlying resources are making room in the cache to place the new files so if it could be done entirely in ram so the only time it ever gets written to disk is when ram gets full and spills over to the virtual memory.

  19. tin hat got stuck in an endless loop booting trying to load my sata drive or something. then i shut it off and tried again without my sata drive connected and it got farther and rebooted itself.
    hooray!

  20. I have a crazy idea…

    What if you have an PC emulator like Qemu running a distro of Linux that just runs a ram drive with the memory pre-allocated by the emulator? Then have like a samba server or something to interface with the virtual ramdisk that runs on application layer of the host machine. Like having a networked drive subst’ed in that redirects to the virtual machine running the ramdrive that allows the user to drag-drop files and/or execute them. Is this idea plausible or is there a fatal flaw(s) in this design?

  21. I remember running the entire OS on Mac OS 7 from a ram disk – simply create the ramdisk, copy The system folder accross (one drag and drop action), set the new ramdisk as the boot drive and reboot. Easy.

    Ahh – back when an operating system was easily managed from within a single directory.

  22. I’ve been doing this for years and years. My main reason for it was that I noticed that when I did a did repair, it was often the files in the browsercache that were broken. Also, it’s refreshing that a reboot would really get rid of browser poo. The only downside is that Camino (my preferred browser) loses it’s favicons in the fav’s bar. I can live with that.

  23. Useless trivia re: the Amiga – Despite its better known ram disk, there was also the fixed size Rad: ram disk device driver that would keep its contents after a reboot. Great way to diskcopy workbench or the first disk of a multidisk game.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.