Message101116
Here's a short benchmark for everyone who thinks that my original benchmark was somehow related to TCP behavior. This one doesn't even involve sockets:
from threading import Thread
import time
def writenums(f,n):
start = time.time()
for x in range(n):
f.write("%d\n" % x)
end = time.time()
print(end-start)
def spin():
while True:
pass
# Uncomment to add a thread
#t1 = Thread(target=spin)
#t1.daemon=True
#t1.start()
writenums(open("/tmp/nums","w"),1000000)
If I run this on my Macbook with no threads, it takes about 1.05 seconds. If the one spinning thread is turned on, the time jumps to about 4.5 seconds. What you're seeing is that the spinning thread unfairly hogs the CPU.
If I use my own patched version (new GIL with priorities), the threaded version drops back down to about 1.10 seconds. I have not tried it with Antoine's latest patch, but would expect similar results as he is also using priorities.
Just to be clear, this issue is not specific to sockets or TCP. |
|
Date |
User |
Action |
Args |
2010-03-15 14:21:03 | dabeaz | set | recipients:
+ dabeaz, loewis, jhylton, pitrou, eric.smith, kevinwatters, tarek, karld, carljm, coderanger, alex, brian.curtin, flox, DazWorrall, rh0dium, rcohen, mahmoudimus |
2010-03-15 14:21:03 | dabeaz | set | messageid: <1268662863.3.0.65421349461.issue7946@psf.upfronthosting.co.za> |
2010-03-15 14:21:01 | dabeaz | link | issue7946 messages |
2010-03-15 14:21:00 | dabeaz | create | |
|