Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macho: speed up the linker by embracing multi-threaded approach #143

Merged
merged 139 commits into from
Jul 2, 2024

Conversation

kubkon
Copy link
Owner

@kubkon kubkon commented Jun 25, 2024

At the time of writing, comparison in linking #138 (./new is zld after rewrite, ./old is current master, ./ld is Apple's new linker, ./ld_classic is Apple's old linker, and ./lld is LLVM's stock linker):

Screenshot 2024-06-25 at 12 59 42

Also, just for completeness, speed up in -r relocatable mode between old and new zld:

Screenshot 2024-06-25 at 13 01 28

kubkon added 30 commits June 16, 2024 09:55
@kubkon kubkon force-pushed the macho-cleanup-parallel-writes branch from adae2da to 249a57d Compare June 29, 2024 06:00
@mlugg
Copy link

mlugg commented Jun 29, 2024

On par with LLD, that's what we like to see! So... what shenanigans are Apple up to to make ld so fast?

@kubkon
Copy link
Owner Author

kubkon commented Jun 29, 2024

On par with LLD, that's what we like to see! So... what shenanigans are Apple up to to make ld so fast?

Sadly I don't have access to ld's sources - they haven't released them yet, if ever. Anyhow, we still have room for improvement - we don't mmap the output file yet, or any file in fact.

@kubkon
Copy link
Owner Author

kubkon commented Jun 29, 2024

Oh, and also, bear in mind we do more work since we don't generate the latest MachO binary format. What I mean by this is that the latest dyld doesn't need dyld opcodes which are fairly expensive to generate. Also, I am sure there are places in zld codebase that could be improved further from the algorithmic perspective.

@mlugg
Copy link

mlugg commented Jun 29, 2024

Sadly I don't have access to ld's sources - they haven't released them yet, if ever.

That just means it's reverse-engineering time ;-) /hj

I am sure there are places in the zld codebase that could be improved further from the algorithmic perspective.

If there are any particularly hot bits of code which you think ought to be looked at, I'd be happy to see if I can think of any improvements!

@kubkon kubkon force-pushed the macho-cleanup-parallel-writes branch 13 times, most recently from 5e9853a to b22eebf Compare June 30, 2024 04:34
@kubkon kubkon marked this pull request as ready for review June 30, 2024 04:40
@kubkon kubkon force-pushed the macho-cleanup-parallel-writes branch 3 times, most recently from 6b27cc2 to c62e005 Compare June 30, 2024 21:56
This time we can completely get rid of the mutex in Symbol.
@kubkon kubkon force-pushed the macho-cleanup-parallel-writes branch from 8b0cf5f to 5334972 Compare July 1, 2024 08:11
@kubkon kubkon merged commit bf7b2bb into main Jul 2, 2024
7 checks passed
@kubkon kubkon deleted the macho-cleanup-parallel-writes branch July 2, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants