Re: Solving thundering Herd with glibc...

Liste des GroupesRevenir à cl c++ 
Sujet : Re: Solving thundering Herd with glibc...
De : Bonita.Montero (at) *nospam* gmail.com (Bonita Montero)
Groupes : comp.lang.c++
Date : 27. Apr 2025, 04:18:02
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vuk7k0$3th9g$1@raubtier-asyl.eternal-september.org>
References : 1 2 3 4 5 6 7 8 9
User-Agent : Mozilla Thunderbird
Am 26.04.2025 um 23:41 schrieb Chris M. Thomasson:

On 4/26/2025 12:25 AM, Bonita Montero wrote:

>
I just tried to awaken all 31 threads from outside holding the mutex,
but not from inside:
>
     for( size_t r = N; r; --r )
     {
         unique_lock lock( mtx );
         signalled = nClients;
         ai.store( nClients, memory_order_relaxed );
         lock.unlock();
         if( argc < 2 )
             cv.notify_all();
         else
             for( int c = nClients; c; cv.notify_one(), --c );
         bs.acquire();
     }
>
The result: 7.500 context switches per thread, not 3.000.
>
     10000 rounds,
     7498.06 context switches pe thread
>
So never signal a condvar to multiple threads from outside !

So, do that. It's your software. Do what you like. This is a very old debate. Take your contrived test and just, roll with it. Whatever.
There's nothing to debate, I've measured it: If you awake a single
thread it doesn't matter if you awake from inside or outside, if you
awake multiple threads awakening them from inside is multiple times
faster.

Date Sujet#  Auteur
24 Apr 25 * Solving thundering Herd with glibc...19Chris M. Thomasson
24 Apr 25 `* Re: Solving thundering Herd with glibc...18Bonita Montero
24 Apr 25  +* Re: Solving thundering Herd with glibc...16Chris M. Thomasson
25 Apr 25  i`* Re: Solving thundering Herd with glibc...15Bonita Montero
25 Apr 25  i +* Re: Solving thundering Herd with glibc...7Bonita Montero
25 Apr 25  i i`* Re: Solving thundering Herd with glibc...6Chris M. Thomasson
26 Apr 25  i i `* Re: Solving thundering Herd with glibc...5Bonita Montero
26 Apr 25  i i  `* Re: Solving thundering Herd with glibc...4Bonita Montero
26 Apr 25  i i   `* Re: Solving thundering Herd with glibc...3Chris M. Thomasson
27 Apr 25  i i    `* Re: Solving thundering Herd with glibc...2Bonita Montero
29 Apr 25  i i     `- Re: Solving thundering Herd with glibc...1Chris M. Thomasson
14 May 25  i `* Re: Solving thundering Herd with glibc...7Vir Campestris
15 May 25  i  +- Re: Solving thundering Herd with glibc...1Chris M. Thomasson
15 May 25  i  +* Re: Solving thundering Herd with glibc...4David Brown
16 May 25  i  i`* Re: Solving thundering Herd with glibc...3candycanearter07
16 May 25  i  i `* Re: Solving thundering Herd with glibc...2David Brown
18 May20:20  i  i  `- Re: Solving thundering Herd with glibc...1candycanearter07
16 May 25  i  `- Re: Solving thundering Herd with glibc...1Bonita Montero
25 Apr 25  `- Re: Solving thundering Herd with glibc...1Bonita Montero

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal