Live data from Hacker News

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

twitter.com

91–100 of 120 posts

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

#91
I can infer from context that mold is a linker. It took searching for https://github.com/rui314/mold to learn what it actually was, though:

"mold is a faster drop-in replacement for existing Unix linkers. It is several times faster than the LLVM lld linker, the second-fastest open-source linker which I originally created a few years ago. mold is designed to increase developer productivity by reducing build time, especially in rapid debug-edit-rebuild cycles."

I don't understand how things like this still manage to front-page without a cursory explanation.

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

#92
post #81
post #45

Earlier quoted context omitted.

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.

Than Levine’s book? You would lose the argument.

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

#93

I can infer from context that mold is a linker. It took searching for https://github.com/rui314/mold to learn what it actually was, though: "mold is a faster drop-in replacement for existing Unix linkers. It is several times faster than the LLVM lld linker, the second-fastest open-source linker which I originally created a few years ago. mold is designed to increase developer productivity by reducing build time, espe…

I think yn is a mature enough site that stories are placed by the site curators and twitter users with connections to the site moderators are part of the curation process. There have been a lot more twitter posts as new submissions this past year or two.

Also, thank you for finding out what the topic discussion was about and sharing. I couldn't infer the meaning.

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

#94
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?

No, outputs are generally smaller than inputs, and for large programs they are much smaller than the inputs. The .o files contain all the data necessary to put the program together and after linking most of that information is no longer needed. I just built a small program I happen to have locally and the constituent .o files add up to 580KiB but the linked program is 208KiB. Another small program has 192KiB of linker inputs and 124KiB of output. This effect is larger for large programs.

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

#95
post #88
post #82

Earlier quoted context omitted.

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

ICF exists but no linker is going to silently do it behind your back without an explicit directive, because it breaks debugging in certain ways. Folded identical functions can't be disambiguated in the file/line tables, so symbolized backtraces may contain impossible calls.

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

#96
post #55

Earlier quoted context omitted.

It might be asking for too much, but this project would be a nice addition to http://aosabook.org Thanks for your good work! I still remember the O(n^2) complexity of ld.bfd when linking C++ code.

I want to write a book about linkers so that the knowledge I earned during the development of the lld and mold linkers wouldn't lost, but I don't have enough time to do that!

I'm one data point but I'd buy it in an instant.

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

#98
post #96
post #55

Earlier quoted context omitted.

I want to write a book about linkers so that the knowledge I earned during the development of the lld and mold linkers wouldn't lost, but I don't have enough time to do that!

I'm one data point but I'd buy it in an instant.

FYI: https://www.amazon.com/Linkers-Loaders-John-R-Levine/dp/1558...

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

#99
post #7
post #6

Earlier quoted context omitted.

Why is it so much faster?

The biggest reason is because it is multi-threaded. When building a program, the compilation step is parallelized (the build system invokes a compiler for each source file), but the final link step is not. So it is important to make the linker itself multi-threaded. But even without multi-threading, mold is still faster than other linkers. I can think of various reasons why, but I don't know which attributes how much…

Could you comment on which data structures are most critical to mold’s performance, and what makes them so fast?

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

#100
post #7

Earlier quoted context omitted.

The biggest reason is because it is multi-threaded. When building a program, the compilation step is parallelized (the build system invokes a compiler for each source file), but the final link step is not. So it is important to make the linker itself multi-threaded. But even without multi-threading, mold is still faster than other linkers. I can think of various reasons why, but I don't know which attributes how much…

Could you comment on which data structures are most critical to mold’s performance, and what makes them so fast?

Ah, I overlooked this explanation at first: https://github.com/rui314/mold/blob/main/docs/design.md

Thanks for the great write up as well as mold itself!

Post reply on HN