From 589ecda56eb23937ba871734598cda8f11395389 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sun, 8 Dec 2013 10:56:07 -0800 Subject: 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. --- Lib/subprocess.py | 2 +- Misc/NEWS | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 546a7a0..78e4fcf 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -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) diff --git a/Misc/NEWS b/Misc/NEWS index 0eac7fb..5eacf9c 100644 --- 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. -- cgit v0.12