| Deutsch English Français Italiano |
|
<vur95i$2gada$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Newsgroups: comp.lang.c++
Subject: Re: Solving thundering Herd with glibc...
Date: Tue, 29 Apr 2025 12:26:41 -0700
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <vur95i$2gada$1@dont-email.me>
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>
<vui1np$1tfb1$1@raubtier-asyl.eternal-september.org>
<vujjub$388jv$1@dont-email.me>
<vuk7k0$3th9g$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 29 Apr 2025 21:26:42 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="dbdb37fffe3643a23b75089f628d1828";
logging-data="2632106"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/aJBPqk/hzcrh9qzP83aYQOESMxpimle4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:lAICJvlmomUVuAEpuRDQF+keA5M=
In-Reply-To: <vuk7k0$3th9g$1@raubtier-asyl.eternal-september.org>
Content-Language: en-US
Bytes: 2861
On 4/26/2025 8:18 PM, Bonita Montero wrote:
> 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.
>
Yawn.