9 ms·
Mold/macOS is 11 times faster than the Apple's default linker to link Chrome
- AA-BA-94-2A-56 4y ago20 seconds down to 2 seconds is a huge achievement. I'll still be telling my boss I'm waiting for a build while I go for my 15 minute coffee, though
- rui314 4y agoIf it takes 20 seconds, you go for a coffee or switch the window to start web browsing, but if it takes only 2 seconds, you can wait without being distracted. So it's more than just saving 18 seconds for each build. It wouldn't interrupt your flow.
- anitil 4y agoYou'll have to switch to instant coffee!
- rui314 4y agoAuthor here. If you have any questions about mold/macOS, feel free to ask me as a reply.
- comex 4y agoCan mold also serve as a replacement for dsymutil (i.e. linking DWARF info)? If not, any plans to support this in the future? :)
- rui314 4y agoI haven't thought about that that much, but it looks like dsymutil is a companion command of a linker, so the answer is probably yes, but I need to investigate it further to give you a concrete answer.
- glandium 4y agoSomeone was supposed to make llvm-dsymutil use the lld code, but that didn't happen.
- azinman2 4y agoWhy is it so much faster?
- rui314 4y agoThe 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. I believe the biggest contributor is its efficient data structure -- it is hard to make program faster by writing fast code, but it can naturally be achieved by designing efficient data structures. That said, it is hard to compare two or more programs to find out why one program is faster than the others unless their designs are similar.
- ripley12 4y agoApple 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.
- wyldfire 4y agoRui has made it explicit that a commercial license is available. Hey Rui, you should replace "please call" with a dollar amount in order to increase your conversion rate ;)
- rui314 4y agoI dislike "contact us for pricing" too, but pricing is hard! I don't know how much I should ask for. This is also a bit unusual business model because mold can be used for free. I'm happy if users pay me 10%-20% of the total cost they could save by using mold though.
- ksec 4y agoI sort of wish Apple, Amazon, Google, Microsoft and Facebook all contribute $200K each and say hey can you now make Mold MIT or BSD.
- forty 4y agoWhat's wrong with the current agpl license, especially for a linker?
- kevin_thibedeau 4y agoCorporations don't understand the GPL and how isolated, unmodified tools aren't viral.
- 4y ago
- mhh__ 4y agoThe 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
- cwzwarich 4y agoWhat’s an example?
- mhh__ 4y agoI 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.
- dalanmiller 4y agoHow do I learn about what’s being discussed here? Why do I need a linker?
- rui314 4y agoYou may want to read this section of the README. https://github.com/rui314/mold#why-does-the-speed-of-linking-matter https://github.com/rui314/mold#why-does-the-speed-of-linking...
- mrtksn 4y agoHere is a video presentation from Apple about the topic: https://developer.apple.com/videos/play/wwdc2022/110362 https://developer.apple.com/videos/play/wwdc2022/110362 It has an introduction section on what is a linker and why you need one. The gist is, linker is the piece of software that puts together different source file, be it at compile time or runtime. So, the faster is your linker the quicker the app compiles and opens.
- gspr 4y agoTo assemble executable code from separately compiled files. Or to tell your executable code from where other executable code it needs can be loaded at runtime.
- fmajid 4y agoJohn 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/ 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 https://docs.oracle.com/cd/E37838_01/html/E36783/index.html
- rurban 4y agoI would argue reading mold's source code is much easier and simplier to understand.
- pjmlp 4y agoGreat achievement, does it support all deployment targets, build configurations for Swift and Objective-C?
- masklinn 4y ago>> Why is time spent on System is so much higher than the other one even though that one takes longer? > Good question but I don't know the answer. Don’t know if that’s the final answer here (didn’t actually investigate), but system is the time spent in syscalls, and locks are usually provided by the OS, aka syscalls (though there might be userland components to avoid the syscall e.g. futex). Thus the need for synchronisation of threaded program generally leads to higher system time. Though here mold is clearly a lot more efficient as well (lower user time).
- spockz 4y agoI’ve always been more attracted to the higher level languages and followed llvm from a compiler interest. So I know the principles, but I would like to understand more. Especially related to cross compilation. Does someone have a source explaining the state of the art? With all the different compilers, gcc, clang and the different flavours of linkers: ld, lld, mold, gold, ?
- pxeger1 4y agoA linker seems like it ought to be a simple piece of software. What is a linker doing that takes so long?
- londons_explore 4y agoWell at a minimum it has to load into RAM all the built objects, which probably include debugging symbols. For something like Chrome, thats probably 20 Gigs...
- amelius 4y agoHuh? Isn't the output of the linker roughly the same size as the sum of the inputs?
- my123 4y ago> 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.
- amelius 4y agoI 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?
- dxf 4y agoLinkers 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 https://github.com/llvm-mirror/lld/blob/master/ELF/ICF.cpp
- 4y ago
- cbmuser 4y agoYes, but it supports only a fraction of the architectures that binutils supports and I usually don’t recompile Chrome every day. ¯\_(ツ)_/¯
- rui314 4y agoThat's not for you then, but some people have to rebuild Chrome-scale programs dozens of times a day, and mold is created for such people.
- aaaaaaaaaaab 4y agoHow does it compare to zld?
- plorkyeran 4y agozld is probably no longer relevant as of Xcode 14 as ld64 now performs similarly to it. Mold is much faster than both.
- stefantalpalaru 4y ago
- thejosh 4y agoMold is absolutely invaluable for building projects on Linux with Rust, so I'm super excited that work is being done to make it work with Mac.
- astrostl 4y agoI can infer from context that mold is a linker. It took searching for https://github.com/rui314/mold 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.
- guessbest 4y agoI 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.
- dang 4y agoSome posts get picked for a second-chance by moderators - see https://news.ycombinator.com/item?id=26998308 https://news.ycombinator.com/item?id=26998308 - but it doesn't have any connection to twitterers, nor to 'connections to the site moderators', except in the sense that we recognize some usernames as good submitters. The intention is just to comb through the stacks looking for good stories that didn't get attention the first time around—especially on topics that aren't correlated with anything else. HN has a wealth of these and I'm pretty sure we still miss half of them.