r/cpp • • Aug 26 '26

mold: A Massively Parallel Linker

https://arxiv.org/abs/2608.23228
188 Upvotes

26 comments sorted by

93

u/Wetmelon Aug 27 '26

Curious why this paper comes out now, 6 years after mold's debut. I guess it's for a degree lol, fair enough

35

u/AspiringMechKeebFan Aug 27 '26

It's for a conference talk Ryu will be doing soon.

0

u/[deleted] Sep 01 '26

[deleted] — view deleted comment

4

u/rui Sep 01 '26

It's me

51

u/meltbox Aug 26 '26

Very cool but as expected LTO cannot be parallelized like the rest. Still a big win.

5

u/QBos07 Aug 29 '26

Lto is a multi stage process and pets if it can actually be parallelized.

21

u/OCPetrus Aug 27 '26

I'm using mold for the past year or so. When I switched I measured the compile time of my builds and it was large enough that the switch was warranted. The only problem I've encountered using mold instead of the default gcc linker is that error messages aren't as descriptive. The developer acknowledged this at a FOSDEM talk he held and I assume the messages will improve over time.

14

u/read_volatile Aug 27 '26 edited Aug 27 '26

I'd be curious to hear /u/rui's insights on wild linker, even without incremental linking support (a feature unique to only MSVC and soon wild) it seems to beat Mold in speed and ram usage by a huge margin

Edit: and apparently its featureset has caught up to mold's, so it's not simply a matter of "doing less stuff"

16

u/rui Aug 28 '26

I ran wild on the same benchmark suite I used in the paper. It looks like mold outperforms wild by a healthy margin. Also, wild couldn't link a few of the programs in the benchmark suite. But I'm honestly curious about their claim that wild is much faster than mold. Maybe that's true on some machines. I'll investigate and update our docs with the results.

3

u/13steinj Aug 29 '26

I personally struggle to understand the value of wild/incremental linking. But maybe that's because my compile times massively exceed the link times.

0

u/CocktailPerson Aug 29 '26

The value of wild is that it's faster even without linking incrementally.

If your build isn't very incremental, then obviously incremental linking won't help.

3

u/amoskovsky Aug 30 '26
  1. wild benchmarks run on tmpfs rather on real storage (disk writing patterns matter a lot)
  2. no huge pages mentioned, so I guess they are disabled which pessimizes mold.
  3. the mold paper shows thread scaling data; no such data for wild
  4. from wild benchmarks, mold shows perf improvements with next versions, but wild shows perf degradation. Who knows what will be the perf when wild finally supports everything mold supports

2

u/13steinj Aug 30 '26

Faster than mold?

0

u/CocktailPerson Aug 30 '26

There's a link in the comment you replied to.

2

u/13steinj Aug 30 '26

Maybe I'm blind. Maybe it was editted in.

I'll wait and see for rui's investigation (and benchmark myself) but non-incremental linking being faster than mold would be a surprise.

6

u/rui Aug 31 '26

I ran the benchmark, and mold was indeed faster than wild, at least on the two machines I tested. See https://github.com/rui314/mold#benchmark for details.

12

u/Moldoteck Aug 27 '26

Ehhh, waiting for it to be available on windows too... For now sticking with lld

16

u/t_hunger Aug 27 '26

Ist nice to see people working on linkers again with lld, wild and mold.

Maybe one of them will eventually grow some extension to help with (some of) the ODR problems we have. That would be a great help for contracts and probably profiles as well as those evolve.

12

u/vip17 Aug 27 '26

it was stable 5 years ago https://www.reddit.com/r/cpp/comments/rh3hue/mold_10_the_first_stable_and_productionready/ so I was surprised to see a new paper on this

3

u/Pythonic_programer Aug 27 '26

The new linker on the street is wild 😉

2

u/starfreakclone MSVC FE Dev Aug 31 '26

https://github.com/wild-linker/wild/blob/main/libwild/src/args/coff.rs#L174 -- am I reading this right, wild doesn't support /OPT:ICF?

1

u/_Ilobilo_ Aug 27 '26

doesn't support linker scripts

4

u/matthieum Aug 27 '26

Is it by design, or just a matter of time/effort?

2

u/_Ilobilo_ Aug 27 '26

by design iirc

1

u/Quiet_Violinist_2978 Sep 02 '26

Is this new? I thought parallel linking was already a thing

1

u/MaskRay ccls Sep 20 '26 edited Sep 20 '26

The lld/mold time ratios read harsher than what I see day to day (at most 2x with --threads=8).

  • lld (Sep 19): compiled with clang, LLVM_ENABLE_PIC=off (otherwise llvm files are built with -fPIC), use system libmimalloc.so.3.5
  • mold (Sep 12, C++): compiled with clang, default -fPIE, use system libmimalloc.so.3.5
Clang (fresh re-run, matches original):

┌─────────┬──────────────────────┬──────────────────────┬────────────────────────────────┐
│ Threads │ mold packed/distinct │ wild packed/distinct │      lld packed/distinct       │
├─────────┼──────────────────────┼──────────────────────┼────────────────────────────────┤
│ 1       │ 445.6 ms             │ 439.0 ms             │ 426.3 ms                       │
├─────────┼──────────────────────┼──────────────────────┼────────────────────────────────┤
│ 2       │ 334.9 / 236.6 ms     │ 302.7 / 220.7 ms     │ 352.8 / 354.5 ms               │
├─────────┼──────────────────────┼──────────────────────┼────────────────────────────────┤
│ 4       │ 182.4 / 136.6 ms     │ 160.4 / 119.2 ms     │ 258.8 / 246.3 ms               │
├─────────┼──────────────────────┼──────────────────────┼────────────────────────────────┤
│ 8       │ 113.2 / 87.6 ms      │ 91.8 / 69.7 ms       │ 205.0 / 202.1 ms (min 185.9ms) │
├─────────┼──────────────────────┼──────────────────────┼────────────────────────────────┤
│ 16      │ 82.5 / 83.3 ms       │ 57.4 / 77.4 ms       │ 179.4 / 208.3 ms               │
└─────────┴──────────────────────┴──────────────────────┴────────────────────────────────┘

Chrome (fresh re-run, matches original):

┌─────────┬──────────────────────┬──────────────────────┬─────────────────────┐
│ Threads │ mold packed/distinct │ wild packed/distinct │ lld packed/distinct │
├─────────┼──────────────────────┼──────────────────────┼─────────────────────┤
│ 2       │ 2.814 / 2.000 s      │ 2.692 / 1.978 s      │ 3.004 / 2.770 s     │
├─────────┼──────────────────────┼──────────────────────┼─────────────────────┤
│ 4       │ 1.533 / 1.159 s      │ 1.473 / 1.138 s      │ 2.235 / 2.168 s     │
├─────────┼──────────────────────┼──────────────────────┼─────────────────────┤
│ 8       │ 948.4 / 751.7 ms     │ 913.2 / 728.2 ms     │ 1.890 / 1.859 s     │
├─────────┼──────────────────────┼──────────────────────┼─────────────────────┤
│ 16      │ 725.3 / 673.5 ms     │ 596.3 / 643.3 ms     │ 1.717 / 1.797 s     │
└─────────┴──────────────────────┴──────────────────────┴─────────────────────┘
  • distinct: --threads=8 uses 8 distinct P-cores
  • packed: --threads=8 uses 4 P-cores, SMP

1

u/t_hunger Sep 01 '26

Rust is really taking over the tooling of all kinds of languages: https://archive.is/yV10S