Patchwork [3,of,3,side-word,(+4)] sshpeer: run the ssh command unbuffered

login
register
mail settings
Submitter Pierre-Yves David
Date May 31, 2015, 7:22 a.m.
Message ID <82bd796ea9d045312aa8.1433056954@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9409/
State Accepted
Commit c88975a4d2643009a94a12f1e37604712a9d13ee
Headers show

Comments

Pierre-Yves David - May 31, 2015, 7:22 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1432139498 18000
#      Wed May 20 11:31:38 2015 -0500
# Node ID 82bd796ea9d045312aa80b1cdcf3894dfcae6239
# Parent  72344e96acd26c68121d747aeb77fb8e1f9a75e8
sshpeer: run the ssh command unbuffered

This is necessary to use non-blocking IO base on polling. Such polling is
needed to restore real time output with ssh peer.

Changeset fce065538bcf is talking about 5x regression on Mac OS X when playing
with this value. So we introduced our own buffering layer in previous
changesets. This seems to keep the regression away (we are even issuing much
less read).

Patch

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -85,11 +85,16 @@  class sshpeer(wireproto.wirepeer):
         self.ui.debug('running %s\n' % cmd)
         cmd = util.quotecommand(cmd)
 
         # while self.subprocess isn't used, having it allows the subprocess to
         # to clean up correctly later
-        self.pipeo, self.pipei, self.pipee, self.subprocess = util.popen4(cmd)
+        #
+        # no buffer allow the use of 'select'
+        # feel free to remove buffering and select usage when we ultimately
+        # move to threading.
+        sub = util.popen4(cmd, bufsize=0)
+        self.pipeo, self.pipei, self.pipee, self.subprocess = sub
 
         self.pipei = util.bufferedinputpipe(self.pipei)
 
         # skip any noise generated by remote shell
         self._callstream("hello")