Lldb's po is really slow all over the sudden

Hello all,

What are the factors that might influence the amount of time po takes to execute? Where should I look into? It started to be really slow (~30-45 seconds). I'm guessing the number of frameworks and their types count/complexity might influence this, but hopefully not at that level. What other things?

Any insights re this would be really helpful!

CC @Adrian_Prantl

Swift 4.1/Xcode 9.4.x or Xcode 10 and it is even slower than in Xcode 9?

CC @Jim_Ingham
Can you elaborate what tools you are using? Which version of swift/lldb are you comparing with another, or was it your code that changed that made you notice the slowdown?

Generally there are two big sources for po slowness: (Assuming this is on macOS) If you "sample" lldb-rpc-server while it's working, do you see lots of time spent in functions that have JIT in the name, or do you see lots of functions with Clang in the name. In the former case you are seeing a known issue where LLDB is doing a lot of work to ingest static archives. In the latter case what you are seeing is Clang module cache being populated. Does this happen only the first time, or are subsequent po commands just as slow?

Speaking for myself, using Xcode 9.4, it is extremely slow the first time and fast afterwards. Though this has been a problem since at least Xcode 9.0 for us.

Alongside compilation time, degradation of po performance is another of the things that kind of makes the experience a bit miffed.

Hey Adrian,
having this issue here. When I sample lldb-rpc-server, I see ~1900 functions with Clang in the name. It happens in every new debugging session, but only the first time. Subsequent po commands are pretty fast.
What would be a solution to this?

When it is slow the first time only then what you are seeing is LLDB populating its Clang module cache. We recently made a couple of improvements that will make it more likely that LLDB can reuse the module cache built during compile time. You can try this out using a nightly beta from swift.org (be sure to set the language to Swift 4.2), but not all of these changes have made it into Xcode at this point in time.

sounds good, thanks, I'll give it a try!