Faster browsing with RAM disks

posted Nov 20th 2008 7:14pm by
filed under: downloads hacks, firefox hacks, lifehacks, macs hacks

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.



66 Responses to Faster browsing with RAM disks

  • 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).

  • 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.

  • 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

  • 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.

  • 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.

  • 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.

  • 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.

  • Peter Hosey says:

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

  • lol says:

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

  • 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…….

  • _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.

  • 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.

  • _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.

  • 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! :)

  • Alcoholic says:

    1. Firefox loads pages slowly?

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

  • 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…….

  • l says:

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

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

  • 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.

  • 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.

  • 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

  • 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.

  • 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!

  • albert@dfw says:

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

  • 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

  • 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

  • Rawrl says:

    lol macfags

    DOS had RAM drives in 1983.

  • 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.

  • 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).

  • Henry says:

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

  • 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.

  • jason says:

    Puppy Linux runs completely in RAM if it can.

    http://www.puppylinux.org/home

  • nitori says:

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

  • 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.

  • brent says:

    awesome hack, i’ll give it a shot

  • matt says:

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

  • barry99705 says:

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

  • 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.

  • 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.

  • 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!

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

  • 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.

  • 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.

  • 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.

  • 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.

  • 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…

  • cflawson says:

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

  • Obama says:

    I am barack obama and I approve this article

  • nikhil says:

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

  • Just4Kix says:

    Thanks g, your terminal script works! I was wondering why Firefox wouldn’t open after running those commands mentioned in the article.

  • chamunks says:

    WEEEEEE! RAM Harddrives http://www.tomshardware.com/reviews/hyperos-dram-hard-drive-block,1186.html

    I realize capslock is disabled but at least it looks annoying and attention grabbing in my head.

  • Caching desktop applications in RAM… Hmmm, it never occurred to me that my software wasn’t already caching properly.

    I do normally use this for hacks I do for little web apps (amateur things though they are) … If I have to set and get little bits of data I will often shove them somewhere in /dev/shm (normally don’t bother to consider Windows boxes)

    but, hmmm, now I’m thinking “I wonder if I can do that in Windows without paying a smallhuge fee!” … I used to have some freeware lying around which let me create a ramdisk. It was awesome but I only had 32MB of RAM and soon gave that b ack to my applications to use as …. as….. well, to use the RAM as RAM. Tada!

  • Just4Kix says:

    update on the Firefox not opening issue. If you make the RamDisk invisible, add a . in front of the ram disk name. Example:

    $ rm -r ~/library/caches/firefox

    $mkdir /volumes/.ramdisk/firefox\ \(\cache\)

    $ ln -s /volumes/.ramdisk/firefox\ \(\cache\) ~/library/caches/firefox

  • bobby says:

    hey bro i sell cvv, fullz, tracks and wutf

  • bobby says:

    you can reach me through this id: torazio_torino@yahoo.co.uk

  • poky says:

    http://tinyurl.com/ramdrive
    easy solution for windows : )
    been using it for certain programs, last 18 months, which requier high i/o speeds : )

  • My Head Asplode says:

    Ok, srsly.
    All the fags talking about “copying OS to a ramdrive” are out of your mind retarted!

    RAM drives are whipped clean every time you restart your computer.

    If you moved all your OS8 files to a ramdisk, you’d have no OS.

    You can’t ever EVER boot from a RAM disk. NEVER NEVER NEVER!

    In theory, you could load all the system files to RAM at startup, then boot the system from that, but think about that for about ten seconds and you’ll realize why that’s a stupid redundant idea…

  • shohug says:

    please help me to change the cache directory of safari to ramdisk in WINDOWS XP. i have a free software which can create upto 3GB ramdisk in XP. if u still need this then contact “Shohug_0301012@yahoo.com”

  • Q says:

    This made me think… here is an opportunity for OS innovation:
    OSes should have some native support to go all out for performance.
    For this topic, an OS would allow programs to create folders with a special type “cache folder” and a maximum size for it.
    This would allow the OS to create a RAMdrive with enough size for all those caches.
    Windows 7 is coming soon, it would be interesting to have such a thing…

  • Oren Beck says:

    Puppy can be set to eliminate Flash Writes during a session unless they are requested during a session or upon exit. If you have no need to “save locally?” That session in theory uses *zero* flash writes.

    IF you can live with the risk about work in progress losses? Mitigation’s possible. Look no further than Gmail for a conceptual answer. A Gmail session “autosaves” drafts at intervals.

    So,for netbooks with internal WLAN or any “connected” machines it’s potentially a done deal.By a use of remote caching/s. Oh, you “can” write back to the local flash on exit if you want to .. But Why would you do so for 99% of your session’s data when it’s only 1% likely needing local saves.

  • klancy says:

    Hold the boat man… all these people screaming “STUPID” and “LAME” aren’t even considering that any program you run… (pretty much ANY)… during the ENTIRE time that you’re running it, is going to run better if it’s on a ramdrive.

    Now what is an OS? It’s a program.

    Consider the Windows Vista can be sped up by providing a thumb drive for cache. That’s not a hack, but a FEATURE of the OS. Hmm, why and how?

    Well… stuff is faster in RAM. Period. Naysayers, your arguments are uneducated and ill informed.

  • thank you very much for sharings…i really enjoy all of these posts…

  • Macduzzit says:

    Cool Tip…totally made Firefox unuseable on my Mac! Tried re-installing Firefox but no joy. Guess I’ll just spend 200 days re-installing the entire SL install on my Mac. Excellent!

  • ThundrBunkn says:

    They climbin in yo RamDisk, they smashin yo Cache Files up…..

  • austin says:

    i did something like this a while ago on linux.
    first i turned my /tmp folder into a tmpfs partition, so its a ramdisk that changes size as needed up to 1/2 your total ram(by default, you can make it more or less)
    then i moved my firefox profile (~/mozilla/firefox/(random guid).default) to a permanent place, then copies it to the /tmp directory and deleted it, then symlinked from the /tmp to ~/mozilla/firefox/(its name) i also deleted cookies.sqlite and sessionstore.js and linked from their permanent location (so that changes to them would persist even if the computer suddenly took a nosedive.) then created a startup script to automate this process. this way everything firefox needs is in ram, it runs much nicer.
    i also moved my ~/.Thumbnails to /tmp and linked to back to ~ this made thumbnails load faster AND it deleted them when my computer shut down(along with any incriminating evidence.)

  • Leave a Reply

    XHTML: You can use these tags: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

    Hack a Day serves up fresh hacks each day, every day from around the web as well as hacking related news.

    Send us your hacks










         




    Hacks

    Resources