News for hackers. Stuff that matters.
Re:Mold/macOS is 11 times faster than the Apple's default li... by rui314 on Sunday June 19, 2022 @12:22AM (#31796144)
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. 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.

Re:Mold/macOS is 11 times faster than the Apple's default li... by glandium on Sunday June 19, 2022 @01:50AM (#31796484)
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
Re:Mold/macOS is 11 times faster than the Apple's default li... by rui314 on Sunday June 19, 2022 @03:03AM (#31796932)
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.

Re:Mold/macOS is 11 times faster than the Apple's default li... by petr_tik on Sunday June 19, 2022 @10:38AM (#31799804)
> 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 li... by bertr4nd on Sunday June 19, 2022 @12:48PM (#31800998)
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 li... by bertr4nd on Sunday June 19, 2022 @01:09PM (#31801205)
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!