Deutsch English Français Italiano |
<vaosr5$3ra5a$3@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!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:18:45 -0700 Organization: A noiseless patient Spider Lines: 35 Message-ID: <vaosr5$3ra5a$3@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:18:46 +0200 (CEST) Injection-Info: dont-email.me; posting-host="98c6004928f46df0abe90729ccf8af51"; logging-data="4040874"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1vwvLe42j6RB/qXPLTHuNA673c53MWgE=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:MMQu9FUYWRSL0aumSUQ91r4CoSg= Content-Language: en-US In-Reply-To: <vaosod$3ra5a$2@dont-email.me> Bytes: 2763 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 ); >>>> 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? Lets see... It's a bit hard to find for some reason: https://groups.google.com/g/comp.lang.c++/c/1MZvhswJ6DQ/m/qyaYH-i0CgAJ