git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Karl Wiberg <kha@virtutech.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: mandolaerik@gmail.com, git@vger.kernel.org
Subject: [PATCH] Work around performance bug in subprocess.Popen.communicate()
Date: Fri, 31 Jul 2009 11:36:32 +0200	[thread overview]
Message-ID: <20090731093632.7018.24435.stgit@october.e.vtech> (raw)

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))

             reply	other threads:[~2009-07-31 10:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-31  9:36 Karl Wiberg [this message]
2009-07-31 11:27 ` [PATCH] Work around performance bug in subprocess.Popen.communicate() 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090731093632.7018.24435.stgit@october.e.vtech \
    --to=kha@virtutech.com \
    --cc=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=mandolaerik@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).