Live data from Hacker News

Mold – A really fast linker

github.com

61–64 of 64 posts

Re: Mold – A really fast linker

#61
post #29

It seems odd to me that we still require .o files at all. Given the final program needs to be storable in RAM + Virtual Memory it surprises me that we still need the intermediate step of pushing to the file system only to then immediately reopen and merge those files. Does someone have more info on this? Or is the reason just legacy? Or is the reason just some ideological “single responsibility” thing?

At the highest level of performance needs, if you want to parallelize the build across machines, you're going to need some kind of storage abstraction for intermediate files since translation units are the easiest place to split builds at. In some places, where builds are particularly optimized, there are special distributed filesystems just for object files. In this case, it's not necessarily true that the object fi…

Thank you the distributed compile usecase is a fun one to think about. I can see why it would require some intermediate set of bytes to shuffle across the network.

> Being backed by disk locally mainly helps for incrementally building so that you can change one file and only recompile intermediate files for translation units that depend on this file.

For the local incremental usecase I’d love to see a more state-full compiler instead. One that could change the bytes of a binary instead. e.g. give all functions some additional “empty padding”. Then any modifications could directly fit into the binary as needed until some defragmentation process which creates the final output binary.

Re: Mold – A really fast linker

#62

Earlier quoted context omitted.

What problem are you trying to solve by keeping .o files in a processes’s memory without spilling to disk?

To reduce the latency of compile-link-test

I don’t think writing to and reading from disk is a significant portion of this loop. You’d want to measure the cost and thus maximum benefit. SSDs are fast. There isn’t much upside here.

Re: Mold – A really fast linker

#63
post #29

Earlier quoted context omitted.

At the highest level of performance needs, if you want to parallelize the build across machines, you're going to need some kind of storage abstraction for intermediate files since translation units are the easiest place to split builds at. In some places, where builds are particularly optimized, there are special distributed filesystems just for object files. In this case, it's not necessarily true that the object fi…

Thank you the distributed compile usecase is a fun one to think about. I can see why it would require some intermediate set of bytes to shuffle across the network. > Being backed by disk locally mainly helps for incrementally building so that you can change one file and only recompile intermediate files for translation units that depend on this file. For the local incremental usecase I’d love to see a more state-full…

Don't quote me on this, but I do believe MSVC does exactly this by default. The option is /INCREMENTAL.

That said, it accomplishes this still using an on-disk datastore.

Re: Mold – A really fast linker

#64

Earlier quoted context omitted.

To reduce the latency of compile-link-test

I don’t think writing to and reading from disk is a significant portion of this loop. You’d want to measure the cost and thus maximum benefit. SSDs are fast. There isn’t much upside here.

The problem may be disk speed, but I agree it may not. The problem I see is the dropping of state.

Specifically, to produce a .o file the compiler has already read through and created indexes of module::function/struct names, their layouts, dependencies, etc.

My understanding is that the .o files need to be re-parsed by the linker to create these indexes, layouts, and dependencies. Especially with LTOs I'd imagine there would be additional inlining work (stuff the compiler is already good at).

This is all just wasted time, including the IO bottlenecks - even if those are marginal.

Post reply on HN