Hi,

Sometime I'm working from home with a good Internet connexion.  Still,
going throught the VPN generates huge latencies to access the different
machines I'm working on.

Running a grep over tramp command takes more than 30 seconds so I
investigated a little bit today.  I found out that file properties has a
cache that I could use by customizing the
`remote-file-name-inhibit-cache' variable.  Its makes me save a bit more
than 10 seconds (according to ELP).

I had still to pay more than 20 seconds to get a grep result while in
the meantime from the console it takes less than 2 seconds ... I can
afford to wait a little more than using a console because it's more
convenient using Emacs but not that much.

I investigated a little bit more and figured out that a lot of shell
commands are sent especially to set environment variables.  I've
gathered these set variable commands in two commands and according to
ELP I've saved another 12 seconds.  Now running grep from Emacs over
tramp gets me result in less than 10 seconds which become acceptable.

I've joined the patch I've made, could you please review it (merge it
?).

I have a question too: is there a way to use a "persistent" tramp
connexion to run commands ?

Thanks,

Jérémy

-- 
One Emacs to rule them all
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
>From 4a8437d5c7a503f19dc11d4dbe738e501c4058f0 Mon Sep 17 00:00:00 2001
From: Jeremy Compostella <[email protected]>
Date: Sun, 12 Oct 2014 20:40:27 +0200
Subject: [PATCH] * tramp.sh.el:
 (tramp-open-connection-setup-interactive-shell): Reduce the amount of set
 environment variable commands

When the latency to the server is important, each shell command to set
a unique environment variable is painful.

This patch gathers the PS[1-3] and PROMPT_COMMAND variables and all
the variables defined in `tramp-remote-process-environment' in two
shell commands.
---
 lisp/tramp-sh.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lisp/tramp-sh.el b/lisp/tramp-sh.el
index a01d173..7f5dabd 100644
--- a/lisp/tramp-sh.el
+++ b/lisp/tramp-sh.el
@@ -3955,10 +3955,8 @@ process to set up.  VEC specifies the connection."
 
   (tramp-message vec 5 "Setting shell prompt")
   (tramp-send-command
-   vec (format "PS1=%s" (tramp-shell-quote-argument tramp-end-of-output)) t)
-  (tramp-send-command vec "PS2=''" t)
-  (tramp-send-command vec "PS3=''" t)
-  (tramp-send-command vec "PROMPT_COMMAND=''" t)
+   vec (format "PS1=%s PS2='' PS3='' PROMPT_COMMAND=''"
+	       (tramp-shell-quote-argument tramp-end-of-output)) t)
 
   ;; Try to set up the coding system correctly.
   ;; CCC this can't be the right way to do it.  Hm.
@@ -4078,15 +4076,17 @@ process to set up.  VEC specifies the connection."
   (let ((env (append (when (tramp-get-remote-locale vec) ; Discard `(nil)'.
 		       `(,(tramp-get-remote-locale vec)))
 		     (copy-sequence tramp-remote-process-environment)))
-	unset item)
+	unset vars item)
     (while env
       (setq item (tramp-compat-split-string (car env) "="))
       (setcdr item (mapconcat 'identity (cdr item) "="))
       (if (and (stringp (cdr item)) (not (string-equal (cdr item) "")))
-	  (tramp-send-command
-	   vec (format "%s=%s; export %s" (car item) (cdr item) (car item)) t)
+	  (push (format "%s=%s; export %s" (car item) (cdr item) (car item)) vars)
 	(push (car item) unset))
       (setq env (cdr env)))
+    (when vars
+      (tramp-send-command
+       vec (mapconcat 'identity vars " ; ")))
     (when unset
       (tramp-send-command
        vec (format "unset %s" (mapconcat 'identity unset " ")) t))))
-- 
1.9.1

_______________________________________________
Tramp-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/tramp-devel

Reply via email to