public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Samir Droubi <samirdr@mit.edu>
To: Noah Goldstein <goldstein.w.n@gmail.com>,
	Florian Weimer <fweimer@redhat.com>
Cc: Samir Droubi via Libc-help <libc-help@sourceware.org>
Subject: RE: ____wcstold_l_internal Question
Date: Sat, 3 Dec 2022 19:20:20 +0000	[thread overview]
Message-ID: <PH0PR01MB66351EABB5C79A1EFE878E69A2169@PH0PR01MB6635.prod.exchangelabs.com> (raw)
In-Reply-To: <CAFUsyfK+5Xbj5-tXiQRpUeQgQmt_zHbPZTgd5Wi8ui0nbYefKg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3617 bytes --]

<libc-help@sourceware.org> wrote:

> >

> > * Samir Droubi via Libc-help:

> >

> > > I was profiling a project that I have been working on and the function

> > > above shows up amongst other internal functions. I was wondering if

> > > you could shed a light on what could possibly be happening to cause

> > > calls to this function to be so frequent. Here is the profiling

> > > result:

> > >

> > >   13.72%  mitscriptbc  libc.so.6             [.] ____wcstold_l_internal

> > >    5.45%  mitscriptbc  libc.so.6             [.] ____wcstof_l_internal

> > >    2.46%  mitscriptbc  libc.so.6             [.] round_and_return

> > >    2.28%  mitscriptbc  libc.so.6             [.] ____wcstod_l_internal

> > >

> > > The libc version being used is 2.35.

> I've noticed on ubuntu 22.04 (2.35 as well) `__wcstold_l` is showing up

> in perf profiles incorrectly. It's usually malloc / memcpy / whatever other

> functions are usually hot if you look at the asm.


> Not sure where the bug is but don't think `__wcstold` is whats taking up

> all those cycles.


I have noticed the same thing. I started noticing this when I was profiling on ubuntu 22.04 (with libc 2.35).

When I look at the annotated assembly in perf for `____wcstold_l_internal`, I see that I am in `_int_free`, but I still see calls to  `____wcstold_l_internal`.

Specifically, here is a segment of what I am seeing:


```

       │      ./malloc/malloc.c:4605

  0.01 │        mov        0x8(%rbp),%rdx
  0.08 │        and        $0xfffffffffffffff8,%rdx
  1.36 │        cmp        %rax,%rdx
       │      ↓ jne        716
       │      ./malloc/malloc.c:4607
  0.14 │        mov        %rbp,%rdi
       │      → call       ____wcstod_l_internal
       │      ./malloc/malloc.c:4610
  1.39 │  b9:   cmp        %r14,0x60(%r12)
  0.01 │      ↓ je         480
       │      ./malloc/malloc.c:4615
  0.05 │     ┌──testb      $0x1,0x8(%r14,%r15,1)
  9.31 │     ├──je         520
       │     │./malloc/malloc.c:4619
  1.31 │     │  andq       $0xfffffffffffffffe,0x8(%r14)

```


I was also confused about why `wcstold_l` would be called here, at least from a quick glance at the external function definition.

Is there a way to confirm that this is actually a problem with perf? When I was looking at what ./malloc/malloc.c:4607 is I found this:

https://github.com/bminor/glibc/blob/release/2.35/master/malloc/malloc.c#L4607

Which calls this macro: https://github.com/bminor/glibc/blob/release/2.35/master/malloc/malloc.c#L1436

which is reading this field: https://github.com/bminor/glibc/blob/release/2.35/master/malloc/malloc.c#L1151

Reading the comments in the file it seems that INTERNAL_SIZE_T  should be defined as size_t: https://github.com/bminor/glibc/blob/release/2.35/master/malloc/malloc.c#L173

I don't really see why those calls to `____wcstold_l_internal` are showing there. Is it possible that the reported line numbers in malloc.c are inaccurate or for a different source than the one I am looking at?


Is there a way to downgrade libc version on Ubuntu 22.04 to study how the performance/perf results change?


> >

> > The external name is wcstold or wcstold_l.  If your application isn't

> > calling that, the profiling data is wrong.  You might find out by

> > setting a breakpoint or probe on the function.

> >

> > Thanks,

> > Florian

> >


      reply	other threads:[~2022-12-03 19:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02  5:39 Samir Droubi
2022-12-02  6:09 ` Florian Weimer
2022-12-03  7:57   ` Noah Goldstein
2022-12-03 19:20     ` Samir Droubi [this message]

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=PH0PR01MB66351EABB5C79A1EFE878E69A2169@PH0PR01MB6635.prod.exchangelabs.com \
    --to=samirdr@mit.edu \
    --cc=fweimer@redhat.com \
    --cc=goldstein.w.n@gmail.com \
    --cc=libc-help@sourceware.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).