bneradt commented on code in PR #12291: URL: https://github.com/apache/trafficserver/pull/12291#discussion_r2153174105
########## tests/gold_tests/autest-site/ports.py: ########## @@ -30,6 +31,72 @@ g_ports = None # ports we can use +class AsyncPortQueue(OrderedSetQueue): + + def __init__(self): + super().__init__() + self._listening_ports = _get_listening_ports() + + async def select_available(self, amount, dmin, dmax): + rmin = dmin - 2000 + rmax = 65536 - dmax + + port_tasks = [] + await asyncio.gather(*port_tasks) + if rmax > amount: + # Fill in ports, starting above the upper OS-usable port range. + port = dmax + 1 + while port < 65536 and self.qsize() < amount: + port_tasks.append(self._check_port(port)) + port += 1 + if rmin > amount and self.qsize() < amount: + port = 2001 + # Fill in more ports, starting at 2001, well above well known ports, + # and going up until the minimum port range used by the OS. + while port < dmin and self.qsize() < amount: + port_tasks.append(self._check_port(port)) + port += 1 + + await asyncio.gather(*port_tasks) Review Comment: I believe we're doing more port checks than originally here. On my system, this adds about 35k or so port_tasks values here, each of which are done even though we only need 1k. Originally, we we essentially short circuit the loop once `self.qsize()` reaches `amount` (1000). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@trafficserver.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org