I've been following this very helpfull answer in an attempt to detect wether or not a file is stored in an ssd device or a spinning hard drive, for the purpose of figuring out wether I should attempt to read multiple files in parallel. It works for the actuall drives installed on the machine, however if its an external drive, usb stick or network share, I get an INVALID_FUNCTION (error code 1) error. I'm sure theres an obvious reason for it but as I'm not familiar with this kind of windows development I'm currently slugging through the documentation trying to figure it out.
EDIT: To clariffy, the error code was returned by the DeviceIoControl function.
So my questions:
1 - Is there a way to get this information from external devices ?
2 - Is there even a point in trying to detect it in these cases, do usb and network connections suffer from similar limitations regarding parallel reads, in which case I should just default to a squential read approach ?
The broadly general answer to your first question is "No". Network storage protocols rarely include any information about the physical media or its interconnects. Think about the complexities associated with describing all of the metadata for a RAID array or Fibre Channel/InfiniBand SAN. The OS does not need to concern itself with any of the details that the RAID controller/SAN does. It just sees a single logical storage device, and that's good enough.
Your second question is more interesting. Thanks to the power of abstraction, most of the implementation details do not matter. I am not sure what limitations regarding parallel reads you are referring to. From an algorithmic perspective, the most you may care about is dynamic scaling by measuring throughput as you put more (or less) threads to work. [1]
More threads are usually better, but "it depends". Modern hardware queues are very deep (NVMe has up to 65K queues) and that benefits concurrency by substantially reducing the head-of-line blocking problem. ↩︎
Yes, that post was my starting point when I began looking into this. To clarify, what I was referring to with the "limitations regarding parallel reads" was in comparison with a HDDs limitations in that regard.
What I was getting at with my second question is if I should treat devices connected via usb or network the same as I would a HDD or if it would also be possible in some cases to do it in parallel.