I need to read small sequences of data from a 3.7 GB file. The positions I need to read are not adjacent, but I can order the IO so that the file is read from beginning to end.
The file is stored on a iSCSI SAN which should be capable of handling/optimizing queued IO.
The question is, how can I make a one shot request of all the data/positions I need in one go? Is it possible? I don't think async IO is an option because the reads are very small (20-200 bytes)
Currently the code looks like this:
using (var fileStream = new FileStream(dataStorePath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
for (int i = 0; i < internalIds.Count();i++ )
{
fileStream.Position = seekPositions[i].SeekPosition;
... = Serializer.DeserializeWithLengthPrefix<...>(fileStream, PrefixStyle.Base128);
}
...
}
I'm looking for ways to improve this I/O because I'm getting somewhat sub-par read performance. All the seek times from moving the head seem to be adding up.