8

I found a lot of good topics on Stack Overflow concerning this, but my question is a bit more specific. A lot of companies are using this software to host the same services we do...

http://memory.dataram.com/products-and-services/software/ramdisk

Apparently the Read/Write speed to a Virtual Disk is insanely faster, and as we run very intensive I/O software, I would like to write something to do the same thing. My only needs are that it runs the application on a Virtual Drive (for the increased I/O speeds) and copies the data over to the physical location on the Hard-Drive every X minutes.

Would this be pretty easy to accomplish? What should I look into using to accomplish this?

EDIT

It looks like I can use the following Dokan Library, but would "subst" command in Windows yield any I/O performance increases, or would this library be the best bet?

http://dokan-dev.net/en/about/

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • Just create a Queue to hold all of your data. The Queue will grow dynmically as new objects are added to it, and every so often you can fire off a "writeQueueToHardDrive" function which pulls items off the front of the Queue until it is empty. – Frosty840 Jul 29 '11 at 12:32
  • Do you have more info on this approach? Since RamDisk it seems is built around the Kernel, I am wondering if any approach from C# is going to yield the same results. –  Jul 29 '11 at 12:40
  • @Brett - sure it runs at the kernel level - but you would have to deal with I/O calls. a `Queue` is all memory based. – Daniel A. White Jul 29 '11 at 12:48
  • C# stores all of its data in RAM anyway... a RAMDisk is for storing *files* to RAM. It's useful for quickly moving saved files between programs without first saving them to the harddisk. You don't mention needing to do that. All you say you need to do is save data once. Saving data to harddisk will take the same amount of time no matter whether you write from program memory or RAMDisk. Therefore, seeing as your IO data is *already* in the RAM, just save it to the harddrive from your RAM. – Frosty840 Jul 29 '11 at 12:49
  • My C# application is actually just a Daemon application for a Java process, which is entirely based around RAM. Our customers rent instances of the process with anywhere from 192MB to 8GB of RAM allocated to it. I would just like to have my Daemon application handle the Virtual Disk operations (or Queue). The software also has hundreds of tiny files it uses, so having the improved I/O speeds will help immensely. –  Jul 29 '11 at 13:00
  • Just from reading over the description of Queue, I don't think it sounds like it will really work since my applications not the one that will be using the Virtual Drive. The Java process my C# application launches is what will be using it. –  Jul 29 '11 at 13:03
  • Again, I'm still not seeing the need for a RAM drive. If you need to load that data from the disk into memory, load it into memory and keep it there. That's all you'd be doing if you were using a RAM disk anyway. All a RAM drive does is disguise your RAM as harddrive space... – Frosty840 Jul 29 '11 at 13:06
  • This is a new ballpark to me, but that makes sense. So basically just load the entire contents of their applications directory to RAM then launch the Java process from there? –  Jul 29 '11 at 13:10
  • 1
    Or rather, still launch Java from the C:\ drive, but for the parameter specifying the -jar file to load, give it the one loaded into RAM? –  Jul 29 '11 at 13:12
  • Well, I can't say that you need to load an entire directory into memory, that's application dependent. But yes, if you want data from the harddrive, load it from the harddrive. If you want data putting on the harddrive, put it on the harddrive. If you need to access data, you're loading it into RAM already. As I said before, unless you're using it as a shortcut for loading the data between programs, I can't see much use in what you're doing for a RAM drive. – Frosty840 Jul 29 '11 at 13:14

2 Answers2

7

This really isn't a C#/.NET question, unless you want to write your own RAM disk driver. Drivers like the one at your link have been around for a long time, and they do have insane read/write speeds, at the cost of RAM availability to your application and the OS. That may not be a problem in your case, if the machine in question has lots of RAM.

The programming part of it is the periodic writing of RAM disk contents to disk. As a RAM disk usually shows up as just another drive, this is a simple matter of copying files from it to a physical disk. You could do that in C#, but it would work just as well in a number of scripting languages.

If this is a high end application, look into solid state SATA drives. They have read/write speeds considerably faster than hard drives, and the data is persistent across crashes, power failures, etc.

Norman Kraft
  • 183
  • 1
  • 7
  • That actually is correct. The sub-processes that my C# manages are allocated X amount of RAM they can use each. This is the exact information on why this software is being used with RamDisk http://www.minecraftwiki.net/wiki/Tutorials/Ramdisk_enabled_server –  Jul 29 '11 at 13:14
0

If you do need a RAM drive, then what you really need is a block device driver which will do the job in kernel mode. The problem with Dokan is that (a) this is a filesystem driver, and this requires lots of additional work for you, (b) it calls your user-mode code back, and this causes a slowdown, (c) it's free stuff which is not stable enough for production use.

blak3r
  • 16,066
  • 16
  • 78
  • 98
Eugene Mayevski 'Callback
  • 45,135
  • 8
  • 71
  • 121