diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-11-11 20:24:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-11 20:24:47 +0100 |
commit | 40745cf24820bb0b0b0d28259bb5115ed5b068eb (patch) | |
tree | 209956d61d03c155a6a87801f3fd5814c34ed0e9 | |
parent | db842ccc0b246d454f90c6ff8fefec854a7e407e (diff) | |
parent | 09409ebbd3e9c107ead67b488cbe8b918fc2c91a (diff) |
Merge pull request #19981 from vespa-engine/balder/improve-inlining-probability
Remove double book keeping of count.
3 files changed, 6 insertions, 32 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.cpp index 6bc90033994..49e8d3eb23a 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.cpp @@ -13,7 +13,6 @@ LidStateVector::LidStateVector(unsigned int newSize, unsigned int newCapacity, : _bv(newSize, newCapacity, generationHolder), _lowest(trackLowest ? newSize : 0u), _highest(0), - _count(0u), _trackLowest(trackLowest), _trackHighest(trackHighest) { @@ -29,16 +28,12 @@ LidStateVector::resizeVector(uint32_t newSize, uint32_t newCapacity) bool nolowest(_lowest == _bv.size()); if (_bv.size() > newSize) { _bv.shrink(newSize); - assert(_count >= internalCount()); - _count = internalCount(); } if (_bv.capacity() < newCapacity) { _bv.reserve(newCapacity); - assert(_count == internalCount()); } if (_bv.size() < newSize) { _bv.extend(newSize); - assert(_count == internalCount()); } if (_trackLowest) { if (nolowest) { @@ -57,7 +52,6 @@ LidStateVector::resizeVector(uint32_t newSize, uint32_t newCapacity) maybeUpdateHighest(); } - void LidStateVector::updateLowest() { @@ -70,7 +64,6 @@ LidStateVector::updateLowest() _lowest = lowest; } - void LidStateVector::updateHighest() { @@ -83,7 +76,6 @@ LidStateVector::updateHighest() _highest = highest; } - void LidStateVector::setBit(unsigned int idx) { @@ -96,28 +88,16 @@ LidStateVector::setBit(unsigned int idx) } assert(!_bv.testBit(idx)); _bv.setBitAndMaintainCount(idx); - ++_count; - assert(_count == internalCount()); } - void LidStateVector::clearBit(unsigned int idx) { assert(idx < _bv.size()); assert(_bv.testBit(idx)); _bv.clearBitAndMaintainCount(idx); - --_count; - assert(_count == internalCount()); maybeUpdateLowest(); maybeUpdateHighest(); } -uint32_t -LidStateVector::internalCount() -{ - // Called by document db executor thread. - return _bv.countTrueBits(); -} - } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.h index 20fff60911c..be47676716b 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lidstatevector.h @@ -11,9 +11,8 @@ class LidStateVector search::GrowableBitVector _bv; uint32_t _lowest; uint32_t _highest; - uint32_t _count; - bool _trackLowest; - bool _trackHighest; + bool _trackLowest; + bool _trackHighest; void updateLowest(); void updateHighest(); @@ -26,12 +25,6 @@ class LidStateVector if (_trackHighest && _highest != 0 && !_bv.testBit(_highest)) updateHighest(); } - - /** - * Get number of bits set in vector. Should only be called by - * write thread. - */ - uint32_t internalCount(); public: LidStateVector(unsigned int newSize, unsigned int newCapacity, @@ -48,7 +41,7 @@ public: unsigned int byteSize() const { return _bv.extraByteSize() + sizeof(LidStateVector); } - bool empty() const { return _count == 0u; } + bool empty() const { return count() == 0u; } unsigned int getLowest() const { return _lowest; } unsigned int getHighest() const { return _highest; } @@ -58,7 +51,7 @@ public: */ uint32_t count() const { // Called by document db executor thread or metrics related threads - return _count; + return _bv.countTrueBits(); } unsigned int getNextTrueBit(unsigned int idx) const { diff --git a/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp b/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp index 80c6549499d..d428ce52953 100644 --- a/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp +++ b/searchlib/src/vespa/searchlib/common/allocatedbitvector.cpp @@ -157,8 +157,9 @@ AllocatedBitVector::grow(Index newSize, Index newCapacity) setSize(newSize); clearIntervalNoInvalidation(clearRange); } else { - clearInterval(newSize, size()); + clearIntervalNoInvalidation(Range(newSize, size())); setSize(newSize); + updateCount(); } } return ret; |