为什么在Windows上创建新流程要比Linux昂贵? [英] Why is creating a new process more expensive on Windows than Linux?

查看:89
本文介绍了为什么在Windows上创建新流程要比Linux昂贵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说在Windows机器上创建新进程比在Linux上昂贵.这是真的?有人可以解释为什么价格更高的技术原因,并提供这些原因背后的设计决策的历史原因吗?

I've heard that creating a new process on a Windows box is more expensive than on Linux. Is this true? Can somebody explain the technical reasons for why it's more expensive and provide any historical reasons for the design decisions behind those reasons?

推荐答案

mweerden:从第一天开始,NT就已为多用户设计,因此,这并不是真正的原因.但是,您对的是,进程创建在NT上的作用不如在Unix上重要,因为与Unix相比,NT与Unix相比,更倾向于多线程而不是多处理.

mweerden: NT has been designed for multi-user from day one, so this is not really a reason. However, you are right about that process creation plays a less important role on NT than on Unix as NT, in contrast to Unix, favors multithreading over multiprocessing.

Rob,使用COW时fork的确是相对便宜的,但是事实上,fork后面紧跟着一个exec.执行人员也必须加载所有图像.因此,讨论前叉的性能只是事实的一部分.

Rob, it is true that fork is relatively cheap when COW is used, but as a matter of fact, fork is mostly followed by an exec. And an exec has to load all images as well. Discussing the performance of fork therefore is only part of the truth.

在讨论进程创建的速度时,最好区分NT和Windows/Win32.就NT(即内核本身)而言,我认为进程创建(NtCreateProcess)和线程创建(NtCreateThread)不会比一般Unix显着慢.可能还有更多事情要做,但是我看不出性能差异的主要原因.

When discussing the speed of process creation, it is probably a good idea to distinguish between NT and Windows/Win32. As far as NT (i.e. the kernel itself) goes, I do not think process creation (NtCreateProcess) and thread creation (NtCreateThread) is significantly slower as on the average Unix. There might be a little bit more going on, but I do not see the primary reason for the performance difference here.

但是,如果您查看Win32,您会发现它增加了相当多的过程创建开销.首先,它要求CSRSS通知有关过程创建的过程,这涉及LPC.它至少需要另外加载kernel32,并且必须执行许多其他的簿记工作项目,然后才能将该进程视为完整的Win32进程.而且,我们不要忘记解析清单所带来的所有额外开销,检查映像是否需要兼容填充程序,检查软件限制策略是否适用(yada yada).

If you look at Win32, however, you'll notice that it adds quite a bit of overhead to process creation. For one, it requires the CSRSS to be notified about process creation, which involves LPC. It requires at least kernel32 to be loaded additionally, and it has to perform a number of additional bookkeeping work items to be done before the process is considered to be a full-fledged Win32 process. And let's not forget about all the additional overhead imposed by parsing manifests, checking if the image requires a compatbility shim, checking whether software restriction policies apply, yada yada.

也就是说,除了原始创建进程,VA空间和初始线程之外,我还看到所有必须做的小事情的总和总体下降.但是正如一开始所说的那样-由于多线程比多任务更受青睐,因此唯一受到此额外费用严重影响的软件就是移植性差的Unix软件.尽管当Chrome和IE8之类的软件突然重新发现多处理的好处并开始频繁启动和拆卸过程时,这种情况会改变...

That said, I see the overall slowdown in the sum of all those little things that have to be done in addition to the raw creation of a process, VA space, and initial thread. But as said in the beginning -- due to the favoring of multithreading over multitasking, the only software that is seriously affected by this additional expense is poorly ported Unix software. Although this sitatuion changes when software like Chrome and IE8 suddenly rediscover the benefits of multiprocessing and begin to frequently start up and teardown processes...

这篇关于为什么在Windows上创建新流程要比Linux昂贵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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