[issue34535] queue.Queue(timeout=0.001) avg delay Windows:14.5ms, Ubuntu: 0.063ms
New submission from Paul Overing : I have found that using timeout with a python queue.Queue() results in an average delay of 14.5ms in Windows over Ubuntu in python 3.6.5/3.7, I subtracted the 1 ms timeout. I have also tried datetime.datetime.now() to measure the time, with similar results. Does that make sense? import queue import time max=0 min=1 num = 1 sum = 0 for x in range(1): q = queue.Queue() start = time.perf_counter() try: msg = q.get(block=True, timeout=.001) except: end = time.perf_counter() chng = end-start -.001 if chng > max: max = chng if chng < min: min = chng sum = sum + chng print(f"Avg: {sum/num}") print(f"Min: {min}") print(f"Max: {max}") Results: Window 10, Python 3.6.5/3.7 Avg: 0.014549868429997701 Min: 0.00167414200046 Max: 0.1389025150284 Ubuntu 16.04, Python 3.6.5/3.7 Avg: 6.275181290839012e-05 Min: 4.89290034456644e-05 Max: 8.690999695681965e-05 -- components: Windows messages: 324277 nosy: Gammaguy, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: queue.Queue(timeout=0.001) avg delay Windows:14.5ms, Ubuntu: 0.063ms type: performance versions: Python 3.6, Python 3.7 ___ Python tracker <https://bugs.python.org/issue34535> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34535] queue.Queue(timeout=0.001) avg delay Windows:14.5ms, Ubuntu: 0.063ms
Paul Overing added the comment: Thank you for your quick response. But 1ms resolution or not, 14.5ms does not seem reasonable given that in Ubuntu it is 0.049ms. Ubuntu is on average 295x faster. Also the variability in times is much higher in Windows max/avg = 9.547, avg/min = 8.69. It makes the windows queue.Queue implementations with timeouts unusable in low latency environments and should be documented as such. As it is slow and highly variable. -- ___ Python tracker <https://bugs.python.org/issue34535> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34535] queue.Queue(timeout=0.001) avg delay Windows:14.5ms, Ubuntu: 0.063ms
Paul Overing added the comment: Thank you to everyone for looking at my issue esp Josh.r for the detailed response. I now understand the issue and I just wanted to bring it to the group's attention for everyone's benefit. Vstinner is correct; Linux is my solution as it is my production environment but I was using my windows laptop for dev as I've been doing frequent Asia trips lately and noticed the difference. -- ___ Python tracker <https://bugs.python.org/issue34535> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com