This is an archive of the discontinued LLVM Phabricator instance.

[SymbolSize] Improve the performance of SymbolSize computation
ClosedPublic

Authored by steven_wu on Jul 29 2023, 3:29 PM.

Details

Summary

The current algorithm to compute the symbol size is quadratic if there
are lots of symbols sharing the same addresses. This happens in a debug
build when lots of debug symbols get emitted in the symtab.

This patch improves the performance like llvm-symbolizer that relies
on the symbol size computation. Symbolizing a release+assert clang with
DebugInfo sees significant improvements from 3:40min to less than 1s.

Diff Detail

Event Timeline

steven_wu created this revision.Jul 29 2023, 3:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2023, 3:29 PM
steven_wu requested review of this revision.Jul 29 2023, 3:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2023, 3:29 PM
steven_wu updated this revision to Diff 545387.Jul 29 2023, 3:30 PM

Update commit message

steven_wu edited the summary of this revision. (Show Details)Jul 29 2023, 3:30 PM
mehdi_amini accepted this revision.Jul 29 2023, 3:49 PM
mehdi_amini added a subscriber: mehdi_amini.

Nice!

This revision is now accepted and ready to land.Jul 29 2023, 3:49 PM
arsenm accepted this revision.Jul 29 2023, 5:49 PM
pete accepted this revision.Jul 29 2023, 7:46 PM
MaskRay accepted this revision.Jul 29 2023, 10:28 PM
MaskRay added a subscriber: MaskRay.

Nice! This is for non-ELF object file formats (https://discourse.llvm.org/t/llvm-symbolizer-has-gotten-extremely-slow/67262/29). It may be different from others' reports (primarily about ELF).

Nice! This is for non-ELF object file formats (https://discourse.llvm.org/t/llvm-symbolizer-has-gotten-extremely-slow/67262/29). It may be different from others' reports (primarily about ELF).

I guess I missed most of the context on discord thread. I saw this issue on Darwin CI and did some investigation while try to find any bug references. Thanks for review.

Nice! This is for non-ELF object file formats (https://discourse.llvm.org/t/llvm-symbolizer-has-gotten-extremely-slow/67262/29). It may be different from others' reports (primarily about ELF).

I guess I missed most of the context on discord thread. I saw this issue on Darwin CI and did some investigation while try to find any bug references. Thanks for review.

It was really bad on linux and mac. There was a previous fix that helped a little for linux, but it's still much slower than it used to be

jhenderson added inline comments.
llvm/lib/Object/SymbolSize.cpp
89

Post commit nit "using" -> "use"

steven_wu added inline comments.Jul 31 2023, 8:47 AM
llvm/lib/Object/SymbolSize.cpp
89

Fixed. Thanks!

Aha, I was wondering if this patch is going to be back ported to clang-17.
It was in https://github.com/llvm/llvm-project/commit/e96c444fd725661e6273d1708dfd10f2b6c3de6b