| Deutsch English Français Italiano |
|
<vaosu6$3ra5a$4@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!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:20:22 -0700 Organization: A noiseless patient Spider Lines: 42 Message-ID: <vaosu6$3ra5a$4@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> <vaosod$3ra5a$2@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 29 Aug 2024 06:20:23 +0200 (CEST) Injection-Info: dont-email.me; posting-host="98c6004928f46df0abe90729ccf8af51"; logging-data="4040874"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19wXR2Avlzutg6k/s4Y+beu9RlG5ZsHugQ=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:Tn1L/eW95LHa+NBYBxiC6K9Z1EY= In-Reply-To: <vaosod$3ra5a$2@dont-email.me> Content-Language: en-US On 8/28/2024 9:17 PM, Chris M. Thomasson wrote: > 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 ); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Can be atomic store with memory_order_release in this context of your code. >>>> 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?