为什么MSYS中的configure这么慢?
当我使用 MSYS 编译某些内容时,./configure
步骤可能比 make
花费更长的时间。然而,同样的过程在Linux中configure速度快,make速度慢。这是否只是 MSYS 中的某些设置导致我的系统陷入困境?有人有解决办法吗?
When I use MSYS to compile something, the ./configure
step can take longer than the make
. However, the same process in Linux has a fast configure and slow make. Is this just some setting in MSYS that is bogging down my system? Does anyone have a solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
典型的配置脚本会启动很多小型子进程。在类 Unix 操作系统上,这是通过 fork() 和 exec() 函数调用完成的,它们具有需要保留的非常特殊的语义(例如,分叉后的写时复制共享内存)。在 Windows 上,子进程是使用 CreateProcess() 创建的,它具有非常不同的语义(例如,与父进程完全分离的内存空间)。为了正确执行类 Unix 的脚本和程序,MSYS 需要做大量的模拟工作,使得在 Windows 上创建新进程就像 Unix 上的
fork()/exec()
一样。这最终会比本地提供这些函数调用的操作系统慢。Typical
configure
scripts do a lot of starting small subprocesses. On Unix-like operating systems, this is done with thefork()
andexec()
function calls, which have very particular semantics that need to be preserved (for example, copy-on-write shared memory after forking). On Windows, subprocesses are created withCreateProcess()
which has very different semantics (eg. completely separate memory space from the parent). In order to execute Unix-like scripts and programs correctly, MSYS needs to do a lot of emulation work to make creating new processes on Windows work likefork()/exec()
on Unix. This ends up being slower than an OS that offers those function calls natively.您可能还想关闭正在运行的所有病毒扫描程序。他们将在每次加载可执行文件时重新扫描它,这绝对会降低脚本性能。
即使您没有运行防病毒软件,也不要忘记 Windows Defender。 (您可能还想禁用用户帐户控制,尽管我不知道这对程序加载时间有什么影响。)
You may also want to turn off any virus scanners you have running. They will re-scan an executable every time it is loaded, which absolutely kills script performance.
Even if you don't have anti-virus running, don't forget about Windows Defender. (You may also want to disable User Account Control, though I don't know what impact that has on program load time.)
涉及大量磁盘访问,恕我直言,这会大大减慢速度。
例如,configure 创建临时源代码,作为其执行的测试的一部分进行编译。这会创建一个必须再次删除的目标文件。
为了加快配置速度,我所做的就是提取我想要在 RAM 驱动器上构建的源代码,并在那里配置和编译它。
我建议使用免费的 ImDisk (http://www.ltr-data.se/opencode.html/#ImDisk)。
A lot of disk access is involved, which IMHO slows things down a lot.
For example configure creates temporary source code to be compiled as part of the tests it performs. This creates an object file that has to be deleted again.
What I do to speed up configure is extract the source I want to build on a RAM drive and configure and compile it there.
I recommend using ImDisk (http://www.ltr-data.se/opencode.html/#ImDisk) which is free.