From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: "Wilco Dijkstra" <Wilco.Dijkstra@arm.com>,
"Cristian Rodríguez" <cristian@rodriguez.im>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH 2/2] Add single-threaded fast path to rand()
Date: Wed, 20 Mar 2024 09:31:44 -0300 [thread overview]
Message-ID: <89b53f94-075f-4a34-99df-778271965de9@linaro.org> (raw)
In-Reply-To: <PAWPR08MB898226B2B514C7878E6ECAED832C2@PAWPR08MB8982.eurprd08.prod.outlook.com>
On 19/03/24 12:44, Wilco Dijkstra wrote:
> Hi Cristian,
>
>> So the generalized lock-omitting code in __libc_lock_lock didn't
>> flew..
>
> There were some comments on it. One issue is that it would affect
> practically every lock in GLIBC, thus adding code and branches even for
> locks that don't benefit from single-threaded optimization.
>
> Hence the idea of first sorting out rand() since it is a frequent performance
> complaint (unfortunately).
I don't have a strong opinion on this rand patch, if this idea is to
have it as an workbench for a possible single-thread lock optimization
it should be fine. It is just that I don't see much gain in optimizing
such a bad interface (although we still lack a proper userland PRNG).
>
>> what a new fast path macro function like (sorry I suck at
>> naming things) __libc_maybe_lock_lock that only locks if not single
>> thread ?
>
> Yes despite the huge mess of locking macros in use, adding a new set of
> macros may be better overall. We could say that the critical section must not
> create a new thread itself. This means we can avoid checking the lock value
> and compile the lock macro like:
>
> #define __libc_fast_lock(NAME) if (SINGLE_THREAD_P || !__libc_lock_lock (NAME)) {
This sounds reasonable, maybe we use a static inline instead to enforce the
lock type (not sure if this really required).
next prev parent reply other threads:[~2024-03-20 12:32 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-18 15:20 [PATCH 2/2] Add single-threaded fast path to rand() Wilco Dijkstra
2024-03-18 19:24 ` Cristian Rodríguez
2024-03-19 15:44 ` Wilco Dijkstra
2024-03-20 12:31 ` Adhemerval Zanella Netto [this message]
2024-03-20 14:18 ` Cristian Rodríguez
2024-03-20 14:27 ` Adhemerval Zanella Netto
2024-03-21 7:39 ` Florian Weimer
2024-03-21 13:33 ` Cristian Rodríguez
2024-03-21 14:35 ` Mathieu Desnoyers
2024-03-21 15:07 ` Szabolcs Nagy
2024-03-21 15:18 ` Wilco Dijkstra
2024-03-21 15:53 ` Adhemerval Zanella Netto
2024-03-22 14:27 ` Zack Weinberg
2024-03-22 14:46 ` Adhemerval Zanella Netto
2024-03-22 15:30 ` Zack Weinberg
2024-03-22 18:05 ` Adhemerval Zanella Netto
2024-03-22 19:47 ` Mathieu Desnoyers
2024-03-22 22:54 ` Cristian Rodríguez
2024-03-23 14:01 ` Zack Weinberg
2024-03-23 15:23 ` Mathieu Desnoyers
2024-03-25 14:09 ` Mathieu Desnoyers
2024-03-25 17:52 ` Adhemerval Zanella Netto
2024-03-24 0:59 ` Cristian Rodríguez
2024-03-25 6:44 ` Florian Weimer
2024-03-20 14:28 ` Wilco Dijkstra
2024-03-20 14:40 ` Xi Ruoyao
-- strict thread matches above, loose matches on Subject: below --
2023-11-28 17:37 Wilco Dijkstra
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=89b53f94-075f-4a34-99df-778271965de9@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=Wilco.Dijkstra@arm.com \
--cc=cristian@rodriguez.im \
--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).