Is there a performance difference for file I/O between the following two approaches?
- Use a queue that is filled by producers and start a task writing to disk after all data has arrived
- Have a task writing to disk in parallel to producers
The data is written to different files and multiple directories. A separate task for the I/O and Parallel.ForEach would be used in both cases.
I would assume that the second version would perform better, theoretically the producers and the I/O are really concurrent. Since I/O causes interrupts to the calling process I was wondering if there would be a down-side. This might cause overhead that outweighs the benefits of parallelism.
Are there situations were I should favor the first solution over the second?