homepage

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 neologix
Recipients neologix
Date 2011年03月03日.10:15:32
SpamBayes Score 2.965392e-07
Marked as misclassified No
Message-id <1299147333.52.0.465056224972.issue11382@psf.upfronthosting.co.za>
In-reply-to
Content
Some posix module functions unnecessarily release the GIL.
For example, posix_dup, posix_dup2 and posix_pipe all release the GIL, but those are non-blocking syscalls (the don't imply any I/O, only modifying the process file descriptors table).
This leads to the famous convoy effect (see http://bugs.python.org/issue7946).
For example:
$ cat /tmp/test_dup2.py 
import os
import threading
import sys
import time
def do_loop():
 while True:
 pass
t = threading.Thread(target=do_loop)
t.setDaemon(True)
t.start()
f = os.open(sys.argv[1], os.O_RDONLY)
for i in range(4, 1000):
 os.dup2(f, i)
Whith GIL release/acquire:
$ time ./python /tmp/test_dup2.py /etc/fstab 
real 0m5.238s
user 0m5.223s
sys 0m0.009s
$ time ./python /tmp/test_pipe.py 
real 0m3.083s
user 0m3.074s
sys 0m0.007s
Without GIL release/acquire:
$ time ./python /tmp/test_dup2.py /etc/fstab 
real 0m0.094s
user 0m0.077s
sys 0m0.010s
$ time ./python /tmp/test_pipe.py 
real 0m0.088s
user 0m0.074s
sys 0m0.008s
History
Date User Action Args
2011年03月03日 10:15:33neologixsetrecipients: + neologix
2011年03月03日 10:15:33neologixsetmessageid: <1299147333.52.0.465056224972.issue11382@psf.upfronthosting.co.za>
2011年03月03日 10:15:32neologixlinkissue11382 messages
2011年03月03日 10:15:32neologixcreate

AltStyle によって変換されたページ (->オリジナル) /