mold: A Massively Parallel Linker
mold: A Massively Parallel Linker
mold:一款大规模并行链接器
Abstract: Linking is a critical step in the software build process that combines compiled object files into a single executable or shared library. Despite decades of engineering effort, link times remain a significant bottleneck in the edit-compile-debug cycle, particularly for large C++ programs. Existing linkers exploit limited parallelism, leaving most CPU cores idle during linking.
摘要: 链接是软件构建过程中的关键步骤,它将编译后的目标文件合并为单个可执行文件或共享库。尽管经过了数十年的工程努力,链接时间仍然是“编辑-编译-调试”周期中的一个重大瓶颈,尤其是在大型 C++ 程序中。现有的链接器仅利用了有限的并行性,导致大部分 CPU 核心在链接过程中处于闲置状态。
We present mold, a Unix/Linux linker that applies data parallelism systematically across the entire linking pipeline. We first analyze the architectural constraints that prevent existing linkers from scaling, including entangled symbol resolution and archive processing, and then show how a clean-slate design that decouples them overcomes these limitations.
我们推出了 mold,这是一款在整个链接流水线中系统性地应用数据并行性的 Unix/Linux 链接器。我们首先分析了阻碍现有链接器扩展的架构约束,包括纠缠的符号解析和归档处理,然后展示了如何通过一种解耦这些问题的全新设计来克服这些局限性。
On large real-world programs, mold links multi-gigabyte debug binaries in at most a few seconds, and often in under a second. It is 2.4-16.1x faster than the state-of-the-art lld linker, and up to 112x faster than the traditional GNU ld. An ablation study shows that no single optimization dominates; the speedup comes from the cumulative effect of parallelizing all passes.
在大型实际程序中,mold 链接数 GB 大小的调试二进制文件最多只需几秒钟,通常甚至不到一秒。它的速度比目前最先进的 lld 链接器快 2.4 到 16.1 倍,比传统的 GNU ld 快 112 倍。消融研究表明,没有任何单一的优化起决定性作用;速度的提升来自于所有处理阶段并行化后的累积效应。