Subject: Re: bug#77775: 30.1; Proced performance

From: Azeem Hasan <[email-masked]>
Date: Mon, 14 Apr 2025 09:24:35 +0500

Hi Roland,

Roland Winkler <[email-masked]> writes:

> On Sun, Apr 13 2025, Eli Zaretskii wrote:
>>>    ;; If none of the alternatives is non-nil, the attribute is ignored
>>>    ;; in the listing.
>>>    (let ((standard-attributes
>>> -         (car (proced-process-attributes (list-system-processes))))
>>> +         (car (proced-process-attributes (last (list-system-processes)))))
>>>          new-format fmi)
>>>      (if (and proced-tree-flag
>>>               (assq 'ppid standard-attributes))
>>> 
>>> (The comment at the start of this diff is outdated)
>
> Why is this comment outdated?  Previously, proced-format used emacs-pid
> instead of (list-system-processes), which is obviously much faster.

The comment talks about `emacs-pid' and I couldn't see how it is using
`emacs-pid' and was confused about it till I checked history and saw
that this used to be the case. Why is why I called it outdated. It is
likely to cause confusion for someone like me reading the code for the
first time.

Looking at how the process-alist passed to `proced-format' is
constructed, I think a better change that preserves current behavior
would be:

diff --git a/lisp/proced.el b/lisp/proced.el
index 51e6f3aca4d..f03213f5764 100644
--- a/lisp/proced.el
+++ b/lisp/proced.el
@@ -1747,8 +1747,7 @@ proced-format
   ;; attributes, we take the first attribute that is non-nil for `emacs-pid'.
   ;; If none of the alternatives is non-nil, the attribute is ignored
   ;; in the listing.
-  (let ((standard-attributes
-         (car (proced-process-attributes (list-system-processes))))
+  (let ((standard-attributes (car process-alist))
         new-format fmi)
     (if (and proced-tree-flag
              (assq 'ppid standard-attributes))

> I haven't been engaged in the development of proced.el for some time.
> But I feel I need to look at the current code more carefully before I
> can comment on this patch (and the problem it is supposed to fix) in a
> meaningful way.
>
> Roland

Rahguzar