unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: "H.J. Lu" <hjl.tools@gmail.com>, Florian Weimer <fweimer@redhat.com>
Cc: abush wang <abushwangs@gmail.com>,
	abushwang via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH] stdlib: reorganize stdlib Makefile routines by functionality
Date: Mon, 1 Apr 2024 10:46:08 -0300	[thread overview]
Message-ID: <e8ecea10-7d6e-4780-8791-40a5371de6bf@linaro.org> (raw)
In-Reply-To: <CAMe9rOo8pVK-Xm3tp7tF5ozjCZOZ=jBr=_bxHkKFyfyCB6HMVQ@mail.gmail.com>



On 01/04/24 10:17, H.J. Lu wrote:
> On Mon, Apr 1, 2024 at 6:13 AM Florian Weimer <fweimer@redhat.com> wrote:
>>
>> * abush wang:
>>
>>> This is test:
>>> ```
>>> uint64_t getnsecs() {
>>>     uint32_t lo, hi;
>>>     __asm__ __volatile__ (
>>>         "rdtsc" : "=a"(lo), "=d"(hi)
>>>     );
>>>     return ((uint64_t)hi << 32) | lo;
>>> }
>>>
>>> int main() {
>>>     const int num_iterations = 1;
>>>     uint64_t start, end, total_time = 0;
>>>
>>>     start = getnsecs();
>>>     for (int i = 0; i < num_iterations; i++) {
>>>         (void) lrand48();
>>>     }
>>>     end = getnsecs();
>>>     total_time += (end - start);
>>>
>>>     printf("Average time for lrand48: %lu cycles\n", total_time / num_iterations);
>>>     return 0;
>>> }
>>> ```
>>> before:
>>> Average time for lrand48: 21418 cycles
>>>
>>> after:
>>> Average time for lrand48: 9892 cycles
>>
>> Do you see this on x86-64?  So this isn't a displacement range issue?
>>
>> It could be that this is a random performance change due to code
>> alignment, and not actually caused by the direct call distance.
>>
> 
> I have a linker patch to control section layout:
> 
> https://patchwork.sourceware.org/project/binutils/list/?series=29973
> 
> It can
> 
> 1. Reduce gaps between text sections.
> 2. Put hot text sections close to each other.
> 
> If it can solve this issue, we should add this feature to ld.
> 

Another possibility, if this is related to a displacement range due some
ISA limitation; would to move the lrand entrypoint to the same TU (at
least the one that are simple wrapper that ended up being tail calls).

  reply	other threads:[~2024-04-01 13:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-01 11:47 [PATCH] stdlib: reorganize stdlib Makefile routines by functionality abush wang
2024-04-01 13:12 ` Florian Weimer
2024-04-01 13:17   ` H.J. Lu
2024-04-01 13:46     ` Adhemerval Zanella Netto [this message]
2024-04-02  3:54     ` abush wang
2024-04-08  2:48       ` abush wang
2024-04-02  2:17   ` abush wang
2024-04-02  2:28     ` abush wang
2024-04-02  3:13       ` H.J. Lu
2024-04-02  6:18         ` abush wang
2024-04-02 14:15 ` Adhemerval Zanella Netto
2024-04-03  1:57   ` abush wang
  -- strict thread matches above, loose matches on Subject: below --
2024-04-01 11:44 abushwang
2024-04-01 12:03 ` Xi Ruoyao

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/libc/involved.html

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

  git send-email \
    --in-reply-to=e8ecea10-7d6e-4780-8791-40a5371de6bf@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=abushwangs@gmail.com \
    --cc=fweimer@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@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).