[Lldb-commits] [lldb] a951e76 - [lldb] Added an exponential algorithm for the sleep time in connect_to_debug_monitor() (#118222)

via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 2 08:51:48 PST 2024


Author: Dmitry Vasilyev
Date: 2024-12-02T20:51:44+04:00
New Revision: a951e76fbed642dbe3f51965d17ca566be586cc5

URL: https://github.com/llvm/llvm-project/commit/a951e76fbed642dbe3f51965d17ca566be586cc5
DIFF: https://github.com/llvm/llvm-project/commit/a951e76fbed642dbe3f51965d17ca566be586cc5.diff

LOG: [lldb] Added an exponential algorithm for the sleep time in connect_to_debug_monitor() (#118222)

Reduced MAX_ATTEMPTS to 10.
The sleep time will be 3, 3.6, 4.3, ..., 13, 15.
The total sleep time is 78 + 0.5 * MAX_CONNECT_ATTEMPTS * MAX_ATTEMPTS = 128.
Note the timeout is 600, so the rest time must be enough.
Increased the port range (12000..20000).

Added: 
    

Modified: 
    lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py

Removed: 
    


################################################################################
diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 8c8e4abed0b454..d6cb68f55bf296 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -185,7 +185,7 @@ def setUpServerLogging(self, is_llgs):
             ]
 
     def get_next_port(self):
-        return 12000 + random.randint(0, 3999)
+        return 12000 + random.randint(0, 7999)
 
     def reset_test_sequence(self):
         self.test_sequence = GdbRemoteTestSequence(self.logger)
@@ -388,7 +388,8 @@ def connect_to_debug_monitor(self, attach_pid=None):
         # We're using a random port algorithm to try not to collide with other ports,
         # and retry a max # times.
         attempts = 0
-        MAX_ATTEMPTS = 20
+        MAX_ATTEMPTS = 10
+        attempt_wait = 3
 
         while attempts < MAX_ATTEMPTS:
             server = self.launch_debug_monitor(attach_pid=attach_pid)
@@ -424,7 +425,8 @@ def connect_to_debug_monitor(self, attach_pid=None):
 
             # And wait a random length of time before next attempt, to avoid
             # collisions.
-            time.sleep(random.randint(1, 5))
+            time.sleep(attempt_wait)
+            attempt_wait *= 1.2
 
             # Now grab a new port number.
             self.port = self.get_next_port()


        


More information about the lldb-commits mailing list