| Deutsch English Français Italiano |
|
<vui1np$1tfb1$1@raubtier-asyl.eternal-september.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita Montero <Bonita.Montero@gmail.com>
Newsgroups: comp.lang.c++
Subject: Re: Solving thundering Herd with glibc...
Date: Sat, 26 Apr 2025 09:25:22 +0200
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <vui1np$1tfb1$1@raubtier-asyl.eternal-september.org>
References: <vue7i0$2btp7$1@dont-email.me>
<vue9bf$2dodm$2@raubtier-asyl.eternal-september.org>
<vueanl$2erl6$1@dont-email.me>
<vufhi7$3jcg6$1@raubtier-asyl.eternal-september.org>
<vufrhn$3s5jj$1@raubtier-asyl.eternal-september.org>
<vugpmh$nndj$1@dont-email.me>
<vuhu95$1qaap$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 26 Apr 2025 09:24:42 +0200 (CEST)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="2f836394b1e3ebd027fa233d5ba61fe5";
logging-data="2014561"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CtV1hladSyEOpTaQatwfFUA5fXMvGfcc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:1/IYw6F+LELeeBMT+eL8gq8bTn0=
In-Reply-To: <vuhu95$1qaap$1@raubtier-asyl.eternal-september.org>
Content-Language: de-DE
Am 26.04.2025 um 08:26 schrieb Bonita Montero:
> Am 25.04.2025 um 22:01 schrieb Chris M. Thomasson:
>
> > If you say so... Too busy right now. Perhaps sometime later on tonight.
>
>
> If there would be a thundering herd problem with glibc's condvar it
> would happen very often with my code since I awake 31 threads at once
> with my machine.
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 !