GNU bug report logs - #59272
[PATCH] Make Memory Human Readable in proced Buffers

Previous Next

Package: emacs;

Reported by: Laurence Warne <laurencewarne <at> gmail.com>

Date: Mon, 14 Nov 2022 23:17:05 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 59272 in the body.
You can then email your comments to 59272 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#59272; Package emacs. (Mon, 14 Nov 2022 23:17:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Laurence Warne <laurencewarne <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 14 Nov 2022 23:17:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Laurence Warne <laurencewarne <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Make Memory Human Readable in proced Buffers
Date: Mon, 14 Nov 2022 10:19:51 +0000
[Message part 1 (text/plain, inline)]
Hi, this patch makes vsize and rss human readable in proced buffers by
formatting them as megabytes or gigabytes according to their size, similar
as the -h flag for ls and du.

The current behaviour is to show them always as kilobytes, though I'm
unsure if this meant as 1000 bytes or 1024 bytes, this patch assumes the
former case.

Thanks, Laurence
[Message part 2 (text/html, inline)]
[0001-Make-vsize-and-rss-human-readable-in-proced-buffers.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59272; Package emacs. (Tue, 15 Nov 2022 03:29:01 GMT) Full text and rfc822 format available.

Message #8 received at 59272 <at> debbugs.gnu.org (full text, mbox):

From: Visuwesh <visuweshm <at> gmail.com>
To: Laurence Warne <laurencewarne <at> gmail.com>
Cc: 59272 <at> debbugs.gnu.org
Subject: Re: bug#59272: [PATCH] Make Memory Human Readable in proced Buffers
Date: Tue, 15 Nov 2022 08:58:19 +0530
[திங்கள் நவம்பர் 14, 2022] Laurence Warne wrote:

> Hi, this patch makes vsize and rss human readable in proced buffers by
> formatting them as megabytes or gigabytes according to their size, similar
> as the -h flag for ls and du.
>
> The current behaviour is to show them always as kilobytes, though I'm
> unsure if this meant as 1000 bytes or 1024 bytes, this patch assumes the
> former case.

We can leave this to the user to decide by...

> +(defun proced-format-memory (kilobytes)
> +  "Format KILOBYTES in a human readable format."

... using `file-size-human-readable' instead.

> +  (let* ((mb 1000)
> +         (gb (* 1000 mb)))
> +    (cond ((< kilobytes 100) (format "%.1fK" kilobytes))
> +          ((< kilobytes mb) (format "%dK" kilobytes))
> +          ((< kilobytes (* 100 mb)) (format "%.1fM" (/ kilobytes (float mb))))
> +          ((< kilobytes gb) (format "%dM" (/ kilobytes mb)))
> +          (t (format "%.1fG" (/ kilobytes (float gb)))))))
> +
>  (defun proced-format (process-alist format)
>    "Display PROCESS-ALIST using FORMAT."
>    (if (symbolp format)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59272; Package emacs. (Tue, 15 Nov 2022 03:41:01 GMT) Full text and rfc822 format available.

Message #11 received at 59272 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Visuwesh <visuweshm <at> gmail.com>, Laurence Warne <laurencewarne <at> gmail.com>
Cc: 59272 <at> debbugs.gnu.org
Subject: Re: bug#59272: [PATCH] Make Memory Human Readable in proced Buffers
Date: Mon, 14 Nov 2022 19:40:31 -0800
Visuwesh <visuweshm <at> gmail.com> writes:

> [திங்கள் நவம்பர் 14, 2022] Laurence Warne wrote:
>
>> Hi, this patch makes vsize and rss human readable in proced buffers by
>> formatting them as megabytes or gigabytes according to their size, similar
>> as the -h flag for ls and du.
>>
>> The current behaviour is to show them always as kilobytes, though I'm
>> unsure if this meant as 1000 bytes or 1024 bytes, this patch assumes the
>> former case.
>
> We can leave this to the user to decide by...
>
>> +(defun proced-format-memory (kilobytes)
>> +  "Format KILOBYTES in a human readable format."
>
> ... using `file-size-human-readable' instead.

Yes, we could do something like

(defcustom  proced-format-memory-function #'file-size-human-readable
  "..."
  )

Where one of the options is #'identity, which means not to use human
readable sizes, and then funcall that.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59272; Package emacs. (Tue, 15 Nov 2022 08:35:02 GMT) Full text and rfc822 format available.

Message #14 received at 59272 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 59272 <at> debbugs.gnu.org, Laurence Warne <laurencewarne <at> gmail.com>,
 Visuwesh <visuweshm <at> gmail.com>
Subject: Re: bug#59272: [PATCH] Make Memory Human Readable in proced Buffers
Date: Tue, 15 Nov 2022 10:06:50 +0200
>> We can leave this to the user to decide by...
>>
>>> +(defun proced-format-memory (kilobytes)
>>> +  "Format KILOBYTES in a human readable format."
>>
>> ... using `file-size-human-readable' instead.
>
> Yes, we could do something like
>
> (defcustom  proced-format-memory-function #'file-size-human-readable
>   "..."
>   )
>
> Where one of the options is #'identity, which means not to use human
> readable sizes, and then funcall that.

Maybe the default should be the same as in byte-count-to-string-function?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59272; Package emacs. (Tue, 15 Nov 2022 09:00:02 GMT) Full text and rfc822 format available.

Message #17 received at 59272 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 59272 <at> debbugs.gnu.org, Laurence Warne <laurencewarne <at> gmail.com>,
 Visuwesh <visuweshm <at> gmail.com>
Subject: Re: bug#59272: [PATCH] Make Memory Human Readable in proced Buffers
Date: Tue, 15 Nov 2022 00:59:32 -0800
Juri Linkov <juri <at> linkov.net> writes:

> Maybe the default should be the same as in byte-count-to-string-function?

Make sense to me.  Or maybe we should just use that variable?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59272; Package emacs. (Tue, 15 Nov 2022 09:53:01 GMT) Full text and rfc822 format available.

Message #20 received at 59272 <at> debbugs.gnu.org (full text, mbox):

From: Laurence Warne <laurencewarne <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 59272 <at> debbugs.gnu.org, Visuwesh <visuweshm <at> gmail.com>,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#59272: [PATCH] Make Memory Human Readable in proced Buffers
Date: Tue, 15 Nov 2022 09:51:53 +0000
[Message part 1 (text/plain, inline)]
I think the suggestion to use a custom variable (or just use
byte-count-to-string) is a good one, but AFAICS the argument to
file-size-human-readable should be bytes, but proced gets rss and vsize
from 'process-attributes' which uses kilobytes.  So we're still stuck with
having to choose one of:

(funcall #'byte-count-to-string-function (* 1000 kilobytes))
(funcall #'byte-count-to-string-function (* 1024 kilobytes))

I'm not really familiar with c, so I can't tell from process.c

On Tue, Nov 15, 2022 at 8:59 AM Stefan Kangas <stefankangas <at> gmail.com>
wrote:

> Juri Linkov <juri <at> linkov.net> writes:
>
> > Maybe the default should be the same as in byte-count-to-string-function?
>
> Make sense to me.  Or maybe we should just use that variable?
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59272; Package emacs. (Wed, 16 Nov 2022 08:58:01 GMT) Full text and rfc822 format available.

Message #23 received at 59272 <at> debbugs.gnu.org (full text, mbox):

From: Laurence Warne <laurencewarne <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: 59272 <at> debbugs.gnu.org, Visuwesh <visuweshm <at> gmail.com>,
 Juri Linkov <juri <at> linkov.net>
Subject: Re: bug#59272: [PATCH] Make Memory Human Readable in proced Buffers
Date: Wed, 16 Nov 2022 08:56:42 +0000
[Message part 1 (text/plain, inline)]
Alright, I've had a look at sysdep.c, and it looks like bytes are divided
by 1024 to convert to kilobytes.

I've attached an updated patch using Juri's suggestion.
[Message part 2 (text/html, inline)]
[0001-Make-vsize-and-rss-human-readable-in-proced-buffers.patch (text/x-patch, attachment)]

Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Thu, 17 Nov 2022 09:56:02 GMT) Full text and rfc822 format available.

Notification sent to Laurence Warne <laurencewarne <at> gmail.com>:
bug acknowledged by developer. (Thu, 17 Nov 2022 09:56:02 GMT) Full text and rfc822 format available.

Message #28 received at 59272-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Laurence Warne <laurencewarne <at> gmail.com>
Cc: 59272-done <at> debbugs.gnu.org, juri <at> linkov.net, stefankangas <at> gmail.com,
 visuweshm <at> gmail.com
Subject: Re: bug#59272: [PATCH] Make Memory Human Readable in proced Buffers
Date: Thu, 17 Nov 2022 11:55:25 +0200
> Cc: 59272 <at> debbugs.gnu.org, Visuwesh <visuweshm <at> gmail.com>,
>  Juri Linkov <juri <at> linkov.net>
> From: Laurence Warne <laurencewarne <at> gmail.com>
> Date: Wed, 16 Nov 2022 08:56:42 +0000
> 
> Alright, I've had a look at sysdep.c, and it looks like bytes are divided by 1024 to convert to kilobytes.
> 
> I've attached an updated patch using Juri's suggestion.

Thanks, installed, and closing the bug.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 15 Dec 2022 12:24:13 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 245 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.