-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Windows] speedup connections #1679
Conversation
@mlabonte I am benchmarking this PR with: import psutil, socket, time
ls = []
for x in range(5000):
s = socket.socket()
s.bind(('127.0.0.1', 0))
s.listen(4)
ls.append(s)
t = time.time()
for x in range(100):
psutil.net_connections('tcp')
print(time.time() - t)
[x.close() for x in ls] The results I get are worse than #1676. Without patch I get |
I cannot understand, I did the same on my workspace and 1679 is slighly faster than 1676. I even found one case where it's definively faster but still, I have no idea why as both PR do the same operations. (pr1679) $ python -m timeit "import psutil; psutil.Process().connections(kind='tcp')" (pr1676) $ python -m timeit "import psutil; psutil.Process().connections(kind='tcp')" Maybe the second call is faster than the first in the case of IPv6. |
Can you get similar results as #1676 (comment)? This one:
...looks too big of a speedup. Are you sure you were measuring the right thing? |
Yes, I get similar results comparing master to 1679. It's a particular case: from approx. 9 K conxs, if the rate of new connections is big enough, the size of the table was always bigger than the previous call so we were stuck in the loop. I could get a single call blocked for minutes with ramping up to 60 K connections. |
Whatever measure I try I always get around 10% speedup. Anyway, it's fine. Merging. |
Thanks for merging this! :-) Do you have an ETA to release it in pypi? |
...a variant of #1676.