From 103903be8e1c5e2dfd015c0492169499bcf7889f Mon Sep 17 00:00:00 2001 From: Peisong Xiao Date: Sun, 4 Jan 2026 12:00:43 -0500 Subject: [PATCH] [UNTESTED] optimized atomics for fan-out --- include/weaver.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/weaver.h b/include/weaver.h index 3724d99..9cd708e 100644 --- a/include/weaver.h +++ b/include/weaver.h @@ -484,8 +484,8 @@ class FanOutFabric { for (std::size_t i = head; i != tail; i = ((i + 1) & CONSUMER_QSIZE_MASK)) { - RefCountType cnt = - buffer[qbuffer[i]].count.fetch_sub(1); + RefCountType cnt = buffer[qbuffer[i]].count.fetch_sub( + 1, std::memory_order_relaxed); if (cnt == 1 && dealloc_try(qbuffer[i]) != FanOutFabricDeallocResult::Ok) @@ -547,7 +547,8 @@ class FanOutFabric { THREAD_BITMAP_MASK; } - buffer[slot].count.fetch_sub(failed_cnt); + buffer[slot].count.fetch_sub(failed_cnt, + std::memory_order_relaxed); if (try_cnt == failed_cnt) { fs.push(slot); @@ -609,7 +610,7 @@ class FanOutFabric { } if (reclaim_cnt >= budget && - !reclaim_queues[idx].is_empty()) + head != reclaim_queues[idx].get_tail()) reclaim_hint.fetch_or( BitmapType(1) << idx, std::memory_order_relaxed); @@ -639,7 +640,7 @@ class FanOutFabric { } if (reclaim_cnt >= budget && - !reclaim_queues[idx].is_empty()) + head != reclaim_queues[idx].get_tail()) reclaim_hint.fetch_or( BitmapType(1) << idx, std::memory_order_relaxed);