git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Work around performance bug in subprocess.Popen.communicate()
@ 2009-07-31  9:36 Karl Wiberg
  2009-07-31 11:27 ` Catalin Marinas
  0 siblings, 1 reply; 7+ messages in thread
From: Karl Wiberg @ 2009-07-31  9:36 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: mandolaerik, git

From: Karl Wiberg <kha@treskal.com>

In Python 2.4 (specifically, I tested with 2.4.6 on Ubuntu 9.04),
subprocess.Popen.communicate() seems to take time proportional to the
square of the size of the indata, which makes it ridiculously
expensive to write stack log entries when the diffs are large. Work
around the bug by calling subprocess.Popen.stdin.write() manually
instead of letting communicate() handle the indata.

The performance bug has been fixed in Python 2.6 (I tested with
2.6.2), so with that version this workaround doesn't affect the run
time. I haven't tested with Python 2.5.

This fixes bug 13319.

Signed-off-by: Karl Wiberg <kha@treskal.com>

---

 stgit/run.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)


diff --git a/stgit/run.py b/stgit/run.py
index 7493ed3..311d12f 100644
--- a/stgit/run.py
+++ b/stgit/run.py
@@ -110,7 +110,9 @@ class Run:
                                  stdin = subprocess.PIPE,
                                  stdout = subprocess.PIPE,
                                  stderr = subprocess.PIPE)
-            outdata, errdata = p.communicate(self.__indata)
+            if self.__indata:
+                p.stdin.write(self.__indata)
+            outdata, errdata = p.communicate()
             self.exitcode = p.returncode
         except OSError, e:
             raise self.exc('%s failed: %s' % (self.__cmd[0], e))

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-08-14  8:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-31  9:36 [PATCH] Work around performance bug in subprocess.Popen.communicate() Karl Wiberg
2009-07-31 11:27 ` Catalin Marinas
2009-08-04  8:51   ` Karl Wiberg
2009-08-13 22:18     ` Catalin Marinas
2009-08-14  6:21       ` Karl Wiberg
2009-08-14  7:26         ` Erik Sandberg
2009-08-14  8:12           ` Karl Wiberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).