* A tip: how to display longer function names in profiler-report
@ 2020-12-21 16:32 Alan Mackenzie
2020-12-21 17:15 ` Eli Zaretskii
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Alan Mackenzie @ 2020-12-21 16:32 UTC (permalink / raw)
To: emacs-devel
Hello, Emacs.
It's annoyed me for a long time that profiler-report wastes so much
horizontal screen space, and truncates function names horribly. And
that's in CC Mode, which has a very short package prefix, "c-".
When the functions being recorded are within jit-lock, I can easily
reach a nesting depth of 25. That only leaves room for the first 23
characters of the name to be displayed. This is inadequate.
The documentation of profiler.el is not good. It is composed of a large
number of mainly small functions, few (if any) of which have an adequate
doc string or function comment. Some configuration variables which
perhaps ought to be customisable likewise have no comments or doc
strings.
The variable which controls the widths of the comment name, number of
samples, and percentage columns is profiler-report-cpu-line-format.
It's default value is:
((50 left) (24 right
((19 right) (5 right))))
, which codes column sizes of 50, 19, and 5. The 5 (for percentage) is
OK. 50 (defun name) is too small. 19 (number of samples) is too big -
that is broad enough to count up to 10^16 seconds, of the order of the
age of the universe.
So in my .emacs, I've adjusted these widths to 70, 9, and 5 with the
following incantation:
(eval-after-load "profiler"
'(setq profiler-report-cpu-line-format '((70 left)
(14 right ((9 right) (5 right))))))
. I've now stopped being so annoyed at the profiler.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: A tip: how to display longer function names in profiler-report
2020-12-21 16:32 A tip: how to display longer function names in profiler-report Alan Mackenzie
@ 2020-12-21 17:15 ` Eli Zaretskii
2020-12-21 17:34 ` Alan Mackenzie
2020-12-21 17:52 ` Stefan Kangas
2020-12-21 20:24 ` Clément Pit-Claudel
2 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2020-12-21 17:15 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: emacs-devel
> Date: Mon, 21 Dec 2020 16:32:21 +0000
> From: Alan Mackenzie <acm@muc.de>
>
> The variable which controls the widths of the comment name, number of
> samples, and percentage columns is profiler-report-cpu-line-format.
> It's default value is:
>
> ((50 left) (24 right
> ((19 right) (5 right))))
>
> , which codes column sizes of 50, 19, and 5. The 5 (for percentage) is
> OK. 50 (defun name) is too small. 19 (number of samples) is too big -
> that is broad enough to count up to 10^16 seconds, of the order of the
> age of the universe.
Isn't it also used for the "memory" profile? in that case the numbers
are much larger in magnitude. So perhaps we should use 2 different
values for that variable (and I wouldn't worry about the one used for
"memory" profile, since it shouldn't be used on any modern platform).
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: A tip: how to display longer function names in profiler-report
2020-12-21 17:15 ` Eli Zaretskii
@ 2020-12-21 17:34 ` Alan Mackenzie
2020-12-21 18:12 ` Eli Zaretskii
0 siblings, 1 reply; 12+ messages in thread
From: Alan Mackenzie @ 2020-12-21 17:34 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
Hello, Eli.
On Mon, Dec 21, 2020 at 19:15:42 +0200, Eli Zaretskii wrote:
> > Date: Mon, 21 Dec 2020 16:32:21 +0000
> > From: Alan Mackenzie <acm@muc.de>
> > The variable which controls the widths of the comment name, number of
> > samples, and percentage columns is profiler-report-cpu-line-format.
> > It's default value is:
> > ((50 left) (24 right
> > ((19 right) (5 right))))
> > , which codes column sizes of 50, 19, and 5. The 5 (for percentage) is
> > OK. 50 (defun name) is too small. 19 (number of samples) is too big -
> > that is broad enough to count up to 10^16 seconds, of the order of the
> > age of the universe.
> Isn't it also used for the "memory" profile?
No, it's not. (See below.)
> in that case the numbers are much larger in magnitude. So perhaps we
> should use 2 different values for that variable (and I wouldn't worry
> about the one used for "memory" profile, since it shouldn't be used on
> any modern platform).
There's already a separate variable for the memory profile,
profiler-report-memory-line-format. I've never used the memory profile,
so I don't know if profiler-report-memory-line-format's value is
similarly annoying. I suspect not.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: A tip: how to display longer function names in profiler-report
2020-12-21 16:32 A tip: how to display longer function names in profiler-report Alan Mackenzie
2020-12-21 17:15 ` Eli Zaretskii
@ 2020-12-21 17:52 ` Stefan Kangas
2020-12-21 18:14 ` Alan Mackenzie
2020-12-21 20:24 ` Clément Pit-Claudel
2 siblings, 1 reply; 12+ messages in thread
From: Stefan Kangas @ 2020-12-21 17:52 UTC (permalink / raw)
To: Alan Mackenzie, emacs-devel
Alan Mackenzie <acm@muc.de> writes:
> It's annoyed me for a long time that profiler-report wastes so much
> horizontal screen space, and truncates function names horribly. And
> that's in CC Mode, which has a very short package prefix, "c-".
Would profiler-report-mode be a good candidate for using
tabulated-list-mode? The latter has commands for expanding columns.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: A tip: how to display longer function names in profiler-report
2020-12-21 17:34 ` Alan Mackenzie
@ 2020-12-21 18:12 ` Eli Zaretskii
2020-12-21 18:52 ` Alan Mackenzie
0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2020-12-21 18:12 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: emacs-devel
> Date: Mon, 21 Dec 2020 17:34:12 +0000
> Cc: emacs-devel@gnu.org
> From: Alan Mackenzie <acm@muc.de>
>
> > > ((50 left) (24 right
> > > ((19 right) (5 right))))
>
> > > , which codes column sizes of 50, 19, and 5. The 5 (for percentage) is
> > > OK. 50 (defun name) is too small. 19 (number of samples) is too big -
> > > that is broad enough to count up to 10^16 seconds, of the order of the
> > > age of the universe.
>
> > Isn't it also used for the "memory" profile?
>
> No, it's not. (See below.)
Then how about changing the value to be better suited to the actual
width of the fields? E.g., just use the value you came up with? Are
there any downsides?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: A tip: how to display longer function names in profiler-report
2020-12-21 17:52 ` Stefan Kangas
@ 2020-12-21 18:14 ` Alan Mackenzie
0 siblings, 0 replies; 12+ messages in thread
From: Alan Mackenzie @ 2020-12-21 18:14 UTC (permalink / raw)
To: Stefan Kangas; +Cc: emacs-devel
Hello, Stefan.
On Mon, Dec 21, 2020 at 11:52:34 -0600, Stefan Kangas wrote:
> Alan Mackenzie <acm@muc.de> writes:
> > It's annoyed me for a long time that profiler-report wastes so much
> > horizontal screen space, and truncates function names horribly. And
> > that's in CC Mode, which has a very short package prefix, "c-".
> Would profiler-report-mode be a good candidate for using
> tabulated-list-mode? The latter has commands for expanding columns.
I think profiler-report-mode might well be such a candidate. I wasn't
actually aware of tabulated-list-mode before your post.
I don't know how difficult it would be to adapt the profiler for it. It
is essentially uncommented source code which, additionally, uses quite a
few obscure cl-... facilities.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: A tip: how to display longer function names in profiler-report
2020-12-21 18:12 ` Eli Zaretskii
@ 2020-12-21 18:52 ` Alan Mackenzie
0 siblings, 0 replies; 12+ messages in thread
From: Alan Mackenzie @ 2020-12-21 18:52 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
Hello, Eli.
On Mon, Dec 21, 2020 at 20:12:32 +0200, Eli Zaretskii wrote:
> > Date: Mon, 21 Dec 2020 17:34:12 +0000
> > Cc: emacs-devel@gnu.org
> > From: Alan Mackenzie <acm@muc.de>
> > > > ((50 left) (24 right
> > > > ((19 right) (5 right))))
> > > > , which codes column sizes of 50, 19, and 5. The 5 (for percentage) is
> > > > OK. 50 (defun name) is too small. 19 (number of samples) is too big -
> > > > that is broad enough to count up to 10^16 seconds, of the order of the
> > > > age of the universe.
> > > Isn't it also used for the "memory" profile?
> > No, it's not. (See below.)
> Then how about changing the value to be better suited to the actual
> width of the fields? E.g., just use the value you came up with? Are
> there any downsides?
The values I am trying out give a width of 84 characters. That would be
intolerable for somebody on an 80 char. wide window.
It seems we either want another configurable option, or Stefan K.'s idea
of using tabulated-column-mode, which would allow the column widths to
be adjusted dynamically. But even in the latter case, we'd probably
still want a config option for the initial column widths.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: A tip: how to display longer function names in profiler-report
2020-12-21 16:32 A tip: how to display longer function names in profiler-report Alan Mackenzie
2020-12-21 17:15 ` Eli Zaretskii
2020-12-21 17:52 ` Stefan Kangas
@ 2020-12-21 20:24 ` Clément Pit-Claudel
2020-12-21 21:24 ` Alan Mackenzie
2 siblings, 1 reply; 12+ messages in thread
From: Clément Pit-Claudel @ 2020-12-21 20:24 UTC (permalink / raw)
To: emacs-devel
On 12/21/20 11:32 AM, Alan Mackenzie wrote:
> Hello, Emacs.
>
> It's annoyed me for a long time that profiler-report wastes so much
> horizontal screen space, and truncates function names horribly. And
> that's in CC Mode, which has a very short package prefix, "c-".
I think the best fix would be to put the CPU samples and % columns first instead of last, and put the function name column last, with no limits on how far to the right it might expand.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: A tip: how to display longer function names in profiler-report
2020-12-21 20:24 ` Clément Pit-Claudel
@ 2020-12-21 21:24 ` Alan Mackenzie
2020-12-21 21:34 ` Clément Pit-Claudel
0 siblings, 1 reply; 12+ messages in thread
From: Alan Mackenzie @ 2020-12-21 21:24 UTC (permalink / raw)
To: Clément Pit-Claudel; +Cc: emacs-devel
Hello, Clément.
On Mon, Dec 21, 2020 at 15:24:06 -0500, Clément Pit-Claudel wrote:
> On 12/21/20 11:32 AM, Alan Mackenzie wrote:
> > Hello, Emacs.
> > It's annoyed me for a long time that profiler-report wastes so much
> > horizontal screen space, and truncates function names horribly. And
> > that's in CC Mode, which has a very short package prefix, "c-".
> I think the best fix would be to put the CPU samples and % columns
> first instead of last, and put the function name column last, with no
> limits on how far to the right it might expand.
That's an utterly brilliant idea! Thanks!
Something like, very roughly: ....
diff --git a/lisp/profiler.el b/lisp/profiler.el
index bf8aacccc3..20486da29b 100644
--- a/lisp/profiler.el
+++ b/lisp/profiler.el
@@ -445,9 +445,10 @@ profiler-report-leaf-mark
:group 'profiler)
(defvar profiler-report-cpu-line-format
- '((50 left)
- (24 right ((19 right)
- (5 right)))))
+ '((24 right ((19 right)
+ (5 right)))
+ (90 left))
+ )
(defvar profiler-report-memory-line-format
'((55 left)
@@ -505,13 +512,14 @@ profiler-report-line-format
(profiler-format (cl-ecase (profiler-profile-type profiler-report-profile)
(cpu profiler-report-cpu-line-format)
(memory profiler-report-memory-line-format))
- name-part
(if diff-p
(list (if (> count 0)
(format "+%s" count)
count)
"")
- (list count count-percent)))))
+ (list count count-percent))
+ name-part
+ )))
(defun profiler-report-insert-calltree (tree)
(let ((line (profiler-report-line-format tree)))
@@ -735,7 +748,8 @@ profiler-report-describe-entry
(cpu
(profiler-report-header-line-format
profiler-report-cpu-line-format
- "Function" (list "CPU samples" "%")))
+ (list "CPU samples" "%") "Function"
+ ))
(memory
(profiler-report-header-line-format
profiler-report-memory-line-format
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: A tip: how to display longer function names in profiler-report
2020-12-21 21:24 ` Alan Mackenzie
@ 2020-12-21 21:34 ` Clément Pit-Claudel
2020-12-21 22:09 ` Alan Mackenzie
2020-12-22 12:22 ` Alan Mackenzie
0 siblings, 2 replies; 12+ messages in thread
From: Clément Pit-Claudel @ 2020-12-21 21:34 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: emacs-devel
On 12/21/20 4:24 PM, Alan Mackenzie wrote:
> Something like, very roughly: ....
Precisely :) Love it. And we can even remove the padding spaces from the last column.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: A tip: how to display longer function names in profiler-report
2020-12-21 21:34 ` Clément Pit-Claudel
@ 2020-12-21 22:09 ` Alan Mackenzie
2020-12-22 12:22 ` Alan Mackenzie
1 sibling, 0 replies; 12+ messages in thread
From: Alan Mackenzie @ 2020-12-21 22:09 UTC (permalink / raw)
To: Clément Pit-Claudel; +Cc: emacs-devel
Hello again, Clément.
On Mon, Dec 21, 2020 at 16:34:10 -0500, Clément Pit-Claudel wrote:
> On 12/21/20 4:24 PM, Alan Mackenzie wrote:
> > Something like, very roughly: ....
> Precisely :) Love it. And we can even remove the padding spaces from the last column.
Indeed, why not? The following is close, but hasn't yet tested the
other sort of profiling ("memory", I think), and the headings aren't
100% yet. But see what you think!
diff --git a/lisp/profiler.el b/lisp/profiler.el
index bf8aacccc3..6fbcad3009 100644
--- a/lisp/profiler.el
+++ b/lisp/profiler.el
@@ -85,6 +85,9 @@ profiler-format
(t
(profiler-ensure-string arg)))
for len = (length str)
+ if (zerop width)
+ collect str into frags
+ else
if (< width len)
collect (progn (put-text-property (max 0 (- width 2)) len
'invisible 'profiler str)
@@ -445,9 +448,10 @@ profiler-report-leaf-mark
:group 'profiler)
(defvar profiler-report-cpu-line-format
- '((50 left)
- (24 right ((19 right)
- (5 right)))))
+ '((14 right ((9 right)
+ (5 right)))
+ (1 left "%s")
+ (0 left)))
(defvar profiler-report-memory-line-format
'((55 left)
@@ -505,13 +509,14 @@ profiler-report-line-format
(profiler-format (cl-ecase (profiler-profile-type profiler-report-profile)
(cpu profiler-report-cpu-line-format)
(memory profiler-report-memory-line-format))
- name-part
(if diff-p
(list (if (> count 0)
(format "+%s" count)
count)
"")
- (list count count-percent)))))
+ (list count count-percent))
+ " "
+ name-part)))
(defun profiler-report-insert-calltree (tree)
(let ((line (profiler-report-line-format tree)))
@@ -735,7 +740,7 @@ profiler-report-describe-entry
(cpu
(profiler-report-header-line-format
profiler-report-cpu-line-format
- "Function" (list "CPU samples" "%")))
+ (list "Samples" "%") " " "Function"))
(memory
(profiler-report-header-line-format
profiler-report-memory-line-format
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: A tip: how to display longer function names in profiler-report
2020-12-21 21:34 ` Clément Pit-Claudel
2020-12-21 22:09 ` Alan Mackenzie
@ 2020-12-22 12:22 ` Alan Mackenzie
1 sibling, 0 replies; 12+ messages in thread
From: Alan Mackenzie @ 2020-12-22 12:22 UTC (permalink / raw)
To: Eli Zaretskii, Clément Pit-Claudel; +Cc: emacs-devel
Hello, Eli and Clément.
On Mon, Dec 21, 2020 at 16:34:10 -0500, Clément Pit-Claudel wrote:
> On 12/21/20 4:24 PM, Alan Mackenzie wrote:
> > Something like, very roughly: ....
> Precisely :) Love it. And we can even remove the padding spaces from the last column.
The padding has now gone. Function names are now never truncated by the
profiler. The only truncation that can happen is when the user's window
is too narrow, something easily remedied.
This change (putting the usage figures on the left, and the function
names on the right) seems such a clear improvement, that I've taken the
liberty of just committing it (including NEWS item and amendments to
debugging.texi). The commit hash is 9920929e7b.
In the event that there are any objections, it would be an easy commit
to reverse.
--
Alan Mackenzie (Nuremberg, Germany).
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2020-12-22 12:22 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-21 16:32 A tip: how to display longer function names in profiler-report Alan Mackenzie
2020-12-21 17:15 ` Eli Zaretskii
2020-12-21 17:34 ` Alan Mackenzie
2020-12-21 18:12 ` Eli Zaretskii
2020-12-21 18:52 ` Alan Mackenzie
2020-12-21 17:52 ` Stefan Kangas
2020-12-21 18:14 ` Alan Mackenzie
2020-12-21 20:24 ` Clément Pit-Claudel
2020-12-21 21:24 ` Alan Mackenzie
2020-12-21 21:34 ` Clément Pit-Claudel
2020-12-21 22:09 ` Alan Mackenzie
2020-12-22 12:22 ` Alan Mackenzie
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.