Skip to content

Commit a951e76

Browse files
authored
[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).
1 parent 0509659 commit a951e76

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def setUpServerLogging(self, is_llgs):
185185
]
186186

187187
def get_next_port(self):
188-
return 12000 + random.randint(0, 3999)
188+
return 12000 + random.randint(0, 7999)
189189

190190
def reset_test_sequence(self):
191191
self.test_sequence = GdbRemoteTestSequence(self.logger)
@@ -388,7 +388,8 @@ def connect_to_debug_monitor(self, attach_pid=None):
388388
# We're using a random port algorithm to try not to collide with other ports,
389389
# and retry a max # times.
390390
attempts = 0
391-
MAX_ATTEMPTS = 20
391+
MAX_ATTEMPTS = 10
392+
attempt_wait = 3
392393

393394
while attempts < MAX_ATTEMPTS:
394395
server = self.launch_debug_monitor(attach_pid=attach_pid)
@@ -424,7 +425,8 @@ def connect_to_debug_monitor(self, attach_pid=None):
424425

425426
# And wait a random length of time before next attempt, to avoid
426427
# collisions.
427-
time.sleep(random.randint(1, 5))
428+
time.sleep(attempt_wait)
429+
attempt_wait *= 1.2
428430

429431
# Now grab a new port number.
430432
self.port = self.get_next_port()

0 commit comments

Comments
 (0)