What is the fastest io when you have the off_t offset and numbytes to read? (ignoring mmap - for reasons of complexity). I want to write a function that takes an off_t offset and numbytes (its really the numchars) and be able to read that section into memory. Since I will be doing this process over and over, I need to know what the fastest is. Right now it seems that fgets with 256 char buffer is very fast, but it takes some work and would be easier to read it all into memory. I could just use fread and be done with it, but in tests it seemed like fgets was substantially faster (which really really matters in this program I am writing - over the process I might be dealing with file sizes up to several gigabytes in size, so this function might be called millions of times).
Also there exists the problem of reading everything into a char buffer and not knowing when end of file has been reached (if it has infact have)... (feof only tells you that the end of buffer has been reached in the case that the last read would fail....but if this last read succeds to read into memory most of the buffer...).
The amount of data per function call would range between 3000 and 11000 characters, so at a given time I would have to deal with reading 3000 to 11000 characters into memory.
I suggested to ignore mmap for now because of the complexity, but if mmap really is the fastest and if there is a simple way that can be showed to me how to get all the information into memory, given only the off_t offset, I will accept the answer.
Because this question is sort've multitiered and I need an answer to this quickly, I will put on the full 500 points. Thank you all for any help you can give!