]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fixes issue #19929: Call os.read with 32768 within subprocess.Popen
authorGregory P. Smith <greg@krypto.org>
Sun, 8 Dec 2013 18:56:07 +0000 (10:56 -0800)
committerGregory P. Smith <greg@krypto.org>
Sun, 8 Dec 2013 18:56:07 +0000 (10:56 -0800)
communicate rather than 4096 for efficiency.  A microbenchmark shows
Linux and OS X both using ~50% less cpu time this way.

Lib/subprocess.py
Misc/NEWS

index 546a7a0fcda89d6963999bc25bda43c856a4e145..78e4fcfc596e2df6756a89227247a14ec09d4fd7 100644 (file)
@@ -1654,7 +1654,7 @@ class Popen(object):
                             if self._input_offset >= len(self._input):
                                 close_unregister_and_remove(fd)
                     elif mode & select_POLLIN_POLLPRI:
-                        data = os.read(fd, 4096)
+                        data = os.read(fd, 32768)
                         if not data:
                             close_unregister_and_remove(fd)
                         self._fd2output[fd].append(data)
index 0eac7fb2ad74e290080ab6223847673fd0224720..5eacf9c9a5900974c4e82449eecec3b73159c30b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -18,6 +18,10 @@ Core and Builtins
 Library
 -------
 
+- Issue #19929: Call os.read with 32768 within subprocess.Popen.communicate
+  rather than 4096 for efficiency.  A microbenchmark shows Linux and OS X
+  both using ~50% less cpu time this way.
+
 - Issue #19506: Use a memoryview to avoid a data copy when piping data
   to stdin within subprocess.Popen.communicate.  5-10% less cpu usage.