public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@redhat.com>
To: Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
	Florian Weimer <fweimer@redhat.com>,
	Wilco Dijkstra via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH] Improve performance of libc locks
Date: Fri, 24 Nov 2023 11:29:03 -0500	[thread overview]
Message-ID: <89f0615a-d626-bca4-a7a3-86f51f30b50f@redhat.com> (raw)
In-Reply-To: <PAWPR08MB8982C098BCEDC1C7624BC65383B8A@PAWPR08MB8982.eurprd08.prod.outlook.com>

On 11/24/23 08:47, Wilco Dijkstra wrote:
> Hi Florian, 
> 
>> We already have SINGLE_THREAD_P checks around locking in several places.
>> This makes the __libc_lock_lock check redudant in those cases.  I
>> believe this was done deliberately because in many cases, we can also to
>> skip cancellation handling at the same time.
> 
> Yes, this is best for the most performance critical cases. However there are lots of
> functions that use locks and many will improve with a single thread check at a 
> higher level. You're right that would add extra checks in cases that are not
> performance critical.

Right.

> Maybe a solution would be to introduce __libc_lock_fast() or similar? That way one
> can improve performance critical code easily without having to add special fast
> paths. Today it would use SINGLE_THREAD_P, but it could potentially use RSEQ in
> the future.

I would prefer a solution like this because you can actively audit, and migrate
the callers rather than adding a hidden (to the developer) change in the macro.

>> The rand performance issue could be addressed with a similar localized
>> change.  I believe that would be far less controversial.
> 
> I can send a patch that adds fast paths to rand() if that helps unblocking this.

I think it would. Add the fast path to rand(), and a microbenchmark to show that this 
is good for performance on your machine, that way we don't regress this change
in the future when we work on rand(). I'm amenable to not having a microbenchmark, but
every time we talk about performance adding a little bit to the corpus helps ensure
we don't loose track of the gains.

-- 
Cheers,
Carlos.


      reply	other threads:[~2023-11-24 16:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-11 16:22 Wilco Dijkstra
2022-08-15 14:07 ` Carlos O'Donell
2022-08-15 17:35   ` Wilco Dijkstra
2022-08-16  7:26     ` Noah Goldstein
2022-11-15 20:17 ` Cristian Rodríguez
2022-12-09 14:10   ` Wilco Dijkstra
2023-11-23 17:16     ` Cristian Rodríguez
2023-11-23 18:17 ` Florian Weimer
2023-11-24 13:47   ` Wilco Dijkstra
2023-11-24 16:29     ` Carlos O'Donell [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=89f0615a-d626-bca4-a7a3-86f51f30b50f@redhat.com \
    --to=carlos@redhat.com \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=fweimer@redhat.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).