Re: Futexes ain't fast

Liste des GroupesRevenir à cl c++ 
Sujet : Re: Futexes ain't fast
De : chris.m.thomasson.1 (at) *nospam* gmail.com (Chris M. Thomasson)
Groupes : comp.lang.c++
Date : 26. Sep 2024, 18:40:30
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vd46af$93f5$1@dont-email.me>
References : 1 2 3 4 5 6 7
User-Agent : Mozilla Thunderbird
On 9/26/2024 9:30 AM, Bonita Montero wrote:
Am 30.08.2024 um 22:04 schrieb Chris M. Thomasson:
On 8/30/2024 1:03 PM, Bonita Montero wrote:
Am 30.08.2024 um 21:43 schrieb Chris M. Thomasson:
On 8/30/2024 8:41 AM, Bonita Montero wrote:
Am 30.08.2024 um 15:31 schrieb jseigh:
>
They don't have to be fast, they just have to allow correct synchronization
and allow performant fast paths. ...
>
Futexes are there to make the slow past faster.
The fast path has been fast before.
>
>
No. You are wrong here.
>
>
No, you don't need a futex for the slow path.
>
>
I don't know what you even mean here. Tell me the difference between a slow path and a fast path.
  The fast path is in userspace, the slow path is in kernel space.
 
Basically right. Think of hitting a slow path (before resorting to the kernel), then trying to spin a couple of times in user space before we have to hit a kernel call. Akin to a adaptive mutex. If we can avoid a kernel call, well, go ahead and try a couple of times...
Actually, there is a "method" to do this even with a simple mutex via try_lock. I wrote about it in the past. Hummm... Think of trying to give a little back off with actual work before we resort to waiting in the kernel. Iirc, the pattern was something like, wrt mutex:
<pseudo-code>
Keep in mind that the prefix try_* means try to no other work. Not block! This is important...
________________________
void lock()
{
     while (! try_lock())
     {
         if (! try_to_do_some_other_useful_work())
         {
        lock(); // oh shit, commit to a lock.
             break;
         }
     }
}
________________________
Notice what's occurring here? We can use "other work" as a sort of "natural backoff" in the contended case of a mutex in general... In a certain sense... Instead of spinning, we are doing "actual work" if we can and only if its available. This can work pretty good on certain scenarios wrt how a program is structured...

Date Sujet#  Auteur
28 Aug 24 * Futexes ain't fast38Bonita Montero
28 Aug 24 +- Re: Futexes ain't fast1Bonita Montero
28 Aug 24 +* Re: Futexes ain't fast20Chris M. Thomasson
29 Aug 24 i`* Re: Futexes ain't fast19Bonita Montero
29 Aug 24 i `* Re: Futexes ain't fast18Chris M. Thomasson
29 Aug 24 i  +* Re: Futexes ain't fast16Chris M. Thomasson
29 Aug 24 i  i`* Re: Futexes ain't fast15Bonita Montero
29 Aug 24 i  i +* Re: Futexes ain't fast10Bonita Montero
29 Aug 24 i  i i`* Re: Futexes ain't fast9Bonita Montero
29 Aug 24 i  i i +* Re: Futexes ain't fast4Chris M. Thomasson
29 Aug 24 i  i i i+* Re: Futexes ain't fast2Bonita Montero
30 Aug 24 i  i i ii`- Re: Futexes ain't fast1Chris M. Thomasson
19 Sep 24 i  i i i`- Re: Futexes ain't fast1Chris M. Thomasson
29 Aug 24 i  i i +* Re: Futexes ain't fast3Chris M. Thomasson
30 Aug 24 i  i i i`* Re: Futexes ain't fast2Bonita Montero
30 Aug 24 i  i i i `- Re: Futexes ain't fast1Chris M. Thomasson
29 Aug 24 i  i i `- Re: Futexes ain't fast1Chris M. Thomasson
29 Aug 24 i  i `* Re: Futexes ain't fast4Chris M. Thomasson
29 Aug 24 i  i  `* Re: Futexes ain't fast3Chris M. Thomasson
29 Aug 24 i  i   `* Re: Futexes ain't fast2Bonita Montero
30 Aug 24 i  i    `- Re: Futexes ain't fast1Chris M. Thomasson
29 Aug 24 i  `- Re: Futexes ain't fast1Chris M. Thomasson
30 Aug 24 `* Re: Futexes ain't fast16jseigh
30 Aug 24  +* Re: Futexes ain't fast11Bonita Montero
30 Aug 24  i`* Re: Futexes ain't fast10Chris M. Thomasson
30 Aug 24  i `* Re: Futexes ain't fast9Bonita Montero
30 Aug 24  i  +* Re: Futexes ain't fast7Chris M. Thomasson
26 Sep 24  i  i`* Re: Futexes ain't fast6Bonita Montero
26 Sep 24  i  i `* Re: Futexes ain't fast5Chris M. Thomasson
26 Sep 24  i  i  `* Re: Futexes ain't fast4Bonita Montero
26 Sep 24  i  i   `* Re: Futexes ain't fast3Chris M. Thomasson
26 Sep 24  i  i    `* Re: Futexes ain't fast2Bonita Montero
26 Sep 24  i  i     `- Re: Futexes ain't fast1Chris M. Thomasson
30 Aug 24  i  `- Re: Futexes ain't fast1Chris M. Thomasson
30 Aug 24  `* Re: Futexes ain't fast4Chris M. Thomasson
31 Aug 24   `* Re: Futexes ain't fast3jseigh
2 Sep 24    +- Re: Futexes ain't fast1Chris M. Thomasson
15 Sep 24    `- Re: Futexes ain't fast1Chris M. Thomasson

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal