Page MenuHomePhabricator

Improve performance when parsing symbol tables in mach-o files.
ClosedPublic

Authored by clayborg on Jun 1 2021, 9:54 PM.

Details

Summary

Some larger projects were loading quite slowly with the current LLDB on macOS and macOS simulator builds. I did some instrument traces and found 3 main culprits:

  • a LLDB timer that was put into a function that was called too often
  • a std::set that was keeping track of the address of symbols that were already added
  • a unnamed function generator in ObjectFile that was going slow due to allocations

In order to see this in action I ran the latest LLDB on a large application with many frameworks using the following method:

(lldb) script import time; start_time = time.perf_counter()
(lldb) file Large.app
(lldb) script print(time.perf_counter() - start_time)

I first range "sudo purge" to clear the system file caches to simulate a cold startup of the debugger, followed by two iterations with warm file caches.

Prior to this fix I was seeing the following timings:

17.68 (cold)
14.56 (warm 1)
14.52 (warm 2)

After this fix I was seeing:

11.32 (cold)
8.43 (warm 1)
8.49 (warm 2)

Diff Detail

Event Timeline

clayborg created this revision.Jun 1 2021, 9:54 PM
clayborg requested review of this revision.Jun 1 2021, 9:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2021, 9:54 PM
shafik added a subscriber: shafik.Jun 2 2021, 9:47 AM
shafik added inline comments.
lldb/source/Symbol/ObjectFile.cpp
623

We should avoid potentially hiding side effects inside expressions or function calls, I would suggest moving the ++m_synthetic_symbol_idx before.

This revision is now accepted and ready to land.Jun 2 2021, 9:58 AM
This revision was landed with ongoing or failed builds.Jun 2 2021, 10:31 AM
This revision was automatically updated to reflect the committed changes.