linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Clark <james.clark@arm.com>
To: Pablo Galindo Salgado <pablogsal@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: Perf support in CPython
Date: Thu, 30 Nov 2023 18:09:51 +0000	[thread overview]
Message-ID: <c845d1f1-4463-7c00-e63b-b3c9968c600c@arm.com> (raw)
In-Reply-To: <CAFjbc8FXJwJShr88XUybWFQa1HC6rYdq7cpc3XPCuPKjOUoz2g@mail.gmail.com>



On 30/11/2023 12:42, Pablo Galindo Salgado wrote:
>> Do you really want to use full Dwarf mode? You have to save the entire
>> stack space on every sample for that to work, so it seems a bit slow.
>> But maybe it's not an issue for lower sampling frequencies. If the
>> application has a huge stack it's not really scalable.
>> Is that just so you have a mode that works out of the box without any
>> recompilation of Python? But not necessarily the best way to do it?
> 
> I do not *want* to do it as we already have a fully working version
> when frame pointers are included
> using the perf maps version. But the problem is that users cannot
> generally leverage this as most
> Python redistributors do not compile with frame pointers, and this
> renders the integration useless
> for most people.
> 
> So indeed, as you mention dwarf unwinding is a suboptimal way but it
> will provide a way
> for most users to get the integration working for them and people that
> really care about the
> most performant way can compile Python with frame pointers. The
> problem is that most
> Python users do not compile Python themselves and this is a huge
> barrier for them.
> 
> That's why we want to *also* have DWARF unwinding working, even if it
> is suboptimal.

Makes sense, it just makes me wonder if there isn't something that's low
overhead that could be added to the default build configuration of
Python that makes it work even in frame pointer mode. Like putting frame
pointers only in the trampolines.

If that doesn't work, maybe this is kind of a ridiculous idea, but what
if you compiled the final binary so that it had two versions of Python,
one with frame pointers and one without, and when you run "python -X
perf" it goes down the path with frame pointers on. Presumably the
performance hit isn't as big of a deal if it's only on for profiling.

I suppose everything is a tradeoff, and that trades fewer build
configurations for a larger binary size and more complicated build system.

Feel free to ignore me though, I'm just thinking out loud. But if Python
was already modified to insert the trampolines, it seems like there must
be some modification that can be done to make frame pointer unwinding
work without turning them on for every single performance critical function.

  reply	other threads:[~2023-11-30 18:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-20 23:50 Perf support in CPython Pablo Galindo Salgado
2023-11-21 18:15 ` Namhyung Kim
2023-11-21 18:30   ` Pablo Galindo Salgado
2023-11-21 18:49     ` Namhyung Kim
2023-11-22 21:04 ` Ian Rogers
2023-11-30  6:39   ` Namhyung Kim
2023-11-30 11:00 ` James Clark
2023-11-30 12:42   ` Pablo Galindo Salgado
2023-11-30 18:09     ` James Clark [this message]
2023-11-30 21:16     ` Ian Rogers
2023-12-01  9:57       ` James Clark

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

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

  git send-email \
    --in-reply-to=c845d1f1-4463-7c00-e63b-b3c9968c600c@arm.com \
    --to=james.clark@arm.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=pablogsal@gmail.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.
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 NNTP newsgroup(s).