English 中文(简体)
文件 IO - 多种阅读性能——书写不同档案
原标题:Linux File IO - Multithreading performance - writing to different files

I m currently working on an audio recording application, that fetches up to 8 audio streams from the network and saves the data to the disk (simplified ;) ). Right now, each stream gets handled by one thread -> the same thread also does the saving work on the disk.

这意味着,我有8条不同的线索,在同一个磁盘上进行书写,每个路面都不同。

您是否认为,如果所有写作工作都由一对一(有时将数据写进特定档案)进行,那么磁盘一/o性能就会增加?

OS是一种嵌入式的六氯环己烷,“disk”是CF卡,申请在C中书写。

Thanks for your ideas Nick

最佳回答

简短的答复: 鉴于你是写给闪电磁盘的,我 expect不希望能够以某种方式作出重大改变。 但是,如果它确实发挥作用,我会期望多条路透镜比单线透镜快,而不是慢慢。

答案越长:

我与你在大约6年前描述的方案写了类似的方案——它挂着一个嵌入的电离层的电离层中光层光纤卡,读/播下了多份同时的音频文件,以便/从一个SCSI硬盘上。 我最初是用一只读书撰写的,因为我认为这可以提供最好的投入,但我却认为情况并非如此。

In particular, when multiple threads were reading/writing at once, the SCSI layer was aware of all the pending requests from all the different threads, and was able to reorder the I/O requests such that seeking of the drive head was minimized. In the single-thread-IO scenario, on the other hand, the SCSI layer knew only about the single "next" outstanding I/O request and thus could not do that optimization. That meant extra travel for the drive head in many cases, and therefore lower throughput.

当然,你的申请不是利用SCSI,也不是与需要找工作的负责人轮流进行,因此,这或许不是你们的问题——但是,如果档案系统/硬件层了解多次同时提出的I/O申请,可能会有其他优化。 找到的唯一真正办法是尝试各种模式,衡量结果。

我的建议是把你的磁盘I/O从您的网络I/O中脱钩,把磁盘I/O转成一个校对池。 那么,你可以将I/O-thread-joint的最大规模从1个到N不等,每个大小衡量系统的业绩。 这将给你一个明确的想法,即你的具体硬件最好能做些什么,而不必再一次重写该守则。

问题回答

如果是嵌入<>/em> linux,我猜测你的机器只有一个处理器/记分。 在这一案例中,read子赢得了改善I/O的绩效。 当然,气球子系统在并行环境中运行良好,但就你而言(如果我对核心数的猜测正确),在几个路面同时做一些事情的情况下,就会出现这种情况。

如果我的猜测是错误的,而且你有1个以上核心,那么我建议对磁盘I/O进行基准。 起草一个方案,用不同校对的许多数据进行书写,另一个方案只读一读。 这些结果将显示你想要知道的一切。

I think that there is no big difference between multithreaded and singlethreaded solution in your case, but in case of multithreading you can syncronize between receiving threads and no one thread can affect on other threads in case of blocking in some system call.
I did particulary the same thing on embedded system, the problem was the high cpu usage when kernel drop many cached dirty pages to the CF, pdflush kernel process take all cpu time in that moment and if you receive stream via udp so it can be skipped because of cpu was busy when udp stream came, so I solved that problem by fdatasync() call every time when some not big amount of data received.





相关问题
Silverlight, Updating the UI during processing

I have a simple silverlight multifile upload application, and i want to provide the user with some feedback, right now its only in a test phase and i dont have the webservice. Somehow i cant get the ...

Is reading from an XmlDocument object thread safe?

I was wondering if i could safely read from an XmlDocument object using SelectNodes() and SelectSingleNode() from multiple threads with no problems. MSDN says that they are not guaranteed to be ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...