Path: ...!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: jseigh Newsgroups: comp.lang.c++ Subject: Re: smrproxy v2 Date: Tue, 29 Oct 2024 07:27:40 -0400 Organization: A noiseless patient Spider Lines: 30 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Tue, 29 Oct 2024 12:27:40 +0100 (CET) Injection-Info: dont-email.me; posting-host="ac8ee95b19a1901ed81555f68070b1d5"; logging-data="1621761"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/E98tBx8DmQ82WvxcLa/Fb" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:Bzh8ADa+m22nXsewJVLJ1xz5iVI= In-Reply-To: Content-Language: en-US Bytes: 2512 On 10/29/24 00:38, Chris M. Thomasson wrote: > On 10/28/2024 6:17 PM, jseigh wrote: >> On 10/28/24 17:57, Chris M. Thomasson wrote: >>> On 10/28/2024 4:45 AM, jseigh wrote: >> >> fwiw, here's the lock and unlock logic from smrproxy rewrite >> >>      inline void lock() >>      { >>          epoch_t _epoch = shadow_epoch.load(std::memory_order_relaxed); >>          _ref_epoch.store(_epoch, std::memory_order_relaxed); >>          std::atomic_signal_fence(std::memory_order_acquire); >>      } >> >>      inline void unlock() >>      { >>          _ref_epoch.store(0, std::memory_order_release); >>      } >> >> epoch_t is interesting.  It's uint64_t but handles wrapped >> compares, ie. for an epoch_t x1 and uint64_t n > > Only your single polling thread can mutate the shadow_epoch, right? > Yes. It's just an optimization. The reader threads could read from the global epoch but it would be in a separate cache line and be an extra dependent load. So one dependent load and same cache line.