unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-pretest-bug@gnu.org,
	Stephen Berman <Stephen.Berman@gmx.net>,
	emacs-devel@gnu.org
Subject: Re: 22.1.50; insert-file-contents is slow under tramp
Date: Sun, 26 Aug 2007 12:36:32 +0200	[thread overview]
Message-ID: <871wdqlgzz.fsf@gmx.de> (raw)
In-Reply-To: jwvwsvlt3ch.fsf-monnier+emacs@gnu.org

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Yes. I've installed a patch in the trunk, which makes a fast track for
>> "remote" files being on localhost.
>
> How does that work?  I mean when accessing files on the localhost with
> Tramp, the most likely situation I can think of is the `su' method so how
> what does your "fast track" do to transfer the file faster?  Does it copy it
> to /tmp at the "remote" end, then make it world-readable, then copy it on
> the "local" end, then remove it at the remote end?

Similar approach. It calls `tramp-do-copy-or-rename-file-directly',
which copies the "remote" file to /tmp, and assigns proper
permissions. Then `insert-file-contents' for the _local_ temporary file
is applied, which shows the file in the buffer, and the temporary file
is deleted.

>> For real remote hosts, I recommend to use scp when accessing huge files.
>
> Reminds me: where is the bottleneck in the inline method?  I mean
> fundamentally doing a base64 encoding/decoding shouldn't cost that much
> (negligible CPU-wise and a mere 33% in network transfer).  Maybe we could
> attack this part to improve performance?

I haven't investigated too much. mimencode and base64-decode are pretty
fast, even on my stone-age machine, with an 8MB sized file:

| (with-current-buffer (get-buffer-create "foo")
|   (elp-instrument-function 'call-process)
|   (elp-instrument-function 'base64-decode-region)
|   (erase-buffer)
|
|   (call-process "mimencode" nil t nil "/var/cache/apt/pkgcache.bin")
|   (base64-decode-region (point-min) (point-max))
|   (elp-results))
|
| Function Name         Call Count  Elapsed Time  Average Time
| ====================  ==========  ============  ============
| base64-decode-region  1           7.732203      7.732203
| call-process          1           1.917887      1.917887

But with the installed "fast track", it is remarkable faster than even
these two basic functions:

| (with-current-buffer (get-buffer-create "foo")
|   (elp-instrument-function 'insert-file-contents)
|   (erase-buffer)
|   (setq tramp-verbose 0)
|
|   ;; This opens the connection, including password handover etc
|   (file-attributes "/sudo::")
|
|   (insert-file-contents "/sudo::/var/cache/apt/pkgcache.bin")
|   (elp-results))
|
| Function Name         Call Count  Elapsed Time  Average Time
| ====================  ==========  ============  ============
| insert-file-contents  2           1.64688       0.82344

Without the fast track, the access time is inacceptable large. I suspect
that `tramp-wait-for-output' is the bottleneck, because it must check
for the resulting shell prompt, handle echoing shells, etc. I will
investigate next days whether there can be an improvement.

>         Stefan

Best regards, Michael.

  reply	other threads:[~2007-08-26 10:36 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-23 12:33 22.1.50; insert-file-contents is slow under tramp Stephen Berman
2007-08-23 14:25 ` martin rudalics
2007-08-23 15:02   ` Stephen Berman
2007-08-23 17:49     ` martin rudalics
2007-08-23 18:59       ` Stefan Monnier
2007-08-23 20:25         ` martin rudalics
2007-08-23 20:39           ` Stephen Berman
2007-08-23 21:01             ` martin rudalics
     [not found]             ` <46CDF5B7.2030201@g\x04mx.at>
2007-08-23 21:40               ` Stephen Berman
2007-08-24  5:34                 ` Michael Albinus
2007-08-24  7:18                   ` Stephen Berman
2007-08-24 14:32                   ` Stefan Monnier
2007-08-26 10:36                     ` Michael Albinus [this message]
2007-08-26 19:01                       ` David Kastrup
2007-08-26 19:24                         ` Michael Albinus
2007-08-27  4:16                       ` Stefan Monnier
2007-08-27 11:41                         ` Michael Albinus
2007-08-27 13:58                           ` Stefan Monnier
2007-08-27 14:09                             ` Thien-Thi Nguyen
2007-08-27 14:14                             ` David Kastrup
2007-08-27 14:53                             ` Michael Albinus
2007-08-27 20:11                               ` Stefan Monnier
2007-08-27 20:37                                 ` Michael Albinus
2007-08-27 10:52                     ` Michael Albinus
2007-08-27 11:33                       ` David Kastrup
2007-08-27 18:18                         ` Richard Stallman
2007-08-27 18:51                           ` David Kastrup
2007-08-24  9:28                 ` Eli Zaretskii
2007-08-24  9:35                   ` Stephen Berman
2007-08-24 16:10                 ` Richard Stallman

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=871wdqlgzz.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=Stephen.Berman@gmx.net \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-pretest-bug@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).