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.

Comments

  1. derek says:

    This seems like it’s most useful for the initial startup and load of pages for the first time (that you’ve already cached).

  2. greg says:

    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.

  3. Ian McKellar says:

    why not just increase the size of your firefox in-memory cache?

    see: http://www.extremetech.com/article2/0,1697,1854520,00.asp

  4. tyler says:

    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.

  5. Thach says:

    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.

  6. Paul says:

    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.

  7. Edward Nardella says:

    could always use a hardware ram drive.

    I would like to be able to create a ram disc in windows using free software.

  8. Peter Hosey says:

    Another free RAM disk program for Mac OS X is my own Make RAM Disk.

  9. lol says:

    wow, mac users are amazed at the smallest things. really.

  10. staticfloat says:

    I also would be interested in doing this for windows. Running browsers off of USB sticks can be very slow, but if they were loaded into ram…….

  11. _matt says:

    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.

  12. Thach says:

    _matt, i thought ram drive only need to be small, say 256mb or less. Usually you would store only cached file or page fault stuff. I’m not looking to store the entire OS in ram.

  13. _matt says:

    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.

  14. hpux735 says:

    This “hack” has been extensively discussed on the linux kernel mailing list and kernel trap.

    Just please, no one suggest putting a swap file in the ramdisk! :)

  15. Alcoholic says:

    1. Firefox loads pages slowly?

    2. 1988 called, they want their DOS game speedups back.

    • Chris says:

      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?”

  16. cde says:

    Most of the Mac user community moved away from the need for Ram Disks around the time MacOs 8.1 came out, even more so when we moved to OSX…….

  17. l says:

    And imagine your lappy saving battery by spinnig the HDD once a few minutes

  18. maathieu says:

    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?

  19. MRE says:

    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.

  20. NM says:

    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.

  21. robb says:

    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

  22. Koray says:

    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.

  23. r+9 says:

    Pffft I run my OS in RAM all the time. You can make any old PC into a monster that way.

    Really leets run it all in cache!

  24. albert@dfw says:

    article mentions no pricing yet, so who’s the supplier source for the ssd and what’s the price?

  25. g says:

    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

  26. Austin says:

    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

  27. Rawrl says:

    lol macfags

    DOS had RAM drives in 1983.

  28. Matt says:

    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.

  29. Dick Davies says:

    It’s an improvement on a RAM cache if the RAMdisk is persisted on login/logout (which it is, if you tick the box).

  30. Henry says:

    Wouldn’t setting the browser cache size to 0mb (to not cache to the drive) automatically save the cache to ram?

  31. camerin says:

    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.

  32. jason says:

    Puppy Linux runs completely in RAM if it can.

    http://www.puppylinux.org/home

  33. nitori says:

    Old trick I used ram disks on my Amiga to speed things up.

  34. sean says:

    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.

  35. brent says:

    awesome hack, i’ll give it a shot

  36. matt says:

    ~/library/caches/firefox doesn’t exist on my system?

  37. barry99705 says:

    They’re capitalized in the system, just not here, cause caps aren’t cool.

  38. ejonesss says:

    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.

  39. ejonesss says:

    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.

  40. will d. says:

    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!

  41. blackkaiser says:

    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?

  42. smilr says:

    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.

  43. Vishal says:

    Awesome and mindblowing.
    89.16 mbps vs 0.61 mbps. Thats something to think about.

    Did you try that from Linux live CD.

  44. Dave says:

    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.

  45. dzeims says:

    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.

  46. Phil S. says:

    I used to do this on my PCjr. I had 2megs of ram and used 720k of it to run a ram drive. Suddenly 4.77Mhz didn’t seem so slow…

  47. cflawson says:

    Did you ever fart so hard you ended up in another zip code?

  48. Obama says:

    I am barack obama and I approve this article

  49. nikhil says:

    what other advantages could creating a ramdisk have besides browsing advantages?

  50. Jimmy says:

    That is really cool.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 93,691 other followers