[Lldb-commits] [PATCH] D98272: [lldb/Platform] Skip very slow xcrun queries for simulator platforms, NFC

Vedant Kumar via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 9 10:53:24 PST 2021


vsk created this revision.
vsk added reviewers: aprantl, JDevlieghere.
vsk requested review of this revision.
Herald added a project: LLDB.

GetXcodeSDK() consistently takes over 1 second to complete if the
queried SDK is missing, because `xcrun` doesn't cache negative lookups.

Because there are multiple simulator platforms, this can add 4+ seconds
to `lldb -b some_object_file.o`.

To work around this, skip the call to GetXcodeSDK() when setting up
simulator platforms if the specified arch doesn't have what looks like a
simulator triple.

Some other ways to fix this:

- Fix caching in xcrun (rdar://74882205)
- Test for arch compat before calling SomePlatform::CreateInstance() (much larger change)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98272

Files:
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp


Index: lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -530,6 +530,8 @@
   }
 
   static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
+    if (arch && arch->IsValid() && !arch->TripleEnvironmentWasSpecified())
+      return nullptr; // Avoid very slow xcrun query for non-simulator archs.
     llvm::StringRef sdk;
     sdk = HostInfo::GetXcodeSDKPath(XcodeSDK("iPhoneSimulator.Internal.sdk"));
     if (sdk.empty())
@@ -578,6 +580,8 @@
   }
 
   static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
+    if (arch && arch->IsValid() && !arch->TripleEnvironmentWasSpecified())
+      return nullptr; // Avoid very slow xcrun query for non-simulator archs.
     return PlatformAppleSimulator::CreateInstance(
         "PlatformAppleTVSimulator", g_tvos_description,
         ConstString(g_tvos_plugin_name),
@@ -619,6 +623,8 @@
   }
 
   static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
+    if (arch && arch->IsValid() && !arch->TripleEnvironmentWasSpecified())
+      return nullptr; // Avoid very slow xcrun query for non-simulator archs.
     return PlatformAppleSimulator::CreateInstance(
         "PlatformAppleWatchSimulator", g_watchos_description,
         ConstString(g_watchos_plugin_name),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98272.329394.patch
Type: text/x-patch
Size: 1473 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210309/28be0885/attachment.bin>


More information about the lldb-commits mailing list