USGS-OWI / condor-examples

Examples of using HTCondor to scale scientific processing to a computer cluster
5 stars 8 forks source link

[2015-09-14] Creating temporary ramdisks to accelerate IO bound jobs #4

Open lawinslow opened 9 years ago

lawinslow commented 9 years ago

If you have a job that takes relatively little ram and can benefit from faster hard drive IO, it may be helpful to create a ramdisk mount where temporary files can be stored. It has to be managed well as the temporary space will invariably not be super large, but it can be helpful in certain circumstances.

Using parallel-ssh as discussed in the previous post #3, we can very simply set this up

parallel-ssh -h hosts.txt -l root -i -A -t 120 mkdir /mnt/ramdisk
parallel-ssh -h hosts.txt -l root -i -A -t 120 mount -t tmpfs -o size=16g tmpfs /mnt/ramdisk

I have a bit of extra RAM, so I set them to be 16 gigs. This is a per-machine temp directory, so you need to make sure your different jobs won't trample each other.

Then in my R code, I do something like this to be robust to the existence of a ramdisk.

  fastdir = tempdir()
  if(file.exists('/mnt/ramdisk')){
    fastdir = paste0('/mnt/ramdisk/', sample(1:1e6, 1))
    dir.create(fastdir)
  }

Then, somewhere towards the end of the sim (maybe in a try-catch finally area) I put an unlink(run_dir, recursive=TRUE) to get rid of temporary files before going to the next job.

lawinslow commented 8 years ago

To remove

parallel-ssh -h hosts.txt -l root -i -A -t 120 umount /mnt/ramdisk
parallel-ssh -h hosts.txt -l root -i -A -t 120 rm -r /mnt/ramdisk