Commit 7b83b186 authored by Gregory P. Smith's avatar Gregory P. Smith

Fixes 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.
parents bd6932a5 589ecda5
...@@ -1601,7 +1601,7 @@ class Popen(object): ...@@ -1601,7 +1601,7 @@ class Popen(object):
selector.unregister(key.fileobj) selector.unregister(key.fileobj)
key.fileobj.close() key.fileobj.close()
elif key.fileobj in (self.stdout, self.stderr): elif key.fileobj in (self.stdout, self.stderr):
data = os.read(key.fd, 4096) data = os.read(key.fd, 32768)
if not data: if not data:
selector.unregister(key.fileobj) selector.unregister(key.fileobj)
key.fileobj.close() key.fileobj.close()
......
...@@ -24,6 +24,10 @@ Library ...@@ -24,6 +24,10 @@ Library
- Issue #19343: Expose FreeBSD-specific APIs in resource module. Original - Issue #19343: Expose FreeBSD-specific APIs in resource module. Original
patch by Koobs. patch by Koobs.
- 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 - Issue #19506: Use a memoryview to avoid a data copy when piping data
to stdin within subprocess.Popen.communicate. 5-10% less cpu usage. to stdin within subprocess.Popen.communicate. 5-10% less cpu usage.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment