进程与线程对性能的影响 [英] Performance impact of Processes vs Threads

查看:173
本文介绍了进程与线程对性能的影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很明显,如果性能至关重要,那么原型和配置文件就很有意义.但同样,可以在StackOverflow上寻求智慧和建议:)

Clearly if performance is critical it makes sense to prototype and profile. But all the same, wisdom and advice can be sought on StackOverflow :)

对于处理任务间通信不频繁或不适合消息传递的高度并行任务,使用进程(fork()等)或线程是否存在性能劣势?

For the handling of highly parallel tasks where inter-task communication is infrequent or suits message-passing, is there a performance disadvantage to using processes (fork() etc) or threads?

线程之间的上下文切换是否比进程之间的上下文切换便宜?有些处理器具有单指令上下文切换,不是吗?主流操作系统是否可以更好地利用具有多个线程或进程的SMP?如果该进程从不写入这些页面,那么fork()的COW开销是否比线程还要昂贵?

Is the context switch between threads cheaper than that between processes? Some processors have single-instruction context-switching don't they? Do the mainstream operating systems better utilise SMP with multiple threads or processes? Is the COW overhead of fork() more expensive than threads if the process never writes to those pages?

以此类推.谢谢!

推荐答案

关于进程创建缓慢的想法是一个古老的想法,过去更是如此. Google的Chrome团队在某个地方做了一点段落,说明它的影响已不再那么大了,这是Scott Hanselman的主题: http://www.hanselman.com/blog/MicrosoftIE8AndGoogleChromeProcessesAreTheNewThreads.aspx

The idea that processes are slow to create is an old one, and was much more true in the past. Google's Chrome team did a little paragraph somewhere about how it's not as big an impact anymore, and here is Scott Hanselman on the subject: http://www.hanselman.com/blog/MicrosoftIE8AndGoogleChromeProcessesAreTheNewThreads.aspx

我认为线程速度更快?'c,但这只是适度的,因此,现在更容易出错.

My take on it is that threads are faster?'c but only moderately so, and currently it's easier to make mistakes with threads.

我听说.NET 4.0将扩展线程库...有关system.threading.thread.For的内容?我可以想到一些我想做的地方...对于这千个项目列表中的每个项目,请执行某项操作.

I have heard that .NET 4.0 is going to extend the thread library... Something about system.threading.thread.For ? And I can think of a few places I'd want to do that... For each item in this thousand item list go do something.

http://reedcopsey.com/?p=87

这篇关于进程与线程对性能的影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆