diff options
42 files changed, 141 insertions, 143 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp index c6ef6994b81..ead9f142508 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp @@ -241,20 +241,20 @@ DocumentMetaStore::onUpdateStat() } void -DocumentMetaStore::onGenerationChange(generation_t generation) +DocumentMetaStore::before_inc_generation(generation_t current_gen) { _gidToLidMap.getAllocator().freeze(); - _gidToLidMap.getAllocator().assign_generation(generation - 1); - getGenerationHolder().assign_generation(generation - 1); + _gidToLidMap.getAllocator().assign_generation(current_gen); + getGenerationHolder().assign_generation(current_gen); updateStat(false); } void -DocumentMetaStore::removeOldGenerations(generation_t firstUsed) +DocumentMetaStore::reclaim_memory(generation_t oldest_used_gen) { - _gidToLidMap.getAllocator().reclaim_memory(firstUsed); - _lidAlloc.reclaim_memory(firstUsed); - getGenerationHolder().reclaim(firstUsed); + _gidToLidMap.getAllocator().reclaim_memory(oldest_used_gen); + _lidAlloc.reclaim_memory(oldest_used_gen); + getGenerationHolder().reclaim(oldest_used_gen); } std::unique_ptr<search::AttributeSaver> diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h index c4010a07709..2dc85f07cf4 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.h @@ -93,8 +93,8 @@ private: void onUpdateStat() override; // Implements AttributeVector - void onGenerationChange(generation_t generation) override; - void removeOldGenerations(generation_t firstUsed) override; + void before_inc_generation(generation_t current_gen) override; + void reclaim_memory(generation_t oldest_used_gen) override; std::unique_ptr<search::AttributeSaver> onInitSave(vespalib::stringref fileName) override; bool onLoad(vespalib::Executor *executor) override; diff --git a/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp b/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp index 938a7fb35d7..8b8f4d2c4d4 100644 --- a/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp +++ b/searchlib/src/tests/attribute/multi_value_mapping/multi_value_mapping_test.cpp @@ -41,11 +41,11 @@ class MyAttribute : public search::NotImplementedAttribute _mvMapping.shrink(committedDocIdLimit); setNumDocs(committedDocIdLimit); } - virtual void removeOldGenerations(generation_t firstUsed) override { - _mvMapping.reclaim_memory(firstUsed); + virtual void reclaim_memory(generation_t oldest_used_gen) override { + _mvMapping.reclaim_memory(oldest_used_gen); } - virtual void onGenerationChange(generation_t generation) override { - _mvMapping.assign_generation(generation - 1); + virtual void before_inc_generation(generation_t current_gen) override { + _mvMapping.assign_generation(current_gen); } public: diff --git a/searchlib/src/tests/attribute/postinglist/postinglist.cpp b/searchlib/src/tests/attribute/postinglist/postinglist.cpp index e41aaec351e..1eed3a015e1 100644 --- a/searchlib/src/tests/attribute/postinglist/postinglist.cpp +++ b/searchlib/src/tests/attribute/postinglist/postinglist.cpp @@ -201,7 +201,7 @@ private: PostingListNodeAllocator &postingsAlloc); void - removeOldGenerations(Tree &tree, + reclaim_memory(Tree &tree, ValueHandle &valueHandle, PostingList &postings, PostingListNodeAllocator &postingsAlloc); @@ -665,7 +665,7 @@ bumpGeneration(Tree &tree, void AttributePostingListTest:: -removeOldGenerations(Tree &tree, +reclaim_memory(Tree &tree, ValueHandle &valueHandle, PostingList &postings, PostingListNodeAllocator &postingsAlloc) diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp index 876830bb186..100470b5a5f 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp @@ -184,7 +184,7 @@ void AttributeVector::incGeneration() { // Freeze trees etc, to stop new readers from accessing currently held data - onGenerationChange(_genHandler.getNextGeneration()); + before_inc_generation(_genHandler.getCurrentGeneration()); _genHandler.incGeneration(); // Remove old data on hold lists that can no longer be reached by readers removeAllOldGenerations(); @@ -237,8 +237,8 @@ AttributeVector::headerTypeOK(const vespalib::GenericHeader &header) const getConfig().collectionType().asString(); } -void AttributeVector::removeOldGenerations(generation_t firstUsed) { (void) firstUsed; } -void AttributeVector::onGenerationChange(generation_t generation) { (void) generation; } +void AttributeVector::reclaim_memory(generation_t oldest_used_gen) { (void) oldest_used_gen; } +void AttributeVector::before_inc_generation(generation_t current_gen) { (void) current_gen; } const IEnumStore* AttributeVector::getEnumStoreBase() const { return nullptr; } IEnumStore* AttributeVector::getEnumStoreBase() { return nullptr; } const attribute::MultiValueMappingBase * AttributeVector::getMultiValueBase() const { return nullptr; } @@ -410,7 +410,7 @@ bool AttributeVector::applyWeight(DocId, const FieldValue&, const AssignValueUpd void AttributeVector::removeAllOldGenerations() { _genHandler.update_oldest_used_generation(); - removeOldGenerations(_genHandler.get_oldest_used_generation()); + reclaim_memory(_genHandler.get_oldest_used_generation()); } diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h index 4d4cd8ac35f..6963814be0c 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.h +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h @@ -446,8 +446,8 @@ private: GenerationHandler::Guard takeGenerationGuard() { return _genHandler.takeGuard(); } /// Clean up [0, firstUsed> - virtual void removeOldGenerations(generation_t firstUsed); - virtual void onGenerationChange(generation_t generation); + virtual void reclaim_memory(generation_t oldest_used_gen); + virtual void before_inc_generation(generation_t current_gen); virtual void onUpdateStat() = 0; /** * Used to regulate access to critical resources. Apply the diff --git a/searchlib/src/vespa/searchlib/attribute/flagattribute.cpp b/searchlib/src/vespa/searchlib/attribute/flagattribute.cpp index df75b0ab4e5..f8cf742bdb2 100644 --- a/searchlib/src/vespa/searchlib/attribute/flagattribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/flagattribute.cpp @@ -229,10 +229,10 @@ FlagAttributeT<B>::resizeBitVectors(uint32_t neededSize) template <typename B> void -FlagAttributeT<B>::removeOldGenerations(vespalib::GenerationHandler::generation_t firstUsed) +FlagAttributeT<B>::reclaim_memory(vespalib::GenerationHandler::generation_t oldest_used_gen) { - B::removeOldGenerations(firstUsed); - _bitVectorHolder.reclaim(firstUsed); + B::reclaim_memory(oldest_used_gen); + _bitVectorHolder.reclaim(oldest_used_gen); } template class FlagAttributeT<FlagBaseImpl>; diff --git a/searchlib/src/vespa/searchlib/attribute/flagattribute.h b/searchlib/src/vespa/searchlib/attribute/flagattribute.h index 796c1493cc9..df75e7afa04 100644 --- a/searchlib/src/vespa/searchlib/attribute/flagattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/flagattribute.h @@ -33,7 +33,7 @@ private: void ensureGuardBit(); void clearGuardBit(DocId doc); void resizeBitVectors(uint32_t neededSize); - void removeOldGenerations(vespalib::GenerationHandler::generation_t firstUsed) override; + void reclaim_memory(vespalib::GenerationHandler::generation_t oldest_used_gen) override; uint32_t getOffset(int8_t value) const { return value + 128; } using AtomicBitVectorPtr = vespalib::datastore::AtomicValueWrapper<BitVector *>; diff --git a/searchlib/src/vespa/searchlib/attribute/multienumattribute.h b/searchlib/src/vespa/searchlib/attribute/multienumattribute.h index ee8f3181fd9..a073060afc5 100644 --- a/searchlib/src/vespa/searchlib/attribute/multienumattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/multienumattribute.h @@ -63,8 +63,8 @@ public: void onCommit() override; void onUpdateStat() override; - void removeOldGenerations(generation_t firstUsed) override; - void onGenerationChange(generation_t generation) override; + void reclaim_memory(generation_t oldest_used_gen) override; + void before_inc_generation(generation_t current_gen) override; //----------------------------------------------------------------------------------------------------------------- // Attribute read API diff --git a/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp index ad827d0fd85..4dad82073e0 100644 --- a/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp @@ -194,15 +194,15 @@ MultiValueEnumAttribute<B, M>::onUpdateStat() template <typename B, typename M> void -MultiValueEnumAttribute<B, M>::removeOldGenerations(generation_t firstUsed) +MultiValueEnumAttribute<B, M>::reclaim_memory(generation_t oldest_used_gen) { - this->_enumStore.reclaim_memory(firstUsed); - this->_mvMapping.reclaim_memory(firstUsed); + this->_enumStore.reclaim_memory(oldest_used_gen); + this->_mvMapping.reclaim_memory(oldest_used_gen); } template <typename B, typename M> void -MultiValueEnumAttribute<B, M>::onGenerationChange(generation_t generation) +MultiValueEnumAttribute<B, M>::before_inc_generation(generation_t current_gen) { /* * Freeze tree before generation is increased in attribute vector @@ -211,8 +211,8 @@ MultiValueEnumAttribute<B, M>::onGenerationChange(generation_t generation) * sufficiently new frozen tree. */ freezeEnumDictionary(); - this->_mvMapping.assign_generation(generation - 1); - this->_enumStore.assign_generation(generation - 1); + this->_mvMapping.assign_generation(current_gen); + this->_enumStore.assign_generation(current_gen); } template <typename B, typename M> diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h index 0a29b4af48d..ed78f7776f1 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h @@ -60,9 +60,9 @@ public: uint32_t getValueCount(DocId doc) const override; void onCommit() override; void onUpdateStat() override; - void removeOldGenerations(generation_t firstUsed) override; + void reclaim_memory(generation_t oldest_used_gen) override; - void onGenerationChange(generation_t generation) override; + void before_inc_generation(generation_t current_gen) override; bool onLoad(vespalib::Executor *executor) override; virtual bool onLoadEnumerated(ReaderBase &attrReader); diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp index 2405841f331..b746fa5d555 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp @@ -96,16 +96,16 @@ void MultiValueNumericAttribute<B, M>::setNewValues(DocId doc, const std::vector } template <typename B, typename M> -void MultiValueNumericAttribute<B, M>::removeOldGenerations(generation_t firstUsed) +void MultiValueNumericAttribute<B, M>::reclaim_memory(generation_t oldest_used_gen) { - this->_mvMapping.reclaim_memory(firstUsed); + this->_mvMapping.reclaim_memory(oldest_used_gen); } template <typename B, typename M> -void MultiValueNumericAttribute<B, M>::onGenerationChange(generation_t generation) +void MultiValueNumericAttribute<B, M>::before_inc_generation(generation_t current_gen) { - this->_mvMapping.assign_generation(generation - 1); + this->_mvMapping.assign_generation(current_gen); } template <typename B, typename M> diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h index 4bd8ad6e99f..a22a6241ab2 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.h @@ -80,8 +80,8 @@ public: MultiValueNumericPostingAttribute(const vespalib::string & name, const AttributeVector::Config & cfg); ~MultiValueNumericPostingAttribute(); - void removeOldGenerations(generation_t firstUsed) override; - void onGenerationChange(generation_t generation) override; + void reclaim_memory(generation_t oldest_used_gen) override; + void before_inc_generation(generation_t current_gen) override; std::unique_ptr<attribute::SearchContext> getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override; diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp index 70a438f1551..deee72dcf39 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp @@ -56,19 +56,19 @@ MultiValueNumericPostingAttribute<B, M>::~MultiValueNumericPostingAttribute() template <typename B, typename M> void -MultiValueNumericPostingAttribute<B, M>::removeOldGenerations(generation_t firstUsed) +MultiValueNumericPostingAttribute<B, M>::reclaim_memory(generation_t oldest_used_gen) { - MultiValueNumericEnumAttribute<B, M>::removeOldGenerations(firstUsed); - _postingList.reclaim_memory(firstUsed); + MultiValueNumericEnumAttribute<B, M>::reclaim_memory(oldest_used_gen); + _postingList.reclaim_memory(oldest_used_gen); } template <typename B, typename M> void -MultiValueNumericPostingAttribute<B, M>::onGenerationChange(generation_t generation) +MultiValueNumericPostingAttribute<B, M>::before_inc_generation(generation_t current_gen) { _postingList.freeze(); - MultiValueNumericEnumAttribute<B, M>::onGenerationChange(generation); - _postingList.assign_generation(generation - 1); + MultiValueNumericEnumAttribute<B, M>::before_inc_generation(current_gen); + _postingList.assign_generation(current_gen); } template <typename B, typename M> diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h index 4deb71e9759..2e355a9aed2 100644 --- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.h @@ -77,8 +77,8 @@ public: MultiValueStringPostingAttributeT(const vespalib::string & name); ~MultiValueStringPostingAttributeT(); - void removeOldGenerations(generation_t firstUsed) override; - void onGenerationChange(generation_t generation) override; + void reclaim_memory(generation_t oldest_used_gen) override; + void before_inc_generation(generation_t current_gen) override; std::unique_ptr<attribute::SearchContext> getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override; diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp index 9bc2c31b163..cfd00f84636 100644 --- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp @@ -75,19 +75,19 @@ MultiValueStringPostingAttributeT<B, T>::mergeMemoryStats(vespalib::MemoryUsage template <typename B, typename T> void -MultiValueStringPostingAttributeT<B, T>::removeOldGenerations(generation_t firstUsed) +MultiValueStringPostingAttributeT<B, T>::reclaim_memory(generation_t oldest_used_gen) { - MultiValueStringAttributeT<B, T>::removeOldGenerations(firstUsed); - _postingList.reclaim_memory(firstUsed); + MultiValueStringAttributeT<B, T>::reclaim_memory(oldest_used_gen); + _postingList.reclaim_memory(oldest_used_gen); } template <typename B, typename T> void -MultiValueStringPostingAttributeT<B, T>::onGenerationChange(generation_t generation) +MultiValueStringPostingAttributeT<B, T>::before_inc_generation(generation_t current_gen) { _postingList.freeze(); - MultiValueStringAttributeT<B, T>::onGenerationChange(generation); - _postingList.assign_generation(generation - 1); + MultiValueStringAttributeT<B, T>::before_inc_generation(current_gen); + _postingList.assign_generation(current_gen); } diff --git a/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp index 8593b013443..f34099de758 100644 --- a/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp @@ -125,17 +125,17 @@ PredicateAttribute::onUpdateStat() } void -PredicateAttribute::removeOldGenerations(generation_t firstUsed) +PredicateAttribute::reclaim_memory(generation_t oldest_used_gen) { - getGenerationHolder().reclaim(firstUsed); - _index->reclaim_memory(firstUsed); + getGenerationHolder().reclaim(oldest_used_gen); + _index->reclaim_memory(oldest_used_gen); } void -PredicateAttribute::onGenerationChange(generation_t generation) +PredicateAttribute::before_inc_generation(generation_t current_gen) { - getGenerationHolder().assign_generation(generation - 1); - _index->assign_generation(generation - 1); + getGenerationHolder().assign_generation(current_gen); + _index->assign_generation(current_gen); } void diff --git a/searchlib/src/vespa/searchlib/attribute/predicate_attribute.h b/searchlib/src/vespa/searchlib/attribute/predicate_attribute.h index f5d789298a0..159e71e99e3 100644 --- a/searchlib/src/vespa/searchlib/attribute/predicate_attribute.h +++ b/searchlib/src/vespa/searchlib/attribute/predicate_attribute.h @@ -48,8 +48,8 @@ public: void onSave(IAttributeSaveTarget & saveTarget) override; bool onLoad(vespalib::Executor *executor) override; void onCommit() override; - void removeOldGenerations(generation_t firstUsed) override; - void onGenerationChange(generation_t generation) override; + void reclaim_memory(generation_t oldest_used_gen) override; + void before_inc_generation(generation_t current_gen) override; void onUpdateStat() override; bool addDoc(DocId &doc_id) override; uint32_t clearDoc(DocId doc_id) override; diff --git a/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp index aa884e1e298..e620d3aca72 100644 --- a/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp @@ -161,21 +161,21 @@ ReferenceAttribute::clearDoc(DocId doc) } void -ReferenceAttribute::removeOldGenerations(generation_t firstUsed) +ReferenceAttribute::reclaim_memory(generation_t oldest_used_gen) { - _referenceMappings.reclaim_memory(firstUsed); - _store.reclaim_memory(firstUsed); - getGenerationHolder().reclaim(firstUsed); + _referenceMappings.reclaim_memory(oldest_used_gen); + _store.reclaim_memory(oldest_used_gen); + getGenerationHolder().reclaim(oldest_used_gen); } void -ReferenceAttribute::onGenerationChange(generation_t generation) +ReferenceAttribute::before_inc_generation(generation_t current_gen) { _referenceMappings.freeze(); _store.freeze(); - _referenceMappings.assign_generation(generation - 1); - _store.assign_generation(generation - 1); - getGenerationHolder().assign_generation(generation - 1); + _referenceMappings.assign_generation(current_gen); + _store.assign_generation(current_gen); + getGenerationHolder().assign_generation(current_gen); } void diff --git a/searchlib/src/vespa/searchlib/attribute/reference_attribute.h b/searchlib/src/vespa/searchlib/attribute/reference_attribute.h index dc3e2ad729a..e0ae906eb23 100644 --- a/searchlib/src/vespa/searchlib/attribute/reference_attribute.h +++ b/searchlib/src/vespa/searchlib/attribute/reference_attribute.h @@ -50,8 +50,8 @@ private: ReferenceMappings _referenceMappings; void onAddDocs(DocId docIdLimit) override; - void removeOldGenerations(generation_t firstUsed) override; - void onGenerationChange(generation_t generation) override; + void reclaim_memory(generation_t oldest_used_gen) override; + void before_inc_generation(generation_t current_gen) override; void onCommit() override; void onUpdateStat() override; std::unique_ptr<AttributeSaver> onInitSave(vespalib::stringref fileName) override; diff --git a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp index 6e07a9e658e..ac05ab3b7c6 100644 --- a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp @@ -257,13 +257,13 @@ SingleBoolAttribute::getEstimatedSaveByteSize() const } void -SingleBoolAttribute::removeOldGenerations(generation_t firstUsed) { - getGenerationHolder().reclaim(firstUsed); +SingleBoolAttribute::reclaim_memory(generation_t oldest_used_gen) { + getGenerationHolder().reclaim(oldest_used_gen); } void -SingleBoolAttribute::onGenerationChange(generation_t generation) { - getGenerationHolder().assign_generation(generation - 1); +SingleBoolAttribute::before_inc_generation(generation_t current_gen) { + getGenerationHolder().assign_generation(current_gen); } } diff --git a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h index 7868c228e77..a02d5c7d80d 100644 --- a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h @@ -28,8 +28,8 @@ public: void onSave(IAttributeSaveTarget &saveTarget) override; void clearDocs(DocId lidLow, DocId lidLimit, bool in_shrink_lid_space) override; void onShrinkLidSpace() override; - void removeOldGenerations(generation_t firstUsed) override; - void onGenerationChange(generation_t generation) override; + void reclaim_memory(generation_t oldest_used_gen) override; + void before_inc_generation(generation_t current_gen) override; uint64_t getEstimatedSaveByteSize() const override; std::unique_ptr<attribute::SearchContext> diff --git a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.h b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.h index 6e46c697fbc..dbf3e4e7c58 100644 --- a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.h @@ -111,8 +111,8 @@ public: uint32_t getValueCount(DocId doc) const override; void onCommit() override; void onUpdateStat() override; - void removeOldGenerations(generation_t firstUsed) override; - void onGenerationChange(generation_t generation) override; + void reclaim_memory(generation_t oldest_used_gen) override; + void before_inc_generation(generation_t current_gen) override; EnumHandle getEnum(DocId doc) const override { return getE(doc); } diff --git a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp index f0649224b89..dd400295b3d 100644 --- a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp @@ -264,15 +264,15 @@ SingleValueEnumAttribute<B>::load_enumerated_data(ReaderBase& attrReader, template <typename B> void -SingleValueEnumAttribute<B>::removeOldGenerations(generation_t firstUsed) +SingleValueEnumAttribute<B>::reclaim_memory(generation_t oldest_used_gen) { - this->_enumStore.reclaim_memory(firstUsed); - getGenerationHolder().reclaim(firstUsed); + this->_enumStore.reclaim_memory(oldest_used_gen); + getGenerationHolder().reclaim(oldest_used_gen); } template <typename B> void -SingleValueEnumAttribute<B>::onGenerationChange(generation_t generation) +SingleValueEnumAttribute<B>::before_inc_generation(generation_t current_gen) { /* * Freeze tree before generation is increased in attribute vector @@ -281,8 +281,8 @@ SingleValueEnumAttribute<B>::onGenerationChange(generation_t generation) * sufficiently new frozen tree. */ freezeEnumDictionary(); - getGenerationHolder().assign_generation(generation - 1); - this->_enumStore.assign_generation(generation - 1); + getGenerationHolder().assign_generation(current_gen); + this->_enumStore.assign_generation(current_gen); } diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h b/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h index fd2767eaee1..c6387323fea 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.h @@ -55,8 +55,8 @@ public: void onCommit() override; void onAddDocs(DocId lidLimit) override; void onUpdateStat() override; - void removeOldGenerations(generation_t firstUsed) override; - void onGenerationChange(generation_t generation) override; + void reclaim_memory(generation_t oldest_used_gen) override; + void before_inc_generation(generation_t current_gen) override; bool addDoc(DocId & doc) override; bool onLoad(vespalib::Executor *executor) override; diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.hpp index bbacc10e79c..66af5fe4adc 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/singlenumericattribute.hpp @@ -95,16 +95,16 @@ SingleValueNumericAttribute<B>::addDoc(DocId & doc) { template <typename B> void -SingleValueNumericAttribute<B>::removeOldGenerations(generation_t firstUsed) +SingleValueNumericAttribute<B>::reclaim_memory(generation_t oldest_used_gen) { - getGenerationHolder().reclaim(firstUsed); + getGenerationHolder().reclaim(oldest_used_gen); } template <typename B> void -SingleValueNumericAttribute<B>::onGenerationChange(generation_t generation) +SingleValueNumericAttribute<B>::before_inc_generation(generation_t current_gen) { - getGenerationHolder().assign_generation(generation - 1); + getGenerationHolder().assign_generation(current_gen); } template <typename B> diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h index 720fb211e1a..f2343c1a57c 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.h @@ -69,8 +69,8 @@ public: SingleValueNumericPostingAttribute(const vespalib::string & name, const AttributeVector::Config & cfg); ~SingleValueNumericPostingAttribute(); - void removeOldGenerations(generation_t firstUsed) override; - void onGenerationChange(generation_t generation) override; + void reclaim_memory(generation_t oldest_used_gen) override; + void before_inc_generation(generation_t current_gen) override; std::unique_ptr<attribute::SearchContext> getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override; diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp index c5acc0c360a..1775774171d 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp @@ -127,19 +127,19 @@ SingleValueNumericPostingAttribute<B>::applyValueChanges(EnumStoreBatchUpdater& template <typename B> void -SingleValueNumericPostingAttribute<B>::removeOldGenerations(generation_t firstUsed) +SingleValueNumericPostingAttribute<B>::reclaim_memory(generation_t oldest_used_gen) { - SingleValueNumericEnumAttribute<B>::removeOldGenerations(firstUsed); - _postingList.reclaim_memory(firstUsed); + SingleValueNumericEnumAttribute<B>::reclaim_memory(oldest_used_gen); + _postingList.reclaim_memory(oldest_used_gen); } template <typename B> void -SingleValueNumericPostingAttribute<B>::onGenerationChange(generation_t generation) +SingleValueNumericPostingAttribute<B>::before_inc_generation(generation_t current_gen) { _postingList.freeze(); - SingleValueNumericEnumAttribute<B>::onGenerationChange(generation); - _postingList.assign_generation(generation - 1); + SingleValueNumericEnumAttribute<B>::before_inc_generation(current_gen); + _postingList.assign_generation(current_gen); } template <typename B> diff --git a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp index 02ab5798f9f..b2662a0928d 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp @@ -106,16 +106,16 @@ SingleValueSmallNumericAttribute::onUpdateStat() void -SingleValueSmallNumericAttribute::removeOldGenerations(generation_t firstUsed) +SingleValueSmallNumericAttribute::reclaim_memory(generation_t oldest_used_gen) { - getGenerationHolder().reclaim(firstUsed); + getGenerationHolder().reclaim(oldest_used_gen); } void -SingleValueSmallNumericAttribute::onGenerationChange(generation_t generation) +SingleValueSmallNumericAttribute::before_inc_generation(generation_t current_gen) { - getGenerationHolder().assign_generation(generation - 1); + getGenerationHolder().assign_generation(current_gen); } diff --git a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h index 4bf120d7952..b2af8752fa4 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h @@ -72,8 +72,8 @@ public: void onCommit() override; void onAddDocs(DocId docIdLimit) override; void onUpdateStat() override; - void removeOldGenerations(generation_t firstUsed) override; - void onGenerationChange(generation_t generation) override; + void reclaim_memory(generation_t oldest_used_gen) override; + void before_inc_generation(generation_t current_gen) override; bool addDoc(DocId & doc) override; bool onLoad(vespalib::Executor *executor) override; void onSave(IAttributeSaveTarget &saveTarget) override; diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h index 30549f3048a..358c95f65dc 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h +++ b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.h @@ -71,8 +71,8 @@ public: SingleValueStringPostingAttributeT(const vespalib::string & name); ~SingleValueStringPostingAttributeT(); - void removeOldGenerations(generation_t firstUsed) override; - void onGenerationChange(generation_t generation) override; + void reclaim_memory(generation_t oldest_used_gen) override; + void before_inc_generation(generation_t current_gen) override; std::unique_ptr<attribute::SearchContext> getSearch(QueryTermSimpleUP term, const attribute::SearchContextParams & params) const override; diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp index 5e7b70b5080..eef72984e79 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp @@ -127,19 +127,19 @@ SingleValueStringPostingAttributeT<B>::applyValueChanges(EnumStoreBatchUpdater& template <typename B> void -SingleValueStringPostingAttributeT<B>::removeOldGenerations(generation_t firstUsed) +SingleValueStringPostingAttributeT<B>::reclaim_memory(generation_t oldest_used_gen) { - SingleValueStringAttributeT<B>::removeOldGenerations(firstUsed); - _postingList.reclaim_memory(firstUsed); + SingleValueStringAttributeT<B>::reclaim_memory(oldest_used_gen); + _postingList.reclaim_memory(oldest_used_gen); } template <typename B> void -SingleValueStringPostingAttributeT<B>::onGenerationChange(generation_t generation) +SingleValueStringPostingAttributeT<B>::before_inc_generation(generation_t current_gen) { _postingList.freeze(); - SingleValueStringAttributeT<B>::onGenerationChange(generation); - _postingList.assign_generation(generation - 1); + SingleValueStringAttributeT<B>::before_inc_generation(current_gen); + _postingList.assign_generation(current_gen); } template <typename B> diff --git a/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp b/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp index cdf7e5f5ea8..0e7e492c954 100644 --- a/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp +++ b/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp @@ -110,7 +110,7 @@ LogDataStore::~LogDataStore() // Must be called before ending threads as there are sanity checks. _fileChunks.clear(); _genHandler.update_oldest_used_generation(); - _lidInfo.removeOldGenerations(_genHandler.get_oldest_used_generation()); + _lidInfo.reclaim_memory(_genHandler.get_oldest_used_generation()); } void @@ -940,7 +940,7 @@ LogDataStore::setLid(const MonitorGuard &guard, uint32_t lid, const LidInfo &met (void) guard; if (lid < _lidInfo.size()) { _genHandler.update_oldest_used_generation(); - _lidInfo.removeOldGenerations(_genHandler.get_oldest_used_generation()); + _lidInfo.reclaim_memory(_genHandler.get_oldest_used_generation()); const LidInfo prev = vespalib::atomic::load_ref_relaxed(_lidInfo[lid]); if (prev.valid()) { _fileChunks[prev.getFileId()]->remove(lid, prev.size()); @@ -959,7 +959,7 @@ LogDataStore::incGeneration() _lidInfo.setGeneration(_genHandler.getNextGeneration()); _genHandler.incGeneration(); _genHandler.update_oldest_used_generation(); - _lidInfo.removeOldGenerations(_genHandler.get_oldest_used_generation()); + _lidInfo.reclaim_memory(_genHandler.get_oldest_used_generation()); } size_t diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp index 6a47e0da5df..56b9473b6e6 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp @@ -450,22 +450,20 @@ DenseTensorAttribute::onCommit() } void -DenseTensorAttribute::onGenerationChange(generation_t next_gen) +DenseTensorAttribute::before_inc_generation(generation_t current_gen) { - // TODO: Change onGenerationChange() to send current generation instead of next generation. - // This applies for entire attribute vector code. - TensorAttribute::onGenerationChange(next_gen); + TensorAttribute::before_inc_generation(current_gen); if (_index) { - _index->assign_generation(next_gen - 1); + _index->assign_generation(current_gen); } } void -DenseTensorAttribute::removeOldGenerations(generation_t first_used_gen) +DenseTensorAttribute::reclaim_memory(generation_t oldest_used_gen) { - TensorAttribute::removeOldGenerations(first_used_gen); + TensorAttribute::reclaim_memory(oldest_used_gen); if (_index) { - _index->reclaim_memory(first_used_gen); + _index->reclaim_memory(oldest_used_gen); } } diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.h b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.h index b0991aa57aa..3aa52fe622a 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.h +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.h @@ -47,8 +47,8 @@ public: std::unique_ptr<AttributeSaver> onInitSave(vespalib::stringref fileName) override; uint32_t getVersion() const override; void onCommit() override; - void onGenerationChange(generation_t next_gen) override; - void removeOldGenerations(generation_t first_used_gen) override; + void before_inc_generation(generation_t current_gen) override; + void reclaim_memory(generation_t oldest_used_gen) override; void get_state(const vespalib::slime::Inserter& inserter) const override; void onShrinkLidSpace() override; diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp index d505e939a34..10f06a1e1ec 100644 --- a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp +++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp @@ -523,7 +523,7 @@ HnswIndex::assign_generation(generation_t current_gen) void HnswIndex::reclaim_memory(generation_t oldest_used_gen) { - _graph.node_refs.removeOldGenerations(oldest_used_gen); + _graph.node_refs.reclaim_memory(oldest_used_gen); _graph.nodes.reclaim_memory(oldest_used_gen); _graph.links.reclaim_memory(oldest_used_gen); } diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp index 1d147c14cca..6130da6fcf9 100644 --- a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp @@ -110,17 +110,17 @@ TensorAttribute::onUpdateStat() } void -TensorAttribute::removeOldGenerations(generation_t firstUsed) +TensorAttribute::reclaim_memory(generation_t oldest_used_gen) { - _tensorStore.reclaim_memory(firstUsed); - getGenerationHolder().reclaim(firstUsed); + _tensorStore.reclaim_memory(oldest_used_gen); + getGenerationHolder().reclaim(oldest_used_gen); } void -TensorAttribute::onGenerationChange(generation_t generation) +TensorAttribute::before_inc_generation(generation_t current_gen) { - getGenerationHolder().assign_generation(generation - 1); - _tensorStore.assign_generation(generation - 1); + getGenerationHolder().assign_generation(current_gen); + _tensorStore.assign_generation(current_gen); } bool diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h index 7cfbb68eac7..b7bac35d1b7 100644 --- a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h +++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.h @@ -48,8 +48,8 @@ public: uint32_t clearDoc(DocId docId) override; void onCommit() override; void onUpdateStat() override; - void removeOldGenerations(generation_t firstUsed) override; - void onGenerationChange(generation_t generation) override; + void reclaim_memory(generation_t oldest_used_gen) override; + void before_inc_generation(generation_t current_gen) override; bool addDoc(DocId &docId) override; std::unique_ptr<vespalib::eval::Value> getEmptyTensor() const override; vespalib::eval::TypedCells extract_cells_ref(uint32_t docid) const override; diff --git a/vespalib/src/tests/btree/frozenbtree_test.cpp b/vespalib/src/tests/btree/frozenbtree_test.cpp index 0bde2786a0b..3471d5dc3df 100644 --- a/vespalib/src/tests/btree/frozenbtree_test.cpp +++ b/vespalib/src/tests/btree/frozenbtree_test.cpp @@ -114,7 +114,7 @@ FrozenBTreeTest::freeTree(bool verbose) static_cast<uint64_t>(_intTree->getUsedMemory()), static_cast<uint64_t>(_intTree->getHeldMemory())); _intTree->dropFrozen(); - _intTree->removeOldGenerations(_intTree->getGeneration() + 1); + _intTree->reclaim_memory(_intTree->getGeneration() + 1); LOG(info, "freeTree after unhold: %" PRIu64 " (%" PRIu64 " held)", static_cast<uint64_t>(_intTree->getUsedMemory()), diff --git a/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp b/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp index 48fc88ec86d..5d6ec3050da 100644 --- a/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp +++ b/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp @@ -140,7 +140,7 @@ TEST(RcuVectorTest, generation_handling) v.setGeneration(2); v.push_back(50); - v.removeOldGenerations(3); + v.reclaim_memory(3); EXPECT_EQ(0u, v.getMemoryUsage().allocatedBytesOnHold()); v.push_back(60); // new array EXPECT_EQ(24u, v.getMemoryUsage().allocatedBytesOnHold()); @@ -184,7 +184,7 @@ TEST(RcuVectorTest, memory_usage) EXPECT_TRUE(assertUsage(MemoryUsage(6,6,0,2), v.getMemoryUsage())); v.push_back(4); EXPECT_TRUE(assertUsage(MemoryUsage(12,11,0,6), v.getMemoryUsage())); - v.removeOldGenerations(1); + v.reclaim_memory(1); EXPECT_TRUE(assertUsage(MemoryUsage(6,5,0,0), v.getMemoryUsage())); } diff --git a/vespalib/src/vespa/vespalib/util/rcuvector.h b/vespalib/src/vespa/vespalib/util/rcuvector.h index 5d084fe3815..b0929303692 100644 --- a/vespalib/src/vespa/vespalib/util/rcuvector.h +++ b/vespalib/src/vespa/vespalib/util/rcuvector.h @@ -182,7 +182,7 @@ public: /** * Remove all old data vectors where generation < firstUsed. **/ - void removeOldGenerations(generation_t firstUsed); + void reclaim_memory(generation_t oldest_used_gen); MemoryUsage getMemoryUsage() const override; }; diff --git a/vespalib/src/vespa/vespalib/util/rcuvector.hpp b/vespalib/src/vespa/vespalib/util/rcuvector.hpp index e551bb17db0..eadda8ac1e9 100644 --- a/vespalib/src/vespa/vespalib/util/rcuvector.hpp +++ b/vespalib/src/vespa/vespalib/util/rcuvector.hpp @@ -187,9 +187,9 @@ RcuVector<T>::~RcuVector() template <typename T> void -RcuVector<T>::removeOldGenerations(generation_t firstUsed) +RcuVector<T>::reclaim_memory(generation_t oldest_used_gen) { - _genHolderStore.reclaim(firstUsed); + _genHolderStore.reclaim(oldest_used_gen); } template <typename T> |