是否有一个足够智能的并行 make 系统可以智能地响应低内存/交换条件?
我非常喜欢使用“make -j8”(当然,用我当前计算机的核心数量替换 8)来加速构建,并且并行编译 N 个文件通常对于减少编译时间非常有效。除非某些编译进程占用的内存足够多,以至于计算机耗尽了 RAM,在这种情况下,所有不同的编译进程都开始相互交换,一切都会变得缓慢——从而违背了并行的目的。首先编译。
现在,这个问题的明显解决方案是“购买更多 RAM”——但由于我的成本太低,无法做到这一点,所以我想到应该可以实现“make”(或等效的)监视系统的可用 RAM,当 RAM 降至接近零并且系统开始交换时,make 将自动介入并向其生成的一个或多个编译进程发送 SIGSTOP。这将允许停止的进程完全换出,以便其他进程可以完成编译而无需进一步交换;然后,当其他进程退出并且有更多 RAM 可用时,“make”进程将向暂停的进程发送 SIGCONT,允许它们恢复自己的处理。这样就可以避免大多数交换,并且我可以在所有内核上安全地进行编译。
有人知道实现这个逻辑的程序吗?或者相反,是否有一些充分的理由为什么这样的程序不能/不能工作?
I'm a big fan of speeding up my builds using "make -j8" (replacing 8 with whatever my current computer's number of cores is, of course), and compiling N files in parallel is usually very effective at reducing compile times... unless some of the compilation processes are sufficiently memory-intensive that the computer runs out of RAM, in which case all the various compile processes start swapping each other out, and everything slows to a crawl -- thus defeating the purpose of doing a parallel compile in the first place.
Now, the obvious solution to this problem is "buy more RAM" -- but since I'm too cheap to do that, it occurs to me that it ought to be possible to have an implementation of 'make' (or equivalent) that watches the system's available RAM, and when RAM gets down to near zero and the system starts swapping, make would automatically step in and send a SIGSTOP to one or more of the compile processes it had spawned. That would allow the stopped processes to get fully swapped out, so that the other processes could finish their compile without further swapping; then, when the other processes exit and more RAM becomes available, the 'make' process would send a SIGCONT to the paused processes, allowing them to resume their own processing. That way most swapping would be avoided, and I could safely compile on all cores.
Is anyone aware of a program that implements this logic? Or conversely, is there some good reason why such a program wouldn't/couldn't work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于 GNU Make,有
-l
选项:不过,我认为没有标准选项。
For GNU Make, there's the
-l
option:I don't think there's a standard option for this, though.