kastiglione created this revision.
kastiglione added reviewers: JDevlieghere, mib.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

While investigation slow tests, I looked into why `TestMultithreaded.py`. One
of the reasons is that it determines the architecture of lldb by running:

  lldb -o 'file path/to/lldb' -o 'quit'

On my fairly fast machine, this takes 24 seconds, and `TestMultithreaded.py`
calls this function 4 times.

With this change, this command now takes less than 0.2s on the same machine.

The reason it's slow is symbol table and debug info loading, as indicated by
the new progress events printed to the console. One setting reduced the time in
half:

  settings set target.preload-symbols false

Further investigation, by profiling with Instruments on macOS, showed that
loading time was also caused by looking for scripts. The setting that
eliminates this time is:

  settings set target.load-script-from-symbol-file false


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132803

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1255,21 +1255,23 @@
         """Returns the architecture of the lldb binary."""
         if not hasattr(self, 'lldbArchitecture'):
 
-            # spawn local process
+            # These two target settings prevent lldb from doing setup that does
+            # nothing but slow down the end goal of printing the architecture.
             command = [
                 lldbtest_config.lldbExec,
-                "-o",
-                "file " + lldbtest_config.lldbExec,
-                "-o",
-                "quit"
+                "-x",
+                "-b",
+                "-o", "settings set target.preload-symbols false",
+                "-o", "settings set target.load-script-from-symbol-file false",
+                "-o", "file " + lldbtest_config.lldbExec,
             ]
 
             output = check_output(command)
-            str = output.decode("utf-8")
+            str = output.decode()
 
             for line in str.splitlines():
                 m = re.search(
-                    "Current executable set to '.*' \\((.*)\\)\\.", line)
+                    r"Current executable set to '.*' \((.*)\)\.", line)
                 if m:
                     self.lldbArchitecture = m.group(1)
                     break


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1255,21 +1255,23 @@
         """Returns the architecture of the lldb binary."""
         if not hasattr(self, 'lldbArchitecture'):
 
-            # spawn local process
+            # These two target settings prevent lldb from doing setup that does
+            # nothing but slow down the end goal of printing the architecture.
             command = [
                 lldbtest_config.lldbExec,
-                "-o",
-                "file " + lldbtest_config.lldbExec,
-                "-o",
-                "quit"
+                "-x",
+                "-b",
+                "-o", "settings set target.preload-symbols false",
+                "-o", "settings set target.load-script-from-symbol-file false",
+                "-o", "file " + lldbtest_config.lldbExec,
             ]
 
             output = check_output(command)
-            str = output.decode("utf-8")
+            str = output.decode()
 
             for line in str.splitlines():
                 m = re.search(
-                    "Current executable set to '.*' \\((.*)\\)\\.", line)
+                    r"Current executable set to '.*' \((.*)\)\.", line)
                 if m:
                     self.lldbArchitecture = m.group(1)
                     break
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to