w*********s 发帖数: 277 | 1 用perl来读一堆文件
1.单线程顺序一个一个的读文件
2.用多线程读多个文件,每个线程读一个文件
光读,没做任何操作。
用time命令看运行时间
结果发现2比1慢好多,咋回事呢?
谢谢! |
b******n 发帖数: 592 | 2 1.platform is not hypertheaded and not multi-core
2.if you check usertime, the multi-thread will actually use more cpu time
3.not familiar with perl multi-thread..are they real threads..
4.disk i/o could limit your performance as well. imagine harddisk has to
move forward backward to fulfill the demands of all threads
5.depends on how you implement, too many conditions on threads will result
in inefficient code
【在 w*********s 的大作中提到】 : 用perl来读一堆文件 : 1.单线程顺序一个一个的读文件 : 2.用多线程读多个文件,每个线程读一个文件 : 光读,没做任何操作。 : 用time命令看运行时间 : 结果发现2比1慢好多,咋回事呢? : 谢谢!
|
k*******d 发帖数: 1340 | 3 我觉得4的可能性比较大,如果只是单个硬盘,跳来跳去寻道的时间多
time
result
【在 b******n 的大作中提到】 : 1.platform is not hypertheaded and not multi-core : 2.if you check usertime, the multi-thread will actually use more cpu time : 3.not familiar with perl multi-thread..are they real threads.. : 4.disk i/o could limit your performance as well. imagine harddisk has to : move forward backward to fulfill the demands of all threads : 5.depends on how you implement, too many conditions on threads will result : in inefficient code
|
f*******y 发帖数: 988 | 4 全是外部I/O搞啥多线程
【在 w*********s 的大作中提到】 : 用perl来读一堆文件 : 1.单线程顺序一个一个的读文件 : 2.用多线程读多个文件,每个线程读一个文件 : 光读,没做任何操作。 : 用time命令看运行时间 : 结果发现2比1慢好多,咋回事呢? : 谢谢!
|
t****u 发帖数: 8614 | 5 十有八九是程序没写对,虽然两个thread,但仍然是serialized read operation。
加上thread context switch,所以结果反而慢。
【在 w*********s 的大作中提到】 : 用perl来读一堆文件 : 1.单线程顺序一个一个的读文件 : 2.用多线程读多个文件,每个线程读一个文件 : 光读,没做任何操作。 : 用time命令看运行时间 : 结果发现2比1慢好多,咋回事呢? : 谢谢!
|
x**********g 发帖数: 357 | 6 顶
【在 b******n 的大作中提到】 : 1.platform is not hypertheaded and not multi-core : 2.if you check usertime, the multi-thread will actually use more cpu time : 3.not familiar with perl multi-thread..are they real threads.. : 4.disk i/o could limit your performance as well. imagine harddisk has to : move forward backward to fulfill the demands of all threads : 5.depends on how you implement, too many conditions on threads will result : in inefficient code
|