Subject: 25.2.50; Emacs slow opening files via sshfs

From: Frank Winklmeier <[email-masked]>
Date: Wed, 2 Aug 2017 10:31:33 +0200

Switching from

GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
  of 2016-04-17 on lgw01-04, modified by Debian

to

In GNU Emacs 25.2.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
  of 2017-07-03 built on lcy01-14

I noticed that opening files via an sshfs mounted remote has gotten 
extremely slow (about 10 seconds vs 2 seconds for opening the same 
file). If it helps, here are some straces showing that the time is spent 
in read calls:

strace -CrTw emacs24 -nw -Q /path/to/my/sshfs/file.txt

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
  63.55    1.578241      263040         6           pselect6
  23.11    0.574017        1232       466         1 read
  10.39    0.258128        2607        99        77 faccessat
   1.51    0.037418         411        91        51 stat
   0.55    0.013633          14       972       806 open
   0.17    0.004245          25       167       166 readlinkat

strace -CrTw emacs25 -nw -Q /path/to/my/sshfs/file.txt

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
  83.43    8.913163       16475       541         1 read
  13.76    1.470122      183765         8           pselect6
   2.19    0.233506        1962       119        88 faccessat
   0.21    0.022881          13      1730      1520 open
   0.16    0.016923          83       205       204 readlinkat

Please let me know if other information is useful to debug this.

Windowing system distributor 'The X.Org Foundation', version 11.0.11804000
System Description:	Ubuntu 16.04.2 LTS

Configured using:
  'configure --build=x86_64-linux-gnu --prefix=/usr
  '--includedir=${prefix}/include' '--mandir=${prefix}/share/man'
  '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var
  --disable-silent-rules '--libdir=${prefix}/lib/x86_64-linux-gnu'
  '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode
  --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib
  --program-suffix=25 --with-modules=yes --with-x=yes
  --with-x-toolkit=gtk3 --with-xwidgets=yes 'CFLAGS=-g -O2
  -fstack-protector-strong -Wformat -Werror=format-security'
  'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2'
  'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES XWIDGETS

Important settings:
   value of $LC_MONETARY: en_GB.UTF-8
   value of $LC_NUMERIC: en_GB.UTF-8
   value of $LC_TIME: en_GB.UTF-8
   value of $LANG: en_US.UTF-8
   value of $XMODIFIERS: @im=ibus
   locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
   global-company-mode: t
   pyvenv-mode: t
   shell-dirtrack-mode: t
   recentf-mode: t
   tooltip-mode: t
   global-eldoc-mode: t
   electric-indent-mode: t
   mouse-wheel-mode: t
   tool-bar-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   blink-cursor-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   buffer-read-only: t
   line-number-mode: t
   transient-mark-mode: t

Recent messages:
Loading /home/fwinkl/.recentf...done
Cleaning up the recentf list...done (0 removed)
Company backend ’company-ropemacs’ could not be initialized:
Symbol’s function definition is void: company-ropemacs
For information about GNU Emacs and the GNU system, type C-h C-a.
Note: file is write protected
View mode: type C-h for help, h for commands, q to quit.
Mark saved where search started [5 times]
Making completion list...

Load-path shadows:
/usr/share/emacs/site-lisp/dictionaries-common/flyspell hides 
/usr/share/emacs/25.2.50/lisp/textmodes/flyspell
/usr/share/emacs/site-lisp/dictionaries-common/ispell hides 
/usr/share/emacs/25.2.50/lisp/textmodes/ispell

Features:
(shadow sort mail-extr emacsbug message dired rfc822 mml mml-sec epg
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mail-utils misearch
multi-isearch goto-addr thingatpt noutline outline easy-mmode view
vc-dispatcher vc-svn cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs company-files
company-oddmuse company-keywords company-etags company-gtags
company-dabbrev-code company-dabbrev company-capf company-cmake
company-semantic company-eclim company-template company-css company-nxml
company-bbdb flymake company elpy pyvenv elpy-refactor python tramp-sh
tramp tramp-compat auth-source gnus-util mm-util help-fns mail-prsvr
password-cache tramp-loaddefs trampver ucs-normalize shell pcomplete
format-spec advice json map ido grep compile comint ansi-color files-x
etags xref cl-seq project eieio eieio-core cl-macs ring cus-edit
cus-start cus-load finder-inf info tex-site package epg-config seq
byte-opt gv bytecomp byte-compile cl-extra help-mode cconv edmacro
kmacro recentf tree-widget wid-edit cl-loaddefs pcase cl-lib easymenu
time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel x-win term/common-win x-dnd tool-bar dnd fontset
image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese charscript case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote dbusbind inotify dynamic-setting
system-font-setting font-render-setting xwidget-internal move-toolbar
gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 364676 12088)
  (symbols 48 34067 0)
  (miscs 40 767 228)
  (strings 32 70715 9792)
  (string-bytes 1 2115980)
  (vectors 16 51409)
  (vector-slots 8 895437 7532)
  (floats 8 324 144)
  (intervals 56 340 0)
  (buffers 976 19)
  (heap 1024 38850 1495))