diff options
author | Tor Brede Vekterli <vekterli@yahooinc.com> | 2022-03-10 10:39:50 +0000 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@yahooinc.com> | 2022-03-10 10:43:21 +0000 |
commit | 97812f9ab0d32cfcea1271c5db29052ee21af2f9 (patch) | |
tree | 9860da3df4ebb3eceb06f5f8afc8d013a1e7ddd9 /searchcore | |
parent | 9ecddda1e37238420a0b1fe65ba701fdf79283cb (diff) |
Make LidAllocator active lid count (relaxed) atomic
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp | 6 | ||||
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h | 7 |
2 files changed, 7 insertions, 6 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp index 7633b5a32c0..4163b59b4ca 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.cpp @@ -75,7 +75,7 @@ LidAllocator::unregisterLid(DocId lid) _usedLids.clearBit(lid); if (_activeLids.testBit(lid)) { _activeLids.clearBit(lid); - _numActiveLids = _activeLids.count(); + _numActiveLids.store(_activeLids.count(), std::memory_order_relaxed); } } @@ -90,7 +90,7 @@ LidAllocator::unregister_lids(const std::vector<DocId>& lids) _usedLids.clear_bits(lids); assert(high < _activeLids.size()); _activeLids.consider_clear_bits(lids); - _numActiveLids = _activeLids.count(); + _numActiveLids.store(_activeLids.count(), std::memory_order_relaxed); } void @@ -237,7 +237,7 @@ LidAllocator::updateActiveLids(DocId lid, bool active) } else { _activeLids.clearBit(lid); } - _numActiveLids = _activeLids.count(); + _numActiveLids.store(_activeLids.count(), std::memory_order_relaxed); } } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h index 947192605e2..08fa4a6489a 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h @@ -6,6 +6,7 @@ #include "lidstatevector.h" #include <vespa/searchlib/attribute/attributeguard.h> #include <vespa/searchlib/queryeval/blueprint.h> +#include <atomic> namespace proton::documentmetastore { @@ -25,7 +26,7 @@ private: LidStateVector _pendingHoldLids; bool _lidFreeListConstructed; LidStateVector _activeLids; - uint32_t _numActiveLids; + std::atomic<uint32_t> _numActiveLids; public: LidAllocator(uint32_t size, @@ -54,8 +55,8 @@ public: void clearDocs(DocId lidLow, DocId lidLimit); void shrinkLidSpace(DocId committedDocIdLimit); uint32_t getNumUsedLids() const { return _usedLids.count(); } - uint32_t getNumActiveLids() const { - return _numActiveLids; + uint32_t getNumActiveLids() const noexcept { + return _numActiveLids.load(std::memory_order_relaxed); } void setFreeListConstructed() { _lidFreeListConstructed = true; |