mold: A Massively Parallel Linker

This lightning talk explores mold, a linker designed around pervasive data parallelism that fundamentally rethinks the traditional sequential linking pipeline. We examine how mold restructures every major pass—from symbol resolution to output generation—to operate over large homogeneous arrays, achieving speedups of 2.4 to 16 times over optimized lld and up to 112 times over GNU ld on real-world workloads. The presentation reveals both the architectural decisions that enable this performance and the practical trade-offs in compatibility and resource consumption that accompany massively parallel linking.
Script
Linking a large C++ program can take a minute, and most of your cores sit idle. The TensorFlow debug build feeds 24 gigabytes of object files into lld, which spends 52 seconds on a 64 core machine while leaving nearly all of them waiting.
The authors argue this bottleneck is architectural, not fundamental. Conventional linkers parallelize selected passes but retain serial dependencies in symbol resolution, archive extraction, and layout. Mold instead restructures the complete pipeline so each major pass operates over large homogeneous arrays with synchronization confined to atomic updates.
Symbol resolution becomes a parallel ownership computation. Input files concurrently attempt to install themselves as the owner of symbols they define using atomic compare and swap operations, with rank ordering determining which definition prevails. This removes the central serialization point in traditional symbol resolution and eliminates the need for left to right archive rescanning.
Across nine large real world workloads, mold is 2.4 to 16 times faster than an optimized lld. The TensorFlow debug build drops from 52 seconds to 3.2 seconds. The Firefox debug build scales from 12 seconds at one thread to 0.9 seconds at 32 threads, then hits a memory bandwidth wall where additional cores provide no benefit.
But this performance comes at a cost. At 64 threads, mold consumes 80 percent more CPU time than at one thread without improving wall clock time. Hardware counters reveal the cause: memory latency doubles and instructions per cycle collapse as the system saturates DRAM bandwidth. The design also sacrifices full GNU linker script compatibility, excluding embedded and kernel workloads.
Mold demonstrates that comprehensive parallelization of the linking pipeline is both feasible and materially more effective than selectively threading isolated phases. For developers linking large debug builds dozens of times per day, trading CPU cycles for sub second turnaround fundamentally changes the development loop. Explore the full architectural details and create your own videos at EmergentMind.com.