diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-10 12:36:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-10 12:36:32 +0100 |
commit | 64e30d389319f21f36807d5d404c6e740ce0ad9c (patch) | |
tree | faf97ee8174b40efac618dbb769109d1491e33c7 /searchcore | |
parent | dbb9019f183c7006b1d85301f25d6a0c01cab19c (diff) | |
parent | 97812f9ab0d32cfcea1271c5db29052ee21af2f9 (diff) |
Merge pull request #21628 from vespa-engine/vekterli/make-lid-allocator-active-lids-count-atomic
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; |