This is an archive of the discontinued LLVM Phabricator instance.

Create synthetic symbol names on demand to improve memory consumption and startup times.
ClosedPublic

Authored by clayborg on Jul 14 2021, 9:49 AM.

Details

Summary

This is a resubmission of https://reviews.llvm.org/D105160 after fixing testing issues.

This fix was created after profiling the target creation of a large C/C++/ObjC application that contained almost 4,000,000 redacted symbol names. The symbol table parsing code was creating names for each of these synthetic symbols and adding them to the name indexes. The code was also adding the object file basename to the end of the symbol name which doesn't allow symbols from different shared libraries to share the names in the constant string pool.

Prior to this fix this was creating 180MB of "___lldb_unnamed_symbol" symbol names and was taking a long time to generate each name, add them to the string pool and then add each of these names to the name index.

This patch fixes the issue by:

not adding a name to synthetic symbols at creation time, and allows name to be dynamically generated when accessed
doesn't add synthetic symbol names to the name indexes, but catches this special case as name lookup time. Users won't typically set breakpoints or lookup these synthetic names, but support was added to do the lookup in case it does happen
removes the object file baseanme from the generated names to allow the names to be shared in the constant string pool
Prior to this fix the startup times for a large application was:
12.5 seconds (cold file caches)
8.5 seconds (warm file caches)

After this fix:
9.7 seconds (cold file caches)
5.7 seconds (warm file caches)

The names of the symbols are auto generated by appending the symbol's UserID to the end of the "___lldb_unnamed_symbol" string and is only done when the name is requested from a synthetic symbol if it has no name.

Diff Detail

Event Timeline

clayborg created this revision.Jul 14 2021, 9:49 AM
clayborg requested review of this revision.Jul 14 2021, 9:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2021, 9:49 AM
Herald added a subscriber: MaskRay. · View Herald Transcript
clayborg added inline comments.Jul 14 2021, 9:52 AM
lldb/include/lldb/Symbol/Symbol.h
158

@JDevlieghere this was added to fix the failing tests that caused some bots to fail. Prior to this we were not adding any synthetic symbols to the name lookup tables, even if they didn't have names that started with "___lldb_unnamed_symbol"

lldb/source/Symbol/Symtab.cpp
306

@JDevlieghere this was added to fix the failing tests that caused some bots to fail. Prior to this we were not adding any synthetic symbols to the name lookup tables, even if they didn't have names that started with "___lldb_unnamed_symbol". This code used to be:

if (symbol->IsTrampoline() || symbol->IsSynthetic())

And it would leave out synthetic symbols with valid names, like form the dyld trie

JDevlieghere accepted this revision.Jul 14 2021, 9:55 AM

Thanks Greg! Assuming this passes on the bot this LGTM.

This revision is now accepted and ready to land.Jul 14 2021, 9:55 AM
wallace closed this revision.Sep 14 2021, 12:08 AM

This was commited by ec1a49170129d