Deutsch English Français Italiano |
<vaosod$3ra5a$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.nobody.at!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> Newsgroups: comp.lang.c++ Subject: Re: Futexes ain't fast Date: Wed, 28 Aug 2024 21:17:16 -0700 Organization: A noiseless patient Spider Lines: 28 Message-ID: <vaosod$3ra5a$2@dont-email.me> References: <van414$3fe9t$1@raubtier-asyl.eternal-september.org> <vanrkt$3j1oq$1@dont-email.me> <vaor7n$3r4u5$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: Thu, 29 Aug 2024 06:17:17 +0200 (CEST) Injection-Info: dont-email.me; posting-host="98c6004928f46df0abe90729ccf8af51"; logging-data="4040874"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19oxCrbl9F3QslnIyxwOTxJMQ89MVsjG5g=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:77PMZHIQBOaOiRRmNnSXQm7zFvk= Content-Language: en-US In-Reply-To: <vaor7n$3r4u5$1@raubtier-asyl.eternal-september.org> Bytes: 2507 On 8/28/2024 8:51 PM, Bonita Montero wrote: > Am 28.08.2024 um 20:52 schrieb Chris M. Thomasson: >> On 8/28/2024 5:09 AM, Bonita Montero wrote: >>> I tested the operating-system specific mutex (CRITICAL_SECTION Or >>> pthread_mutext_t) against a futex and a std::mutex. I guessed std::mutex >>> uses th operating system specific mutex internally, but the times varied >>> so much across Windows and Linux that I gues that std::mutex used at >>> least a differently parametrized operating system mutex or maybe even >>> completely own code. >>> This are the times and each line has a further contender: >> [...] >>> while( futex.exchange( true, memory_order_acquire ) ) >>> futex.wait( true, memory_order_relaxed ); >>> futex.exchange( false, memory_order_release ); >>> futex.notify_one(); >>> } ); >> [...] >> >> A wait bit would help out here... ;^) Afaict, this is a rather "naive" >> use of futexes. In you use case here, the exchange to unlock can be a >> simple atomic store with release semantics. Also, try to think about >> calling notify_* only when you absolutely need to... :^) > > Show me your code ... > I did a while back for a futex mutex, win32 impl iirc... Do I have to find the older code?