This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dabeaz
Recipients DazWorrall, alex, brian.curtin, carljm, coderanger, dabeaz, eric.smith, flox, jhylton, karld, kevinwatters, loewis, mahmoudimus, pitrou, rcohen, rh0dium, tarek
Date 2010-03-15.14:21:00
SpamBayes Score 2.0059629e-08
Marked as misclassified No
Message-id <1268662863.3.0.65421349461.issue7946@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2010-03-15 14:21:03dabeazsetrecipients: + dabeaz, loewis, jhylton, pitrou, eric.smith, kevinwatters, tarek, karld, carljm, coderanger, alex, brian.curtin, flox, DazWorrall, rh0dium, rcohen, mahmoudimus
2010-03-15 14:21:03dabeazsetmessageid: <1268662863.3.0.65421349461.issue7946@psf.upfronthosting.co.za>
2010-03-15 14:21:01dabeazlinkissue7946 messages
2010-03-15 14:21:00dabeazcreate