简体   繁体   English

如何从硬盘以最大速度读取/写入我编码的多线程程序不能超过15 mb / sec

[英]How to read/write at Maximum Speed from Hard Disk.Multi Threaded program I coded cannot go above 15 mb/ sec

I have a 5 gb 256 Files in csv which I need to read at optimum speed and then write back data in Binary form . 我在csv中有一个5 gb 256个文件,需要以最佳速度读取,然后以二进制形式写回数据。

I made following arrangments to achieve it :- 我做了以下安排来实现它:-

For each file, there is one corresponding thread. 对于每个文件,都有一个相应的线程。 Am using C function fscanf,fwrite. 我正在使用C函数fscanf,fwrite。 But in Resource Monitor,it shows not more then 12 MB/ Sec of Hard Disk and 100 % Acitve Highest Time. 但是在资源监视器中,它显示的硬盘容量不超过12 MB /秒,最高显示时间为100%。 Google says HardDisk can read/write till 100 MB/Sec. 谷歌表示,硬盘可以读/写到100 MB /秒。 Machine Configuration is :- Intel i7 Core 3.4. 机器配置为:-Intel i7 Core 3.4。 Has 8 Cores. 有8个核心。

Please give me your prespective. 请给我您的职位。 My aim to complete this process within 1 Min . 我的目标是在1分钟内完成此过程。

** Using One Thread it took me 12 Mins** **使用一个线程花了我12分钟**

If all the files reside on the same disk, using multiple threads is likely to be counter-productive. 如果所有文件都位于同一磁盘上,则使用多个线程可能会适得其反。 If you read from many files in parallel, the HDD heads will keep moving back and forth between different areas of the disk, drastically reducing throughput. 如果您并行读取许多文件,则HDD磁头将在磁盘的不同区域之间来回移动,从而极大地降低了吞吐量。

I would measure how long it takes a built-in OS utility to read the files (on Unix, something like dd or cat into /dev/null ) and then use that as a baseline, bearing in mind that you also need to write stuff back . 我会测量内置的OS实用程序读取文件(在Unix上,将ddcat放入/dev/null ),然后将其用作基线需要多长时间,请记住,您还需要编写一些东西回去 Writing can be costly both in terms of throughput and seek times. 就吞吐量和寻道时间而言,写入可能会非常昂贵。

I would then come up with a single-threaded implementation that reads and writes data in large chunks, and see whether I can get it to perform similarly the OS tools. 然后,我将提出一个单线程实现,该实现可以大块读取和写入数据,并查看是否可以使它执行与OS工具类似的操作。

PS If you have 5GB of data and your HDD's top raw throughput is 100MB, and you also need to write the converted data back onto the same disk, you goal of 1 minute is not realistic. PS:如果您有5GB的数据,并且HDD的最大原始吞吐量为100MB,并且还需要将转换后的数据写回到同一张磁盘上,那么1分钟的目标是不现实的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM