F*******i 发帖数: 190 | 1 如果 我的程序需要同时 读和写很多数据,
请问可以用multi-thread 来 提高 IO 的 performance 吗?
比如现在有可能是写的太慢了, 导致会miss 掉一些读进来的数据,
如果 可以, 请问 c++ 有什么比较好的工具 或者 tutorial ?
谢谢 |
p*u 发帖数: 2454 | 2 I think you need read-write lock for this purpose. you also need to buffer d
ata in your writer thread.
You can check out Linux AIO, though it's not C++ but C.
【在 F*******i 的大作中提到】 : 如果 我的程序需要同时 读和写很多数据, : 请问可以用multi-thread 来 提高 IO 的 performance 吗? : 比如现在有可能是写的太慢了, 导致会miss 掉一些读进来的数据, : 如果 可以, 请问 c++ 有什么比较好的工具 或者 tutorial ? : 谢谢
|
F*******i 发帖数: 190 | 3 Yes, read-write lock and buffer are exactly what I am looking for.
Thanks for the AIO!
d
【在 p*u 的大作中提到】 : I think you need read-write lock for this purpose. you also need to buffer d : ata in your writer thread. : You can check out Linux AIO, though it's not C++ but C.
|
T*****9 发帖数: 2484 | 4 use lock or semaphore
可以用buffer,然后对这个buffer用2个semaphore,1个lock或者3个semaphore
你可以看看pthread,同时我觉得fifo的实现基本是1读1写(事实上是多读多写),你可
以看看他的实现
【在 F*******i 的大作中提到】 : 如果 我的程序需要同时 读和写很多数据, : 请问可以用multi-thread 来 提高 IO 的 performance 吗? : 比如现在有可能是写的太慢了, 导致会miss 掉一些读进来的数据, : 如果 可以, 请问 c++ 有什么比较好的工具 或者 tutorial ? : 谢谢
|
D*******a 发帖数: 3688 | 5 要做好buffering
【在 F*******i 的大作中提到】 : 如果 我的程序需要同时 读和写很多数据, : 请问可以用multi-thread 来 提高 IO 的 performance 吗? : 比如现在有可能是写的太慢了, 导致会miss 掉一些读进来的数据, : 如果 可以, 请问 c++ 有什么比较好的工具 或者 tutorial ? : 谢谢
|
F*******i 发帖数: 190 | 6 Thanks!
请问有好的c++的库推荐吗?
谢谢,
【在 D*******a 的大作中提到】 : 要做好buffering
|
D*******a 发帖数: 3688 | 7 thread,mutex,semaphore本来是OS的东西,所以不同操作系统下面用法不同
不过现在好像可以用boost::thread库
【在 F*******i 的大作中提到】 : Thanks! : 请问有好的c++的库推荐吗? : 谢谢,
|
F*******i 发帖数: 190 | 8 Thanks!
【在 D*******a 的大作中提到】 : thread,mutex,semaphore本来是OS的东西,所以不同操作系统下面用法不同 : 不过现在好像可以用boost::thread库
|
d******n 发帖数: 42 | |
d******n 发帖数: 42 | 10 try QT, it has multithread component |
|
|
a****l 发帖数: 8211 | 11 why do you think multi-threading will improve IO performance? If you hard-
drive can only write this fast, how can you make it write faster?
You need to refine your writing routines to make it faster.
【在 F*******i 的大作中提到】 : 如果 我的程序需要同时 读和写很多数据, : 请问可以用multi-thread 来 提高 IO 的 performance 吗? : 比如现在有可能是写的太慢了, 导致会miss 掉一些读进来的数据, : 如果 可以, 请问 c++ 有什么比较好的工具 或者 tutorial ? : 谢谢
|
F*******i 发帖数: 190 | 12 Thanks for your suggestion.
Here is the situation:
Process data --> Write data --> Read data again>
If I spend too many time on the Write data part, I might miss the new
incoming
data since it is live.
Any comments?
【在 a****l 的大作中提到】 : why do you think multi-threading will improve IO performance? If you hard- : drive can only write this fast, how can you make it write faster? : You need to refine your writing routines to make it faster.
|
a****l 发帖数: 8211 | 13 Ok, I thought you meant your io is not writing fast enough.
Yes, in this case, it is almost always you must use 2 threads.
【在 F*******i 的大作中提到】 : Thanks for your suggestion. : Here is the situation: : Process data --> Write data --> Read data again> : If I spend too many time on the Write data part, I might miss the new : incoming : data since it is live. : Any comments?
|
F*******i 发帖数: 190 | 14 Do you have any good c++ resources about this to recommend?
Thanks again!
【在 a****l 的大作中提到】 : Ok, I thought you meant your io is not writing fast enough. : Yes, in this case, it is almost always you must use 2 threads.
|
b***y 发帖数: 2799 | 15 READ的BUFFER是多大,READ那边进来速度是多大?如果你怕MISS,把READ BUFFER弄大
点不就行了?当然你也可以写一部分,就去CHECK一下READ,然后再接着写。
【在 F*******i 的大作中提到】 : 如果 我的程序需要同时 读和写很多数据, : 请问可以用multi-thread 来 提高 IO 的 performance 吗? : 比如现在有可能是写的太慢了, 导致会miss 掉一些读进来的数据, : 如果 可以, 请问 c++ 有什么比较好的工具 或者 tutorial ? : 谢谢
|
m*****e 发帖数: 4193 | 16 For single producer-consumer model no lock is needed.
Forget AIO, it's not what you need.
d
【在 p*u 的大作中提到】 : I think you need read-write lock for this purpose. you also need to buffer d : ata in your writer thread. : You can check out Linux AIO, though it's not C++ but C.
|
p*u 发帖数: 2454 | 17 then name something OP can use.
【在 m*****e 的大作中提到】 : For single producer-consumer model no lock is needed. : Forget AIO, it's not what you need. : : d
|
m*****e 发帖数: 4193 | 18 He is asking multi-threading.
AIO is completely opposite.
【在 p*u 的大作中提到】 : then name something OP can use.
|
p*u 发帖数: 2454 | 19 he asked how to improve performance of read-write.
【在 m*****e 的大作中提到】 : He is asking multi-threading. : AIO is completely opposite.
|
m*****e 发帖数: 4193 | 20 Have you even used AIO and know its current status? Don't just throw fancy
words at a problem.
【在 p*u 的大作中提到】 : he asked how to improve performance of read-write.
|
p*u 发帖数: 2454 | 21 只有土鳖才觉得05年就出来的LINUX AIO fancy。
【在 m*****e 的大作中提到】 : Have you even used AIO and know its current status? Don't just throw fancy : words at a problem.
|
c****r 发帖数: 15 | 22 如果是on Windows的话,use asynchronous file writing. 参考WriteFile Win32 API
. |