unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Winston Carlile via "Emacs development discussions."
	<emacs-devel@gnu.org>
Cc: Winston Carlile <winstonc@google.com>
Subject: Re: Making elp.el behave like a real profiler
Date: Tue, 16 Aug 2022 11:27:36 -0400	[thread overview]
Message-ID: <jwvy1vofcwk.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CALYEEYyp_O0P5V3dKxkm26JBiduONUn7-0qoCw8Cx0+0DvpPLQ@mail.gmail.com> (Winston Carlile via's message of "Mon, 15 Aug 2022 12:22:54 -0700")

Winston Carlile via "Emacs development discussions." [2022-08-15 12:22:54] wrote:
> I'm working on adding one level of context to function calls
> in ELP reports, looking for implementation and usability feedback.

Before we go any further: are you aware of the sampling based profiler
available via `M-x profiler-start`?

> 1) Is there a better way to programmatically access the call
>    stack than a dynamic binding hack?

There's `backtrace-frame(s)`, but I'm not sure it qualifies as "better".

> 2) How can I make the report more intuitive? Specifically
>    I'm worried about confusing people with the 0 call count
>    for f in the above example.

How 'bout:

    Function Name   Call Count
    g               1    ;; called once:
    `-?             1    ;; calls from functions not instrumented
    
    f               4    ;; called 4 times:
    `-g             1    ;; once from g
    `-f             3    ;; and 3 times from itself

Admittedly, this shows the "reverse" from what you currently show.
You'd have the property that for every function, the first line shows
the total of the subsequent lines.

For the other direction:

    Function Name   Call Count
    g               1    ;; called once
    `-f             1    ;; called f once
    
    f               4    ;; called 4 times:
    `-f             3    ;; called itself 3 times

In that version, for a given function, the first line's count is not
directly related to the other lines's count (it can be smaller or
larger).

> 3) Maybe a hashmap would be better than a plist when the
>    number of instrumented functions is large.

A plist is about as bad as it gets.  An alist would be at least a bit
more natural (plists only really make sense when they're written by
humans).

I'm not sure I understand the code correctly, but my quick reading of it
suggest you have O(N^2) calls to `new-infovec`, which seems like
a bad idea [ oh, and naming it without an `elp-` prefix is also a bad
idea) ] since the call graph is probably not that dense, so you'd be
better off allocating them more lazily.

If you keep the O(N^2) infovecs, then I'd recommend hashtables, indeed,
since every alist/plist will have N elements in it, here N will easily
grow to be too big for alist/plist (alist/plist work OK for smallish
number of elements only).


        Stefan




  reply	other threads:[~2022-08-16 15:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 19:22 Making elp.el behave like a real profiler Winston Carlile via Emacs development discussions.
2022-08-16 15:27 ` Stefan Monnier [this message]
2022-08-16 15:48   ` Stefan Kangas
2022-08-17  9:18 ` Michael Albinus
2022-08-17 18:33   ` chad

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvy1vofcwk.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=winstonc@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).