From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Suhail Singh Newsgroups: gmane.emacs.bugs Subject: bug#73046: 29.4; Emacs 100% CPU usage for several seconds when opening dired buffer over TRAMP Date: Fri, 06 Sep 2024 12:56:26 -0400 Message-ID: <87o750g1qd.fsf@gmail.com> References: <87o75241qh.fsf@gmail.com> <86plpi2ixa.fsf@gnu.org> <87seudke20.fsf@gmail.com> <8634md2vc2.fsf@gnu.org> <87h6asrk42.fsf@gmx.de> <86a5gk28ht.fsf@gnu.org> <87le0450x8.fsf@gmx.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13190"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , suhailsingh247@gmail.com, 73046@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 06 18:58:20 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1smcHr-0003FK-N6 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 06 Sep 2024 18:58:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smcHc-0005zM-Gd; Fri, 06 Sep 2024 12:58:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smcHb-0005z7-A3 for bug-gnu-emacs@gnu.org; Fri, 06 Sep 2024 12:58:03 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smcHa-0006pm-Vs for bug-gnu-emacs@gnu.org; Fri, 06 Sep 2024 12:58:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=Zt7+76sfSm8pvGgTLzda3ORLbVa2QERCY8kd8JIRWFs=; b=nzjvtM2yeewqwfiPCs+YJBtgLpVSPZ+IHR1ev1dLWpZw62yvIzy+AeHqU/yy0vRZthsYZtVxLO1i2jwgPeNUHw0vTN7xfKl9xet9s60oe7LnBZvPKPGu7bWGoIN49cbKtM9iIYx8djHYRgm5DopWOwAioztln4bNoZoJgLw1zbOJi83g2CVyY/g/I3iNQmUqNV5uHIyWBNM+M+s5TP3latQyG979oXiipnUs10yRgAu55TqUQ1Tf04kCi7KisDzblOLGv3xplUoLFjr2/oTFCcIjq7M09Jp6u9Ulvy1dZITD5/xM3Svfj4wk/FqSGGkHPtB+XL56eS2OkB5HOWDWWw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1smcHa-0002uZ-98 for bug-gnu-emacs@gnu.org; Fri, 06 Sep 2024 12:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Suhail Singh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 06 Sep 2024 16:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73046 X-GNU-PR-Package: emacs Original-Received: via spool by 73046-submit@debbugs.gnu.org id=B73046.172564186511164 (code B ref 73046); Fri, 06 Sep 2024 16:58:02 +0000 Original-Received: (at 73046) by debbugs.gnu.org; 6 Sep 2024 16:57:45 +0000 Original-Received: from localhost ([127.0.0.1]:54100 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smcHJ-0002u0-Bn for submit@debbugs.gnu.org; Fri, 06 Sep 2024 12:57:45 -0400 Original-Received: from mail-qv1-f66.google.com ([209.85.219.66]:59823) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smcHH-0002th-6a for 73046@debbugs.gnu.org; Fri, 06 Sep 2024 12:57:43 -0400 Original-Received: by mail-qv1-f66.google.com with SMTP id 6a1803df08f44-6c35427935eso12551566d6.3 for <73046@debbugs.gnu.org>; Fri, 06 Sep 2024 09:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725641797; x=1726246597; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=Zt7+76sfSm8pvGgTLzda3ORLbVa2QERCY8kd8JIRWFs=; b=jaPKCo1L/d6sKIAuphQ1egKD1qgbG+cm+pVGjSgHYF4+nt0LPa9RRt9TVpLLkBRNKo hIkf18So6HCq/2Cla+wpQL0NwdAwank0nvX9kk+91xxw+uLwGXCJ6zSov66UaqJppyRH jdlWvSB4WzvgCWeZRJrqgOwu8SpdfgFYe1bwtulU0+HmqmjZEs74NTMUQO1kWe0vGbr9 AnyFryRLMilm7QGbo1BoivBLjIULR9QzN61mwRhC4akmOSuZB20Ijmz0oPF97O4GCu0O gSQVvJsLb23n7LuhARo3yswcC4ovFJ9hxm/b19OYqeA6+v4oYn2XsmbsXnNPSgGyA00f 291Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725641797; x=1726246597; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Zt7+76sfSm8pvGgTLzda3ORLbVa2QERCY8kd8JIRWFs=; b=WW6kUqprGqt9dxWmf1O2aniq+jF78Rw1Ujl0VayJX9AMFjfE+r/opilzLWkzomFRHh 7Oi4LmPuCwsp7/bWashroQaF6i9MDZ19pB1hl8rkeEH5wuJUl0UW1equt64680T4ZldY 3I6+2MpHj/rSqkYAyynHiIQi8CHdmUxVzD1lTC495fOTu2Uu/XhI2chGnyVymMUQ0K6Y naShNorEFOb3tPYXa+1pV3kBdQxuEB4CuiOMzKczDmVVq/bkJHSo4oprRdolSG3SGW/8 MHrhnzT6b+MV7ppR05cyuMGxdFnceQqA4LFVbr4W5Fbi3kN6PgQrznHACZNAIVs/mm9d ZggA== X-Forwarded-Encrypted: i=1; AJvYcCU2phH+iTNf0Sh+EE4irEw1hIhEg+9COU5/FUjV7zThQFJSBjEDy+/2MiZUTPYWJJCTg6912A==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yy2MEqJwa1FxNL4Iuyy8hzhRcVhsuIdQDG34CxVsLrV+27oO+0R R4igj9sXyfHw6R5i3xHYAAqWu9lLUWfuT6USn7OSMnjgEpZMJAJBIGRMpQDg X-Google-Smtp-Source: AGHT+IEUSKYajLyAsXGPJMcxZcWHs3hn7U8au4ZucoYzkyKrEzYg/4WRsXzF1tKu+OJJURfa5+35+w== X-Received: by 2002:ad4:44a1:0:b0:6c5:caa:dd83 with SMTP id 6a1803df08f44-6c52850bb7fmr33905266d6.41.1725641797313; Fri, 06 Sep 2024 09:56:37 -0700 (PDT) Original-Received: from gnus ([65.94.70.53]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6c5201e415fsm18090086d6.33.2024.09.06.09.56.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2024 09:56:36 -0700 (PDT) In-Reply-To: <87le0450x8.fsf@gmx.de> (Michael Albinus's message of "Fri, 06 Sep 2024 16:09:23 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:291328 Archived-At: Michael Albinus writes: >>> > FWIW, I cannot reproduce this: I tried Dired on a remote host with >>> > which I have connection that is quite slow, and saw neither high CPU >>> > usage nor a significant delay in displaying a Dired buffer. >>> >>> 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'. >> >> But font-lock is ON by default, so what I saw also includes this, >> right? > > Sure. But we don't know the exact setting of the OP. The connection > could be extremely slow for him, Tramp's cache might be disabled, > whatever. Perhaps it's worth to rerun the test with "emacs -Q". The issue was observed with emacs -Q on a remote directory that had 22 symlinks. On the affected host, I am able to reliably reproduce the issue by evaluating the code below and then navigating to /tmp/test/links in dired via TRAMP. #+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 Notably, for the affected host, the issue is reproducible using above even after a new OS install. However, the above test case doesn't cover all variables affecting the issue. Specifically, when I run the above code on a different host (with faster connection and fewer hops to get to) and navigate to /tmp/test/links the severity of the issue is much less. That being said, the profiler reports (starting from emacs -Q and after establishing connection with host in question via TRAMP) for both the affected and not-as-affected host are similar. I believe the issue is present on the unaffected host as well, but with much less severity for some reason. My guess is that connection speed (in addition to the number of symlinks in the directory in question) is a determining factor. I am speculating here, but perhaps TRAMP is busy-waiting for a response? That would be consistent with what I observe, but I am not sure how to verify that. >>> I believe it would be helpful to suppress these checks via a user >>> option. >> >> What's wrong with "M-x font-lock-mode RET"? > > You would deactivate all fontifications, not only the ones related to > symlinks. > > And you must do this in a hook of the dired buffer, before fontification > happens. Yes, precisely. That is my current workaround. It's far from ideal, but it at least allows Emacs to be in a semi-workable state. It would be much better if there were a way to suppress only the "expensive" font-locking checks in this case. > There exist `dired-hide-details-mode', which I don't know. Perhaps > enabling it in time would do the job? It, unfortunately, doesn't help. -- Suhail