0

I want to randomly access the elements of a large array (>7GB) that I load into Python as a either an HDF5 dataset (h5py.Dataset), or a memory-mapped array (numpy.memmap).

If this file lives on an spinning-platter HD, these random accesses take forever, for obvious reasons.

Is there a way to check (assert) that the file in question lives on an SSD, before attempting these random accesses?

I am running python in Linux (Ubuntu 14.04). I don't mind non-cross-platform solutions.

SuperElectric
  • 17,548
  • 10
  • 52
  • 69
  • 3
    The OS itself doesn't even know, the interface is identical for both. The only thing I can think of is to do some kind of timing test, but that's likely to be more trouble than it's worth. – Mark Ransom Jun 04 '15 at 15:18
  • 2
    Very easy with newer kernels, see: http://unix.stackexchange.com/q/65595 –  Jun 04 '15 at 15:22
  • 2
    `cat /sys/block/sda/queue/rotational` will tell you if your hard drive is a ssd or hard disk. (1 is a hard disk and 0 is a ssd) – NendoTaka Jun 04 '15 at 15:23
  • These has to be some way to tell. My defrag software gives me a warning if I try to defrag a SSD. – Carcigenicate Jun 04 '15 at 15:24
  • @NendoTaka cool! Now is there a way for me to tell which hard drive a file lives on (in terms of 'sda', 'sdb', etc) from its absolute file path? – SuperElectric Jun 04 '15 at 17:04
  • @moarningsun very interesting. It must use some kind of meta-data from the drive. I don't think Windows has anything similar. – Mark Ransom Jun 04 '15 at 18:44

1 Answers1

1

cat /sys/block/sda/queue/rotational is a good way of finding out if your hard drive is a SSD or a hard disk. You can also slightly change this command in order to get other useful information like cat /sys/block/sdb/queue/rotational.

NendoTaka
  • 1,224
  • 8
  • 14