Skip to content

Instantly share code, notes, and snippets.

@TerrorJack
Created December 27, 2022 22:57
Show Gist options
  • Save TerrorJack/08e5c8f18315d80a3e17b9009969db4a to your computer and use it in GitHub Desktop.
Save TerrorJack/08e5c8f18315d80a3e17b9009969db4a to your computer and use it in GitHub Desktop.

mold-vs-lld benchmark

This benchmark is conducted by compiling LLVM trunk (781eabeb40b8e47e3a46b0b927784e63f0aad9ab) with:

cmake \
  -Bbuild \
  -Hllvm \
  -DCMAKE_BUILD_TYPE=Debug \
  -DLLVM_CCACHE_BUILD=ON \
  -DLLVM_OPTIMIZED_TABLEGEN=ON \
  -DLLVM_PARALLEL_LINK_JOBS=1 \
  -DLLVM_USE_LINKER=lld \
  -G Ninja

Before each build, the tree is wiped. But we do an initial build till completion, so the ccache cache is populated and the resulting time will mainly reflect the linking step.

The compilation is done in an ubuntu 22.04 container on a server with AMD EPYC 7401P (48 logical cores) and 128GB memory.

lld is set up by using official ubuntu apt release. ld.lld version:

Ubuntu LLD 15.0.6 (compatible with GNU linkers)

mold is set up by using official github release tarball. ld.mold version:

mold 1.8.0 (a49a201695edd294ed4d97231c9dc5a994275dd2; compatible with GNU ld)

For fairness, we also compile mold sans mimalloc using cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DMOLD_USE_MIMALLOC=OFF -DCMAKE_INSTALL_PREFIX="$HOME/.local" -G Ninja && cmake --build build --target install.

The time is listed as follows:

lld

real    8m33.229s
user    46m55.646s
sys     28m5.171s

mold

real    7m17.948s
user    24m0.380s
sys     4m48.670s

mold sans mimalloc

real    7m31.060s
user    23m48.600s
sys     4m50.908s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment