Linus Torvalds Just Made a Big Optimization to Help Code Compilation Times

栏目: IT技术 · 发布时间: 4年前

Linus Torvalds Just Made A Big Optimization To Help Code Compilation Times On Big CPUs

Written byMichael Larabel inLinux Kernel on 8 February 2020 at 06:38 PM EST.29 Comments

Linus Torvalds Just Made a Big Optimization to Help Code Compilation Times

For those using GNU Make in particular as their build system, the parallel build times are about to be a lot faster beginning with Linux 5.6 for large core count systems. This landing just after the AMD Threadripper 3990X 64-core / 128-thread CPU launch is one example of systems to benefit from this kernel change when compiling a lot of code and making use of many GNU Make jobs.

Linus Torvalds himself changed around the kernel's pipe code to use exclusive waits when reading or writing. While this doesn't mean much for traditional/common piping of data, the GNU Make job-server is a big benefactor as it relies upon a pipe for limiting the parallelism. This technique though employed by the GNU Make job server is inefficient with today's high core count CPUs as all of the spawned processes are woken up rather than a single reader to be woken upon a writer's release.

Linus Torvalds Just Made a Big Optimization to Help Code Compilation Times

In a simplified test case written by Linus Torvalds, this patch caused the number of context switches on the test program to drop from 11 million to just 1.2 million. The consumed system time was also a tiny fraction of the original time. Reducing the number of context switches is also welcome simply for the fact of how much slower context switching performance has become on the Intel side as a result of the countless security mitigations.

Besides this patch landing now for the Linux 5.6 kernel, the patch was partially delayed as this improvement could actually trigger a race condition with the GNU Make job server, which ended up being resolved back in 2017 but only saw a new release with GNU Make 4.3 and then back-ported on some distributions.

Intel's Josh Triplett tested the patch with Linus and confirmed, " I've been hammering on your pipe fix patch (switching to exclusive wait queues) for a month or so, on several different systems, and I've run into no issues with it. The patch *substantially* improves parallel build times on large (~100 CPU) systems, both with parallel make and with other things that use make's pipe-based jobserver. "

The patch is here for those interested from today's mainline Git state.

I'll certainly be testing this impact too on Make-based compilation performance as part of my Linux 5.6 benchmarking. It will be interesting to see the impact on GNU Make based projects, especially with many projects in recent years switching away from the GNU Build System over complaints of slow performance (as well as other factors) in relation to the likes of Meson+Ninja, but at least a lot of code out there is still dependent upon Make for this Linux 5.6+ change to benefit.

29 Comments


以上所述就是小编给大家介绍的《Linus Torvalds Just Made a Big Optimization to Help Code Compilation Times》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Node.js开发指南

Node.js开发指南

郭家寶(BYVoid) / 人民邮电出版社 / 2012-7 / 45.00元

Node.js是一种方兴未艾的新技术,诞生于2009年。经过两年的快速变化,Node.js生态圈已经逐渐走向稳定。Node.js采用了以往类似语言和框架中非常罕见的技术,总结为关键词就是:非阻塞式控制流、异步I/O、单线程消息循环。不少开发者在入门时总要经历一个痛苦的思维转变过程,给学习带来巨大的障碍。 而本书的目的就是帮助读者扫清这些障碍,学会使用Node.js进行Web后端开发,同时掌握事件驱......一起来看看 《Node.js开发指南》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

html转js在线工具
html转js在线工具

html转js在线工具