Optimizing disk IO

后端 未结 1 1480
天涯浪人
天涯浪人 2021-02-06 08:26

I have a piece of code that analyzes streams of data from very large (10-100GB) binary files. It works well, so it\'s time to start optimizing, and currently disk IO is the bigg

相关标签:
1条回答
  • 2021-02-06 09:14

    First off, it would be useful to use a profiler to identify the hot spots in your program. Based on your description of the problem, you have a lot of overhead going on by the sheer number of freads. As the files are large there will be a big benefit to increasing the amount of data you read per io.

    Convince yourself of this by putting together 2 small programs that read the stream.

    1) read it as you are in the example above, of 2 doubles.
    
    2) read it the same way, but make it 10,000 doubles.
    

    Time both runs a few times, and odds are you will be observe #2 runs much faster.

    Best of luck.

    0 讨论(0)
提交回复
热议问题