diff options
author | Tor Egge <Tor.Egge@yahooinc.com> | 2022-03-28 11:29:25 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@yahooinc.com> | 2022-03-28 11:29:25 +0200 |
commit | 12f0eef92dd9633852088ffbdb598d2b705e1012 (patch) | |
tree | c78fd9aef7c08881bb8445150215d2642e2d1327 /searchlib | |
parent | bf003f9653c0ff3d139f4cbda93b0fbc7c62cfcc (diff) |
Use std::atomic_ref for lidinfo access in logdata store.
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/vespa/searchlib/docstore/logdatastore.cpp | 16 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/docstore/logdatastore.h | 3 |
2 files changed, 10 insertions, 9 deletions
diff --git a/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp b/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp index 2d62e1db6fd..a026b8b8e69 100644 --- a/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp +++ b/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp @@ -136,7 +136,7 @@ LogDataStore::read(const LidVector & lids, IBufferVisitor & visitor) const GenerationHandler::Guard guard(_genHandler.takeGuard()); for (uint32_t lid : lids) { if (lid < getDocIdLimit()) { - LidInfo li = _lidInfo[lid]; + LidInfo li = vespalib::atomic::load_ref_acquire(_lidInfo.acquire_elem_ref(lid)); if (!li.empty() && li.valid()) { orderedLids.emplace_back(li, lid); } @@ -168,7 +168,7 @@ LogDataStore::read(uint32_t lid, vespalib::DataBuffer& buffer) const LidInfo li(0); { GenerationHandler::Guard guard(_genHandler.takeGuard()); - li = _lidInfo[lid]; + li = vespalib::atomic::load_ref_acquire(_lidInfo.acquire_elem_ref(lid)); } if (!li.empty() && li.valid()) { const FileChunk & fc(*_fileChunks[li.getFileId()]); @@ -279,13 +279,13 @@ LogDataStore::remove(uint64_t serialNum, uint32_t lid) { MonitorGuard guard(_updateLock); if (lid < getDocIdLimit()) { - LidInfo lm = _lidInfo[lid]; + LidInfo lm = vespalib::atomic::load_ref_relaxed(_lidInfo[lid]); if (lm.valid()) { _fileChunks[lm.getFileId()]->remove(lid, lm.size()); } lm = getActive(guard).append(serialNum, lid, nullptr, 0, CpuCategory::WRITE); assert( lm.empty() ); - _lidInfo[lid] = lm; + vespalib::atomic::store_ref_release(_lidInfo[lid], lm); } } @@ -941,7 +941,7 @@ LogDataStore::setLid(const MonitorGuard &guard, uint32_t lid, const LidInfo &met if (lid < _lidInfo.size()) { _genHandler.updateFirstUsedGeneration(); _lidInfo.removeOldGenerations(_genHandler.getFirstUsedGeneration()); - const LidInfo &prev = _lidInfo[lid]; + const LidInfo prev = vespalib::atomic::load_ref_relaxed(_lidInfo[lid]); if (prev.valid()) { _fileChunks[prev.getFileId()]->remove(lid, prev.size()); } @@ -950,7 +950,7 @@ LogDataStore::setLid(const MonitorGuard &guard, uint32_t lid, const LidInfo &met incGeneration(); } updateDocIdLimit(lid + 1); - _lidInfo[lid] = meta; + vespalib::atomic::store_ref_release(_lidInfo[lid], meta); } void @@ -972,7 +972,7 @@ LogDataStore::computeNumberOfSignificantBucketIdBits(const IBucketizer & bucketi auto bucketizerGuard = bucketizer.getGuard(); GenerationHandler::Guard lidGuard(_genHandler.takeGuard()); for (size_t i(0), m(getDocIdLimit()); i < m; i++) { - LidInfo lid(_lidInfo[i]); + LidInfo lid(vespalib::atomic::load_ref_acquire(_lidInfo.acquire_elem_ref(i))); if (lid.valid() && (lid.getFileId() == fileId.getId())) { BucketId bucketId = bucketizer.getBucketOf(bucketizerGuard, i); size_t msbCount = vespalib::Optimized::msbIdx(bucketId.toKey()); @@ -1194,7 +1194,7 @@ LogDataStore::compactLidSpace(uint32_t wantedDocLidLimit) MonitorGuard guard(_updateLock); assert(wantedDocLidLimit <= getDocIdLimit()); for (size_t i = wantedDocLidLimit; i < _lidInfo.size(); ++i) { - _lidInfo[i] = LidInfo(); + vespalib::atomic::store_ref_release(_lidInfo[i], LidInfo()); } setDocIdLimit(wantedDocLidLimit); _compactLidSpaceGeneration = _genHandler.getCurrentGeneration(); diff --git a/searchlib/src/vespa/searchlib/docstore/logdatastore.h b/searchlib/src/vespa/searchlib/docstore/logdatastore.h index fc985c57ce4..daa29ac9475 100644 --- a/searchlib/src/vespa/searchlib/docstore/logdatastore.h +++ b/searchlib/src/vespa/searchlib/docstore/logdatastore.h @@ -8,6 +8,7 @@ #include <vespa/searchcommon/common/growstrategy.h> #include <vespa/searchlib/common/tunefileinfo.h> #include <vespa/searchlib/transactionlog/syncproxy.h> +#include <vespa/vespalib/util/atomic.h> #include <vespa/vespalib/util/compressionconfig.h> #include <vespa/vespalib/util/cpu_usage.h> #include <vespa/vespalib/util/executor.h> @@ -152,7 +153,7 @@ public: LidInfo getLid(const Guard & guard, uint32_t lid) const override { (void) guard; if (lid < getDocIdLimit()) { - return _lidInfo[lid]; + return vespalib::atomic::load_ref_acquire(_lidInfo.acquire_elem_ref(lid)); } else { return LidInfo(); } |