Re: tramp readlink slowdown on find-file

2024-03-13 Thread Prashant Tak
Please refer to my config snippet I already have remote-file-name-inhibit-cache 
set as nil.
> Tramp caches the result of a check for remote-file-name-inhibit-cache
> seconds. Increase that value (it defaults to 10), or set it to nil.

Is there no other way to disable the amount of checking done by tramp?

Prashant


Re: tramp readlink slowdown on find-file

2024-03-13 Thread Michael Albinus
Prashant Tak  writes:

Hi Prashant,

Pls keep tramp-devel@gnu.org in Cc, for the archives.

>> When you connect to the remote host directly via ssh from a shell, does it
>> take the same time to call '\readlink --canonicalize-missing /a/b/c/xyz.md'?
>
> No, that works instantly. Is there a way to disable multiple file existence
> checks that tramp does?

Tramp caches the result of a check for remote-file-name-inhibit-cache
seconds. Increase that value (it defaults to 10), or set it to nil.

> Prashant

Best regards, Michael.



Re: tramp readlink slowdown on find-file

2024-03-13 Thread Michael Albinus
Prashant Tak  writes:

> Hi

Hi Prashant,

> while opening a file in tramp, I'm experiencing immense slowdown,
> 20+ seconds to open a file.
> In the debug buffer I found readlink status check to be consuming ~12
> seconds. Any idea what could be causing this?
>
> 21:22:47.919689 tramp-sh-handle-file-truename (4) # Finding true name
> for ‘/ssh:host:/a/b/c/xyz.md’
> 21:22:47.920152 tramp-send-command (6) # \readlink
> --canonicalize-missing /a/b/c/xyz.md 2>/dev/null; echo
> tramp_exit_status $?
> 21:22:59.722106 tramp-wait-for-regexp (6) #
> /a/b/c/xyz.md
> tramp_exit_status 0

When you connect to the remote host directly via ssh from a shell, does it
take the same time to call '\readlink --canonicalize-missing /a/b/c/xyz.md'?

Please keep the backslash when calling readlink. And note that I have
omitted the stderr redirection in order to see possible output.

> Thanks for your wonderful work Michael, the emacs community appreciates it!
>
> Prashant

Best regards, Michael.



tramp readlink slowdown on find-file

2024-03-13 Thread Prashant Tak
Hi while opening a file in tramp, I'm experiencing immense slowdown,
20+ seconds to open a file.
In the debug buffer I found readlink status check to be consuming ~12
seconds. Any idea what could be causing this?

21:22:47.919689 tramp-sh-handle-file-truename (4) # Finding true name
for ‘/ssh:host:/a/b/c/xyz.md’
21:22:47.920152 tramp-send-command (6) # \readlink
--canonicalize-missing /a/b/c/xyz.md 2>/dev/null; echo
tramp_exit_status $?
21:22:59.722106 tramp-wait-for-regexp (6) #
/a/b/c/xyz.md
tramp_exit_status 0

My tramp related configuration:

  (setq tramp-ssh-controlmaster-options
(concat
 "-o ControlPath=\~/.ssh/control/ssh-%%r@%%h:%%p "
 "-o ControlMaster=auto -o ControlPersist=yes")
tramp-default-method "ssh"
tramp-default-remote-shell "/bin/zsh"
remote-file-name-inhibit-auto-save-visited t
remote-file-name-inhibit-cache nil
remote-file-name-inhibit-locks t
tramp-verbose 1
tramp-remote-path '(tramp-own-remote-path)))

Thanks for your wonderful work Michael, the emacs community appreciates it!

Prashant



Re: Review wanted for method for accessing Mock chroots

2024-03-13 Thread Michael Albinus
Tim Landscheidt  writes:

Hi Tim,

>> However: I don't know Mock chroots in detail, but it looks to me like it
>> is something what could live in tramp-container.el. What do you think a bout?
>
> It probably fits quite nicely, but due to my preference for
> sticking to distribution packages, I'd need an interim solu-
> tion until Emacs 30 makes its way to my system. :-)

You don't. Tramp is distributed and updated also via GNU ELPA. The
current release on ELPA is 2.6.2.2. Later this year, likely end of June,
this will be Tramp 2.7, which could contain your package.

>> Why "2.7.1-pre"? This isn't a released version; I would depend on "2.7.1".
>
> Because I copied the version string from the wrong file; I
> changed it to "2.5.4-pre" (as that is what was and is
> shipped on Fedora 38).

In this case, I would say at least "2.5.3", which is a stable
release. "2.5.4-pre" is nothing one could determine correctly.

Fedora 38 comes with Emacs 28.3 (which is an unofficial Emacs
release). This is compatible with Tramp 2.7, which says

--8<---cut here---start->8---
;; Package-Requires: ((emacs "27.1"))
--8<---cut here---end--->8---

So you can install Tramp from GNU ELPA without pain.

Well, it is up to you to decide, whether you want to inregrate into
Tramp proper, or distribute a standalone package. But in the former, you
would profit from fixes in Tramp automatically.

> Tim

Best regards, Michael.



Re: Review wanted for method for accessing Mock chroots

2024-03-13 Thread Tim Landscheidt
Michael Albinus  wrote:

>> Is there anything blatantly wrong/not backward-compatible/
>> not foreward-compatible about it?  I saved on (customizable)
>> variables as it is hard to predict what other users might
>> want/need to change.  Any advice is appreciated.

> Some few comments below.

> However: I don't know Mock chroots in detail, but it looks to me like it
> is something what could live in tramp-container.el. What do you think a bout?

It probably fits quite nicely, but due to my preference for
sticking to distribution packages, I'd need an interim solu-
tion until Emacs 30 makes its way to my system. :-)

> Here are some few comments from roughly scanning the code:

>> ;;; mock-tramp.el --- TRAMP integration for Mock chroots  -*- 
>> lexical-binding: t; -*-

> Tramp is spelled out “Tramp”. See the manual.

Ha!  In "my" manual (2.5.4-pre) it is spelled "TRAMP" be-
cause 079625d3c618188fc76b89f8d942f0e7004d0312 was not com-
mitted yet. :-)

>> ;; Package-Requires: ((tramp "2.7.1-pre"))

> Why "2.7.1-pre"? This isn't a released version; I would depend on "2.7.1".

Because I copied the version string from the wrong file; I
changed it to "2.5.4-pre" (as that is what was and is
shipped on Fedora 38).

>> ;;;###autoload
>> (defcustom mock-tramp-method "mock"
>>   "TRAMP method to connect to Mock chroots."
>>   :type 'string
>>   :group 'mock-tramp)

> You can keep the :group out; the last declared defgroup is taken by
> default.

Thanks.

>> ;;;###autoload
>> (defun mock-tramp--list-chroots (directory)
>>   "Return a list of chroots defined in DIRECTORY.

> Why ;;;###autoload?

>> ;;;###autoload
>> (with-eval-after-load 'tramp
>>   (add-to-list 'tramp-methods

> Same here.

To mimic docker-tramp's (IMHO sensible) behaviour:
Installing the package sets up the Tramp method.

>>  (tramp-login-program "mock")

> I would declare and use `mock-tramp-program'.

I'd rather not.  Mock is very specialized, and it is unlike-
ly that a regular user will ever want or need to change
tramp-login-program, but nothing else.  If I introduce a
customization for this now, it is thus unlikely that is
(ever) used, but it takes screen/mental space nonetheless.

>>  (tramp-login-args (("-r") ("%h")
>> ("--shell"
>>  "--"
>>  "/usr/bin/env"
>>  "PROMPT_COMMAND="
>>  "/bin/sh"

> I would use `tramp-default-remote-shell'.

>>  "-l")))
>>  (tramp-remote-shell "/bin/sh")

> Same here.

Thanks.

I have attached a new revision of the package.

Tim
;;; mock-tramp.el --- Tramp integration for Mock chroots  -*- lexical-binding: 
t; -*-

;; Copyright (C) 2024  Tim Landscheidt

;; Author: Tim Landscheidt 
;; Version: 1.0rc7
;; Package-Requires: ((tramp "2.5.4-pre"))
;; Keywords: comm, processes

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see .

;;; Commentary:

;; This package provides a Tramp method to access Mock chroots
;; (https://rpm-software-management.github.io/mock/).  For example,
;; after running "fedpkg mockbuild --no-cleanup-after", one can edit
;; the files in the chroot by visiting "/mock:default:/path/to/file"
;; and execute commands in this chroot with M-x shell-command RET.

;;; Code:

(require 'subr-x)
(require 'tramp)

(defgroup mock-tramp nil
  "Tramp integration for Mock chroots."
  :prefix "mock-tramp-"
  :group 'applications
  :link '(emacs-commentary-link "mock-tramp"))

;;;###autoload
(defcustom mock-tramp-method "mock"
  "Tramp method to connect to Mock chroots."
  :type 'string
  :package-version '(mock-tramp . "1.0rc2"))

;;;###autoload
(defun mock-tramp--list-chroots (directory)
  "Return a list of chroots defined in DIRECTORY.

The list consists of (\"\" chroot) sublists suitable for Tramp
completion."
  ;; Unfortunately, mock provides no machine-readable list of chroots,
  ;; therefore here the logic in mock/py/mockbuild/config.py and
  ;; mock/etc/bash_completion.d/mock needs to be duplicated.  An RFE
  ;; for such an option to mock is tracked at
  ;; https://github.com/rpm-software-management/mock/issues/1294.
  (if (file-directory-p directory)
  (seq-reduce
   (lambda (r filename)
 (if (not (and (string= directory "/etc/mock")