This is an archive of the discontinued LLVM Phabricator instance.

Cache file IDs of symbols in emitStabs for faster sorting
ClosedPublic

Authored by michaeleisel on Jun 1 2022, 8:10 AM.

Details

Summary

This reduces the time emitStabs() takes by about 275ms, or 3% of overall linking time for the project I'm on. Although the parent function is run in parallel, it's one of the slowest tasks in that concurrent batch (I have another optimization for another slow task as well).

This is my first LLVM revision, so any guidance on the process is appreciated.

Diff Detail

Event Timeline

michaeleisel created this revision.Jun 1 2022, 8:10 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 1 2022, 8:10 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
michaeleisel requested review of this revision.Jun 1 2022, 8:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2022, 8:10 AM
michaeleisel edited the summary of this revision. (Show Details)Jun 1 2022, 8:13 AM
michaeleisel added inline comments.
lld/MachO/SyntheticSections.cpp
924

We could also use bucket sort instead, but I just went with this. It reduces sorting time by ~75%

thakis accepted this revision.Jun 1 2022, 8:54 AM
thakis added a subscriber: thakis.

Nice!

I'd keep the name symbolsNeedingStabs though, that seems like a much better name than sortingPairs (?)

Do you have commit permissions, or should I land this for you? If so, what --author= should I use (ie preferred name and email)?

This revision is now accepted and ready to land.Jun 1 2022, 8:54 AM

Rename to symbolsNeedingStabs

@thakis I don't have commit permissions, if you could land it that'd be great. My preferred name is "Michael Eisel", and preferred email is "michael.eisel@gmail.com". Thanks!

MaskRay accepted this revision.Jun 1 2022, 10:24 AM
MaskRay added a subscriber: MaskRay.
MaskRay added inline comments.
lld/MachO/SyntheticSections.cpp
894

use using

Landed in f5709066e3b0, thanks!

lld/MachO/SyntheticSections.cpp
894

Done.

This revision was landed with ongoing or failed builds.Jun 1 2022, 11:51 AM
This revision was automatically updated to reflect the committed changes.
int3 added a subscriber: int3.Jun 1 2022, 11:53 AM

Awesome!

thakis added inline comments.Jun 1 2022, 11:53 AM
lld/MachO/SyntheticSections.cpp
922–923

Oh sorry, I missed that this is > 80 columns. LLVM uses 80 columns. Run git clang-format HEAD^ to make clang-format auto-format your code before sending out patches :)

Fixed this up in 815825f4426f91. Apologies again for missing it before committing.

@thakis oops, will do in the future!