Improve disk read performance (multiple files) with threading

Posted by pablo on Stack Overflow See other posts from Stack Overflow or by pablo
Published on 2010-04-24T10:00:08Z Indexed on 2010/04/24 10:03 UTC
Read the original article Hit count: 170

Filed under:
|
|

I need to find a method to read a big number of small files (about 300k files) as fast as possible.

Reading them sequentially using FileStream and reading the entire file in a single call takes between 170 and 208 seconds (you know, you re-run, disk cache plays its role and time varies).

Then I tried using PInvoke with CreateFile/ReadFile and using FILE_FLAG_SEQUENTIAL_SCAN, but I didn't appreciate any changes.

I tried with several threads (divide the big set in chunks and have every thread reading its part) and this way I was able to improve speed just a little bit (not even a 5% with every new thread up to 4).

Any ideas on how to find the most effective way to do this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about Performance