From: Suhail Singh <suhailsingh247@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: michael.albinus@gmx.de, Suhail Singh <suhailsingh247@gmail.com>,
73046@debbugs.gnu.org
Subject: bug#73046: 29.4; Emacs 100% CPU usage for several seconds when opening dired buffer over TRAMP
Date: Fri, 06 Sep 2024 20:19:34 -0400 [thread overview]
Message-ID: <87h6asl3hl.fsf@gmail.com> (raw)
In-Reply-To: <8634mc1ty0.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 06 Sep 2024 22:08:23 +0300")
Eli Zaretskii <eliz@gnu.org> writes:
> So if it takes 4 to 5 sec to move a 20KB file, then how much stuff
> needs to be moved for the Dired listing? What does the below show, if
> you run it on that remote machine?
>
> $ ls -al | wc
Given that the contents of the remote directory can be exactly
replicated (apart from metadata such as mtime etc) by the below code
(that I shared in another response), you should be able to answer the
question trivially:
#+name: perf-fix/tramp/font-lock-on-dired/reproducer
#+begin_src sh
cd /tmp
rm -rf /tmp/test
mkdir /tmp/test
cd /tmp/test
for i in `seq -w 0 21`; do
mkdir -p src/"$i"
done
mkdir -p links
cd links
for i in `seq -w 0 21`; do
ln -sf /tmp/test/src/"$i"
done
#+end_src
For the record, the output is as follows:
#+begin_src sh :dir /ssh:${affected-host}:/tmp
cd /tmp/test/links
ls -al | wc
#+end_src
#+RESULTS:
: 25 262 1599
> It needs to show around 40KB to explain 10 sec of delay.
I don't understand your reasoning. In fact if the output of ls -al was
indeed around 40kb I would have been very surprised. The time taken for
transferring the 20KB file included initial connection costs whereas
TRAMP would presumably be reusing the same connection, but would be
sending multiple small requests. I don't see how one can be compared to
the other, other than to say (generally) that when connection is slow
both workflows would take greater time (which is what we observe).
Note that disabling font-lock improved response delay considerably.
That means the delay is not due to transferring information contained in
`ls --dired', which is considerably fast (relatively speaking), but in
doing the additional checks that Michael mentioned:
>>> It seems to be related to font-locking, indeed. See variable
>>> `dired-font-lock-keywords'. It specifies face recognition running basic
>>> file oprtations. For example, ";; Broken Symbolic link" calls
>>> `file-truename' and `file-exists-p', while "Symbolic link to a directory"
>>> and ";; Symbolic link to a non-directory" invoke `file-truename' and
>>> `file-directory-p'.
I did some further investigation; summarizing findings below:
A. On Host-A, the network connection is fairly slow s.t. transferring a
20KB file takes ~5s. On Host-B, the network connection is fairly
fast.
B. On Host-A, the time taken to refresh dired buffer containing 22
Subdirectories (/tmp/test/src as in above code snippet) is 0.70-0.75s
with font-lock enabled, and about the same with font-lock disabled.
These times exclude the time taken to establish the intiial
connection over TRAMP.
C. On Host-A, the time taken to refresh dired buffer containing 22
symlinks (each symlink pointing to a directory, i.e., /tmp/test/links
in the above code snippet) is 0.70-0.75s with font-lock disabled.
With font-lock enabled the time taken is ~13-14s and the CPU is at
100%. These times exclude the time taken to establish the intiial
connection over TRAMP.
D. On Host-B, the time taken to display dired buffer for /tmp/test/links
with font-lock enabled is ~2s greater than when font-lock is
disabled. When /tmp/test/links contains 100 symlinks to directories
(instead of 22), the time taken when font-lock is enabled is ~6s
greater than when font-lock is disabled.
Given above, I conclude:
1. The issue is present when there are symlinks to directories.
2. The issue is worse when there are greater number of symlinks to
directories.
2. The issue is worse when the connection is slower. However, it is
still observable when the connection is faster - if you're having
difficulty reproducing, increase the number of symlinks to
directories in /tmp/test/links above.
3. Given that when connection is slower, not only is the time taken for
font-locking greater, but the CPU is at 100%, I suspect that the
relevant code is doing some kind of busy-waiting.
The above observations seem consistent with Michael's comments above
regd. font-lock checks for "Broken Symbolink link" and "Symbolic link to
a directory". As such, if Michael's proposal below is implemented I
believe it would be an adequate fix to the issue:
>>> I believe it would be helpful to suppress these checks via a user
>>> option. And no, the checks shouldn't be suppressed for remote
>>> directories in general, on a fast connection they are valuable.
I hope that clarifies things, and gives you sufficient information to be
able to reproduce
--
Suhail
next prev parent reply other threads:[~2024-09-07 0:19 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-05 14:24 bug#73046: 29.4; Emacs 100% CPU usage for several seconds when opening dired buffer over TRAMP Suhail Singh
2024-09-05 15:56 ` Eli Zaretskii
2024-09-05 21:04 ` Suhail Singh
2024-09-06 5:40 ` Eli Zaretskii
2024-09-06 13:23 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-06 13:54 ` Eli Zaretskii
2024-09-06 14:09 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-06 16:09 ` Eli Zaretskii
2024-09-06 17:47 ` Suhail Singh
2024-09-06 19:08 ` Eli Zaretskii
2024-09-07 0:19 ` Suhail Singh [this message]
2024-09-07 1:39 ` Suhail Singh
2024-09-07 6:29 ` Eli Zaretskii
2024-09-07 8:07 ` Suhail Singh
2024-09-07 14:36 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-07 15:07 ` Eli Zaretskii
2024-09-07 17:35 ` Suhail Singh
2024-09-08 11:30 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-08 11:47 ` Eli Zaretskii
2024-09-08 15:26 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-08 15:41 ` Eli Zaretskii
2024-09-08 16:46 ` Suhail Singh
2024-09-08 17:53 ` Eli Zaretskii
2024-09-10 8:10 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-11 1:05 ` Suhail Singh
2024-09-11 11:50 ` Eli Zaretskii
2024-09-11 16:29 ` Suhail Singh
2024-09-11 16:38 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-11 17:25 ` Suhail Singh
2024-09-12 11:48 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-11 14:13 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-11 15:56 ` Suhail Singh
2024-09-13 23:17 ` Suhail Singh
2024-09-14 6:24 ` Eli Zaretskii
2024-09-14 14:25 ` Suhail Singh
2024-09-14 14:41 ` Suhail Singh
2024-09-14 15:03 ` Eli Zaretskii
2024-09-14 22:36 ` Suhail Singh
2024-09-15 5:55 ` Eli Zaretskii
2024-09-15 14:23 ` Suhail Singh
2024-09-14 7:07 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-14 14:39 ` Suhail Singh
2024-09-11 14:06 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-07 14:22 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-07 17:58 ` Suhail Singh
2024-09-08 11:26 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-08 15:09 ` Suhail Singh
2024-09-08 15:19 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-08 15:34 ` Suhail Singh
2024-09-08 16:35 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-11 16:19 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-06 16:56 ` Suhail Singh
2024-09-06 16:01 ` Suhail Singh
2024-09-06 15:46 ` Suhail Singh
2024-09-06 15:52 ` Suhail Singh
[not found] <87v7yz1sw8.fsf@rutgers.edu>
2024-09-13 15:47 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
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=87h6asl3hl.fsf@gmail.com \
--to=suhailsingh247@gmail.com \
--cc=73046@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=michael.albinus@gmx.de \
/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).