Live data from Hacker News

Mold/macOS is 11 times faster than the Apple's default linker to link Chrome

twitter.com

81–90 of 120 posts

Re: Mold/macOS is 11 times faster than the Apple's default linker to link Chrome

#81
post #45

How do I learn about what’s being discussed here? Why do I need a linker?

John R. Levine’s book Linkers and Loaders remains the only comprehensive coverage on the topic. You can get the manuscript proofs for free on the author’s website: https://www.iecc.com/linker/ The Solaris Linkers and Libraries docs are very good and mostly relevant to Linux, with fewer distractions about Windows: https://docs.oracle.com/cd/E37838_01/html/E36783/index.html

I would argue reading mold's source code is much easier and simplier to understand.

Re: Mold/macOS is 11 times faster than the Apple's default linker to link Chrome

#82
post #70
post #65

Earlier quoted context omitted.

Huh? Isn't the output of the linker roughly the same size as the sum of the inputs?

> Huh? Isn't the output of the linker roughly the same size as the sum of the inputs? No. Linkers today even do link-time code generation. Debug info is gargantuan and can be kept as separate files too.

I don't know what code linkers are generating on their own but doesn't it sort of imply that the output is at least as large as the input?

Re: Mold/macOS is 11 times faster than the Apple's default linker to link Chrome

#84
post #30
post #22

Earlier quoted context omitted.

I sort of wish Apple, Amazon, Google, Microsoft and Facebook all contribute $200K each and say hey can you now make Mold MIT or BSD.

$200K is nowadays an annual total compensation of a junior dev. I believe mold values much more than a one year outcome of a typical 5-person junior dev team.

Easiest way to confirm what value it has is to simply charge for it :)

Look at Sidekiq for inspiration on how to charge for open source.

Re: Mold/macOS is 11 times faster than the Apple's default linker to link Chrome

#85
post #12

The Apple linker also seems to have a habit of randomly changing it's mind about certain niggly details about MachO binaries which is extremely irritating as a compiler dev

What’s an example?

I can't remember the details (I'm stuck on my phone but I'll try and dig it up later if I remember) but we had some issues with certain sections not being to it's liking so code that was fine on one xcode version then broke on upgrade.

Similarly I had to replace how we implement C runtime destructors because Apple deprecated the way to write a destructor in a binary. This wasn't too hard to do, just call atexit from the itanium C++ ABI, but we had basically no warning as far as I'm aware.

Re: Mold/macOS is 11 times faster than the Apple's default linker to link Chrome

#86
post #31

Earlier quoted context omitted.

Note that recent lld is also multithreaded, and with tweaks, can be faster than mold at low core counts: https://bugzilla.mozilla.org/show_bug.cgi?id=1746462#c2

I wouldn't be surprised. In mold, if we have more than one choices to implement a feature, I always take the one that scales well for more cores even if it doesn't perform the best on low-core count machines. My assumption is that future machines will have more cores than we have today on average, so I'm optimizing mold for such computers.

> My assumption is that future machines will have more cores than we have today on average, so I'm optimizing mold for such computers.

From the manpage of mold-1.3.0, I get the impression mold is designed to scale up to 32 cores, but not more.

  man mold | rg -C2 32
       --threads
       --no-threads
               Use multiple threads.  By default, mold uses as many threads as the number of cores or 32, whichever is the smallest.  The reason why it is capped to 32 is because mold doesn't scale well beyond that point.  To use only one thread, pass --no-threads or --thread-count=1.

Is this correct or does the manpage need to be updated?

Re: Mold/macOS is 11 times faster than the Apple's default linker to link Chrome

#87
post #9

Apple and Microsoft should really throw some money at Rui; Mold is a massive improvement to developer experience, and the sooner it's ported to their platforms the better. I find myself defaulting to Linux for Rust development these days, mostly because Mold makes the inner loop of development so much faster.

Can you please share the link about how it helps in inner loop? Sorry, I never heard of these tools and google is not returning any useful results

It's not really something you can "link" to tho? But the basic loop of development in most cases (in compiled languages) is making a code change, then building the software (or tests), and then running the software (or tests) to check that your change did what it was supposed to do.

Building the software is divided into two steps; compiling your source files into object files, then linking those object files together into an executable. As a project grows, the time taken by the compile step in this development loop stays roughly constant; if you only change a single source file, only that source file has to be recompiled. However, the link step has to link together all your object files, from scratch, every time, so the time taken by the link step grows roughly linearly as the project size grows.

Since mainstream linkers are fairly slows, an incremental build of huge projects is generally dominated by the link step. I've personally experienced the pain of making a small change to Chromium, waiting a second or so for the source file I changed to be recompiled, then waiting a minute or two for the linker to go through every single object file and produce the final executable. Mold would have reduced the build time in the development loop from minutes to seconds.

I hope that helped.

Re: Mold/macOS is 11 times faster than the Apple's default linker to link Chrome

#88
post #82
post #70

Earlier quoted context omitted.

> Huh? Isn't the output of the linker roughly the same size as the sum of the inputs? No. Linkers today even do link-time code generation. Debug info is gargantuan and can be kept as separate files too.

I don't know what code linkers are generating on their own but doesn't it sort of imply that the output is at least as large as the input?

Linkers can also do something called "Identical code folding", or ICF, whereby the linker notices that two pieces of code are exactly the same and can merge them. lld's sources include a little overview of how this is done, see https://github.com/llvm-mirror/lld/blob/master/ELF/ICF.cpp

Re: Mold/macOS is 11 times faster than the Apple's default linker to link Chrome

#90
post #47
post #30

Earlier quoted context omitted.

$200K is nowadays an annual total compensation of a junior dev. I believe mold values much more than a one year outcome of a typical 5-person junior dev team.

> $200K is nowadays an annual total compensation of a junior dev *in the US. In my country, those salaries are completely unheard of.

As I know, Rui was in the US (when he was at Google), so it is a fair statement.
Post reply on HN