According to the readme, Rust is supported, did anyone tried and noticed improvement? rui314/mold: Mold: A Modern Linker 🦠 https://github.com/rui314/mold
According to the readme, Rust is supported, did anyone tried and noticed improvement? rui314/mold: Mold: A Modern Linker 🦠 https://github.com/rui314/mold
With a total build time of less than 2 minutes, my guess is that link time is fairly small. At work we have a c++ project that takes around 40 minutes to build. Only in the incremental case does link time dominate (upwards of 10 seconds with gold, haven’t tried lld or mold).
My understanding is that mold supposedly has more scalable data structures and algorithms (better complexity). Thus for small links there likely will be little difference. So you need to measure it on your actual use case to see if it makes a difference.
mold supposedly can take more advantage of multi core. How many cores did you run on? Again this will likely not show for small links, since there is also overhead in splitting work across threads.
Okay. I updated mold to
v2.0.0
. Added"-Z", "time-passes"
to get link times, ran cargo with--timings
to get CPU utilization graphs. Tested on two projects of mine (the one from yesterday is “X”).Link times are picked as the best from 3-4 runs, changing only white space on
main.rs
.lto="fat"
Observations (
lto="fat"
): As expected, not a lot of utilization of multi-core. Usingcodegen-units
larger than 1 may even cause a regression in link time. Choice of linker betweenlld
andmold
appears to be of no significance.lto="thin"
Observations (
lto="thin"
): Here, we see parallelLLVM_lto_optimize
runs kicking in. Testing withcodegen-units=16
was also done. In that case, the number of parallelLLVM_lto_optimize
runs was so big, the synchronization overhead caused a regression running that test on a humble workstation powered by an Intel i7-7700K processor (4 physical, 8 logical cores only). The results will probably look different running this test case (cu=16) in a more powerful setup. But still, the choice of linker betweenlld
andmold
appears to be of no significance.lto=false
Observations (
lto=false
): Here,codegen-units
becomes the dominant factor with no heavyLLVM_lto_optimize
runs involved. Going abovecodegen-units=8
does not hurt link time. Still, the choice of linker betweenlld
andmold
appears to be of no significance.lto="off"
Observations (
lto="off"
): Same observations aslto=false
. Still, the choice of linker betweenlld
andmold
appears to be of no significance.Debug builds link in <.4 seconds.
With such a small program I expected fixed costs to dominate. Not surprising there is no or almost no difference. You really have to go to cases where linking takes 10s of seconds to see scaling difference, even between ld.bfd and ld.gold.
I did those sort of measurements for my work at the time (a few years ago, before mold was a thing). I have not had the cause or opportunity to measure lld or mold however. Maybe it isn’t faster than lld (certainly it seems so for small projects), but I don’t think these result say anything useful about larger programs.
The best option is not to take the word of others (myself included) however, but measure on your own application and see which is the best option in your case.
If you however do want to measure linking something big, look at something like Chromium. That isn’t rust code though. Not sure what a suitably large rust project would be.