diff options
author | Geir Storli <geirst@yahooinc.com> | 2022-10-12 13:03:52 +0000 |
---|---|---|
committer | Geir Storli <geirst@yahooinc.com> | 2022-10-12 13:38:37 +0000 |
commit | 462073020110f8343553cdbc1d5e264c67942c7d (patch) | |
tree | 1e3b6603c4b45fd3b06e5067b18d76f1c0d4f87e | |
parent | 06f895593abd5bf49ba181e697bf3a1c68fb870a (diff) |
Rename trimHoldLists() -> reclaim_memory().
74 files changed, 176 insertions, 176 deletions
diff --git a/searchcore/src/tests/proton/documentmetastore/lid_allocator/lid_allocator_test.cpp b/searchcore/src/tests/proton/documentmetastore/lid_allocator/lid_allocator_test.cpp index 157d10e6652..8d8674da4f0 100644 --- a/searchcore/src/tests/proton/documentmetastore/lid_allocator/lid_allocator_test.cpp +++ b/searchcore/src/tests/proton/documentmetastore/lid_allocator/lid_allocator_test.cpp @@ -66,8 +66,8 @@ protected: _allocator.holdLids(lids, get_size(), 0); } - void trim_hold_lists() { - _allocator.trimHoldLists(1); + void reclaim_memory() { + _allocator.reclaim_memory(1); } std::vector<uint32_t> get_valid_lids() { @@ -117,7 +117,7 @@ TEST_F(LidAllocatorTest, unregister_lids) assert_valid_lids({2, 4, 6}); assert_active_lids({4, 6}); hold_lids({1, 3, 5}); - trim_hold_lists(); + reclaim_memory(); EXPECT_EQ((std::vector<uint32_t>{1, 3, 5, 7, 8}), alloc_lids(5)); } diff --git a/searchcore/src/tests/proton/documentmetastore/lid_state_vector/lid_state_vector_test.cpp b/searchcore/src/tests/proton/documentmetastore/lid_state_vector/lid_state_vector_test.cpp index 68958bbe3e4..cbc11126b25 100644 --- a/searchcore/src/tests/proton/documentmetastore/lid_state_vector/lid_state_vector_test.cpp +++ b/searchcore/src/tests/proton/documentmetastore/lid_state_vector/lid_state_vector_test.cpp @@ -47,7 +47,7 @@ TEST_F(LidStateVectorTest, basic_free_list_is_working) EXPECT_EQ(0u, freeLids.count()); EXPECT_EQ(3u, list.size()); - list.trimHoldLists(20, freeLids); + list.reclaim_memory(20, freeLids); EXPECT_FALSE(freeLids.empty()); EXPECT_EQ(1u, freeLids.count()); @@ -57,7 +57,7 @@ TEST_F(LidStateVectorTest, basic_free_list_is_working) EXPECT_EQ(0u, freeLids.count()); EXPECT_EQ(2u, list.size()); - list.trimHoldLists(31, freeLids); + list.reclaim_memory(31, freeLids); EXPECT_FALSE(freeLids.empty()); EXPECT_EQ(2u, freeLids.count()); diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp index 2dc804404b2..c6ef6994b81 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp @@ -252,8 +252,8 @@ DocumentMetaStore::onGenerationChange(generation_t generation) void DocumentMetaStore::removeOldGenerations(generation_t firstUsed) { - _gidToLidMap.getAllocator().trimHoldLists(firstUsed); - _lidAlloc.trimHoldLists(firstUsed); + _gidToLidMap.getAllocator().reclaim_memory(firstUsed); + _lidAlloc.reclaim_memory(firstUsed); getGenerationHolder().reclaim(firstUsed); } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h index 6118701b0dc..95a8cf85279 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_allocator.h @@ -41,8 +41,8 @@ public: void unregisterLid(DocId lid); void unregister_lids(const std::vector<DocId>& lids); size_t getUsedLidsSize() const { return _usedLids.byteSize(); } - void trimHoldLists(generation_t firstUsed) { - _holdLids.trimHoldLists(firstUsed, _freeLids); + void reclaim_memory(generation_t oldest_used_gen) { + _holdLids.reclaim_memory(oldest_used_gen, _freeLids); } void moveLidBegin(DocId fromLid, DocId toLid); void moveLidEnd(DocId fromLid, DocId toLid); diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_hold_list.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_hold_list.cpp index 7157a40c5d5..ef0a244fc37 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_hold_list.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_hold_list.cpp @@ -23,9 +23,9 @@ LidHoldList::clear() { } void -LidHoldList::trimHoldLists(generation_t firstUsed, LidStateVector &freeLids) +LidHoldList::reclaim_memory(generation_t oldest_used_gen, LidStateVector &freeLids) { - while (!_holdList.empty() && _holdList.front().second < firstUsed) { + while (!_holdList.empty() && _holdList.front().second < oldest_used_gen) { uint32_t lid = _holdList.front().first; freeLids.setBit(lid); _holdList.pop_front(); diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_hold_list.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_hold_list.h index fc32fcb7510..565d8bf25e1 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_hold_list.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_hold_list.h @@ -43,9 +43,9 @@ public: void clear(); /** - * Frees up elements with generation < first used generation for reuse. + * Frees up elements with generation < oldest used generation for reuse. **/ - void trimHoldLists(generation_t firstUsed, LidStateVector &freeLids); + void reclaim_memory(generation_t oldest_used_gen, LidStateVector &freeLids); }; diff --git a/searchlib/src/tests/attribute/document_weight_or_filter_search/document_weight_or_filter_search_test.cpp b/searchlib/src/tests/attribute/document_weight_or_filter_search/document_weight_or_filter_search_test.cpp index fded2295ef6..41369853c97 100644 --- a/searchlib/src/tests/attribute/document_weight_or_filter_search/document_weight_or_filter_search_test.cpp +++ b/searchlib/src/tests/attribute/document_weight_or_filter_search/document_weight_or_filter_search_test.cpp @@ -146,7 +146,7 @@ DocumentWeightOrFilterSearchTest::inc_generation() _postings.assign_generation(_gens.getCurrentGeneration()); _gens.incGeneration(); _gens.update_oldest_used_generation(); - _postings.trimHoldLists(_gens.get_oldest_used_generation()); + _postings.reclaim_memory(_gens.get_oldest_used_generation()); } TEST_F(DocumentWeightOrFilterSearchTest, daat_or) diff --git a/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp b/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp index 64730871d9d..9d717202551 100644 --- a/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp +++ b/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp @@ -149,7 +149,7 @@ TEST("requireThatComparatorWithTreeIsWorking") m.freeze(); m.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - m.trimHoldLists(g.get_oldest_used_generation()); + m.reclaim_memory(g.get_oldest_used_generation()); } TEST("requireThatFoldedLessIsWorking") diff --git a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp index 8a9e053a612..0542a253cc5 100644 --- a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp +++ b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp @@ -346,7 +346,7 @@ TEST(EnumStoreTest, test_hold_lists_and_generation) checkReaders(ses, readers); ses.assign_generation(sesGen); - ses.trim_hold_lists(sesGen + 1); + ses.reclaim_memory(sesGen + 1); } void @@ -358,7 +358,7 @@ dec_ref_count(NumericEnumStore& store, NumericEnumStore::Index idx) generation_t gen = 5; store.assign_generation(gen); - store.trim_hold_lists(gen + 1); + store.reclaim_memory(gen + 1); } TEST(EnumStoreTest, address_space_usage_is_reported) @@ -884,7 +884,7 @@ void inc_generation(generation_t &gen, NumericEnumStore &store) store.freeze_dictionary(); store.assign_generation(gen); ++gen; - store.trim_hold_lists(gen); + store.reclaim_memory(gen); } } 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 19dd94c5f3c..938a7fb35d7 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 @@ -42,7 +42,7 @@ class MyAttribute : public search::NotImplementedAttribute setNumDocs(committedDocIdLimit); } virtual void removeOldGenerations(generation_t firstUsed) override { - _mvMapping.trimHoldLists(firstUsed); + _mvMapping.reclaim_memory(firstUsed); } virtual void onGenerationChange(generation_t generation) override { _mvMapping.assign_generation(generation - 1); @@ -116,7 +116,7 @@ public: EXPECT_EQ(exp, std::vector<EntryT>(act.cbegin(), act.cend())); } void assign_generation(generation_t current_gen) { _mvMapping->assign_generation(current_gen); } - void trimHoldLists(generation_t firstUsed) { _mvMapping->trimHoldLists(firstUsed); } + void reclaim_memory(generation_t oldest_used_gen) { _mvMapping->reclaim_memory(oldest_used_gen); } void addDocs(uint32_t numDocs) { for (uint32_t i = 0; i < numDocs; ++i) { uint32_t doc = 0; @@ -248,9 +248,9 @@ TEST_F(IntMappingTest, test_that_old_value_is_not_overwritten_while_held) assign_generation(10); assertArray({5}, old3); assertGet(3, {7}); - trimHoldLists(10); + reclaim_memory(10); assertArray({5}, old3); - trimHoldLists(11); + reclaim_memory(11); assertArray({0}, old3); } diff --git a/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp b/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp index 5b07c0120bf..75e7faf0227 100644 --- a/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp +++ b/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp @@ -67,8 +67,8 @@ protected: _value_store.assign_generation(_gen_handler.getCurrentGeneration()); _store.assign_generation(_gen_handler.getCurrentGeneration()); _gen_handler.incGeneration(); - _value_store.trim_hold_lists(_gen_handler.get_oldest_used_generation()); - _store.trimHoldLists(_gen_handler.get_oldest_used_generation()); + _value_store.reclaim_memory(_gen_handler.get_oldest_used_generation()); + _store.reclaim_memory(_gen_handler.get_oldest_used_generation()); } EntryRef add_sequence(int start_key, int end_key) diff --git a/searchlib/src/tests/attribute/postinglist/postinglist.cpp b/searchlib/src/tests/attribute/postinglist/postinglist.cpp index 0c0187eb8de..e41aaec351e 100644 --- a/searchlib/src/tests/attribute/postinglist/postinglist.cpp +++ b/searchlib/src/tests/attribute/postinglist/postinglist.cpp @@ -263,8 +263,8 @@ AttributePostingListTest::freeTree(bool verbose) _intPostings->clearBuilder(); _intPostings->assign_generation(_handler.getCurrentGeneration()); _handler.incGeneration(); - _intNodeAlloc->trimHoldLists(_handler.get_oldest_used_generation()); - _intPostings->trimHoldLists(_handler.get_oldest_used_generation()); + _intNodeAlloc->reclaim_memory(_handler.get_oldest_used_generation()); + _intPostings->reclaim_memory(_handler.get_oldest_used_generation()); LOG(info, "freeTree after unhold: %" PRIu64 " (%" PRIu64 " held)", static_cast<uint64_t>(_intNodeAlloc->getMemoryUsage().allocatedBytes()), @@ -615,7 +615,7 @@ AttributePostingListTest::doCompactEnumStore(Tree &tree, generation_t generation = _handler.getCurrentGeneration(); valueHandle.assign_generation(generation); _handler.incGeneration(); - valueHandle.trimHoldLists(_handler.get_oldest_used_generation()); + valueHandle.reclaim_memory(_handler.get_oldest_used_generation()); LOG(info, "doCompactEnumStore done"); @@ -672,8 +672,8 @@ removeOldGenerations(Tree &tree, { (void) tree; (void) valueHandle; - postingsAlloc.trimHoldLists(_handler.get_oldest_used_generation()); - postings.trimHoldLists(_handler.get_oldest_used_generation()); + postingsAlloc.reclaim_memory(_handler.get_oldest_used_generation()); + postings.reclaim_memory(_handler.get_oldest_used_generation()); } int diff --git a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp index 5c6d9d42cf2..9127c4b59fc 100644 --- a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp +++ b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp @@ -224,8 +224,8 @@ public: void assign_generation(generation_t current_gen) override { _transfer_gen = current_gen; } - void trim_hold_lists(generation_t first_used_gen) override { - _trim_gen = first_used_gen; + void reclaim_memory(generation_t oldest_used_gen) override { + _trim_gen = oldest_used_gen; } bool consider_compact(const CompactionStrategy&) override { return false; diff --git a/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp b/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp index 9526b65846d..958423860e5 100644 --- a/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp +++ b/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp @@ -102,7 +102,7 @@ public: index->assign_generation(gen_handler.getCurrentGeneration()); gen_handler.incGeneration(); gen_handler.update_oldest_used_generation(); - index->trim_hold_lists(gen_handler.get_oldest_used_generation()); + index->reclaim_memory(gen_handler.get_oldest_used_generation()); } void set_filter(std::vector<uint32_t> docids) { uint32_t sz = 10; diff --git a/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp b/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp index 428e6654039..47812c2a63c 100644 --- a/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp +++ b/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp @@ -270,7 +270,7 @@ public: index->assign_generation(gen_handler.getCurrentGeneration()); gen_handler.incGeneration(); gen_handler.update_oldest_used_generation(); - index->trim_hold_lists(gen_handler.get_oldest_used_generation()); + index->reclaim_memory(gen_handler.get_oldest_used_generation()); std::lock_guard<std::mutex> guard(in_progress_lock); in_progress->clearBit(docid); // printf("commit: %u\n", docid); diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.h b/searchlib/src/vespa/searchlib/attribute/enumstore.h index 53044fa5511..0a0b2040b2a 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstore.h +++ b/searchlib/src/vespa/searchlib/attribute/enumstore.h @@ -97,7 +97,7 @@ public: vespalib::AddressSpace get_values_address_space_usage() const override; void assign_generation(generation_t current_gen); - void trim_hold_lists(generation_t first_used); + void reclaim_memory(generation_t first_used); ssize_t load_unique_values(const void* src, size_t available, IndexVector& idx) override; diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp index ef87c55f4cc..b863e56fb4a 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp +++ b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp @@ -111,10 +111,10 @@ EnumStoreT<EntryT>::assign_generation(generation_t current_gen) template <typename EntryT> void -EnumStoreT<EntryT>::trim_hold_lists(generation_t firstUsed) +EnumStoreT<EntryT>::reclaim_memory(generation_t oldest_used_gen) { // remove generations in the range [0, firstUsed> - _store.trimHoldLists(firstUsed); + _store.reclaim_memory(oldest_used_gen); } template <typename EntryT> diff --git a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.h b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.h index 2468a58211c..98587baadd2 100644 --- a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.h +++ b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.h @@ -49,7 +49,7 @@ public: ReadView make_read_view(size_t read_size) const { return ReadView(_indices.make_read_view(read_size), &_store); } // Pass on hold list management to underlying store void assign_generation(generation_t current_gen) { _store.assign_generation(current_gen); } - void trimHoldLists(generation_t firstUsed) { _store.trimHoldLists(firstUsed); } + void reclaim_memory(generation_t oldest_used_gen) { _store.reclaim_memory(oldest_used_gen); } void prepareLoadFromMultiValue() { _store.setInitializing(true); } void doneLoadFromMultiValue() { _store.setInitializing(false); } diff --git a/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp index 6b0f4290d69..ad827d0fd85 100644 --- a/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multienumattribute.hpp @@ -196,8 +196,8 @@ template <typename B, typename M> void MultiValueEnumAttribute<B, M>::removeOldGenerations(generation_t firstUsed) { - this->_enumStore.trim_hold_lists(firstUsed); - this->_mvMapping.trimHoldLists(firstUsed); + this->_enumStore.reclaim_memory(firstUsed); + this->_mvMapping.reclaim_memory(firstUsed); } template <typename B, typename M> diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp index c98a236e6d7..2405841f331 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp @@ -98,7 +98,7 @@ void MultiValueNumericAttribute<B, M>::setNewValues(DocId doc, const std::vector template <typename B, typename M> void MultiValueNumericAttribute<B, M>::removeOldGenerations(generation_t firstUsed) { - this->_mvMapping.trimHoldLists(firstUsed); + this->_mvMapping.reclaim_memory(firstUsed); } diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp index 41dbc0aff40..70a438f1551 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp @@ -59,7 +59,7 @@ void MultiValueNumericPostingAttribute<B, M>::removeOldGenerations(generation_t firstUsed) { MultiValueNumericEnumAttribute<B, M>::removeOldGenerations(firstUsed); - _postingList.trimHoldLists(firstUsed); + _postingList.reclaim_memory(firstUsed); } template <typename B, typename M> diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp index 252e71d0dde..9bc2c31b163 100644 --- a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp @@ -78,7 +78,7 @@ void MultiValueStringPostingAttributeT<B, T>::removeOldGenerations(generation_t firstUsed) { MultiValueStringAttributeT<B, T>::removeOldGenerations(firstUsed); - _postingList.trimHoldLists(firstUsed); + _postingList.reclaim_memory(firstUsed); } template <typename B, typename T> diff --git a/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp index ff27adeb24a..8593b013443 100644 --- a/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp @@ -128,7 +128,7 @@ void PredicateAttribute::removeOldGenerations(generation_t firstUsed) { getGenerationHolder().reclaim(firstUsed); - _index->trimHoldLists(firstUsed); + _index->reclaim_memory(firstUsed); } void diff --git a/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp index ca25e2068a2..aa884e1e298 100644 --- a/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp @@ -163,8 +163,8 @@ ReferenceAttribute::clearDoc(DocId doc) void ReferenceAttribute::removeOldGenerations(generation_t firstUsed) { - _referenceMappings.trimHoldLists(firstUsed); - _store.trimHoldLists(firstUsed); + _referenceMappings.reclaim_memory(firstUsed); + _store.reclaim_memory(firstUsed); getGenerationHolder().reclaim(firstUsed); } diff --git a/searchlib/src/vespa/searchlib/attribute/reference_mappings.h b/searchlib/src/vespa/searchlib/attribute/reference_mappings.h index 50f6b9188f3..cf26b424208 100644 --- a/searchlib/src/vespa/searchlib/attribute/reference_mappings.h +++ b/searchlib/src/vespa/searchlib/attribute/reference_mappings.h @@ -59,7 +59,7 @@ public: void clearMapping(const Reference &entry); // Hold list management & freezing - void trimHoldLists(generation_t usedGen) { _reverseMapping.trimHoldLists(usedGen); } + void reclaim_memory(generation_t oldest_used_gen) { _reverseMapping.reclaim_memory(oldest_used_gen); } void freeze() { _reverseMapping.freeze(); } void assign_generation(generation_t current_gen) { _reverseMapping.assign_generation(current_gen); } diff --git a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp index 0086b1b3455..f0649224b89 100644 --- a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp @@ -266,7 +266,7 @@ template <typename B> void SingleValueEnumAttribute<B>::removeOldGenerations(generation_t firstUsed) { - this->_enumStore.trim_hold_lists(firstUsed); + this->_enumStore.reclaim_memory(firstUsed); getGenerationHolder().reclaim(firstUsed); } diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp index dfd66bbbf04..c5acc0c360a 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp @@ -130,7 +130,7 @@ void SingleValueNumericPostingAttribute<B>::removeOldGenerations(generation_t firstUsed) { SingleValueNumericEnumAttribute<B>::removeOldGenerations(firstUsed); - _postingList.trimHoldLists(firstUsed); + _postingList.reclaim_memory(firstUsed); } template <typename B> diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp index 3bb26b61ba9..5e7b70b5080 100644 --- a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp @@ -130,7 +130,7 @@ void SingleValueStringPostingAttributeT<B>::removeOldGenerations(generation_t firstUsed) { SingleValueStringAttributeT<B>::removeOldGenerations(firstUsed); - _postingList.trimHoldLists(firstUsed); + _postingList.reclaim_memory(firstUsed); } template <typename B> diff --git a/searchlib/src/vespa/searchlib/memoryindex/feature_store.h b/searchlib/src/vespa/searchlib/memoryindex/feature_store.h index db917423bf9..1359fde71a7 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/feature_store.h +++ b/searchlib/src/vespa/searchlib/memoryindex/feature_store.h @@ -205,7 +205,7 @@ public: const std::vector<PosOccFieldsParams> &getFieldsParams() const { return _fieldsParams; } - void trimHoldLists(generation_t usedGen) { _store.trimHoldLists(usedGen); } + void reclaim_memory(generation_t oldest_used_gen) { _store.reclaim_memory(oldest_used_gen); } void assign_generation(generation_t current_gen) { _store.assign_generation(current_gen); } void clearHoldLists() { _store.clearHoldLists();} std::unique_ptr<vespalib::datastore::CompactingBuffers> start_compact(); diff --git a/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp b/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp index 7e6c53e627c..4be3031303e 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp @@ -74,7 +74,7 @@ FieldIndex<interleaved_features>::~FieldIndex() freeze(); // Flush pending freeze for dictionary tree. assign_generation(); incGeneration(); - trimHoldLists(); + reclaim_memory(); } template <bool interleaved_features> diff --git a/searchlib/src/vespa/searchlib/memoryindex/field_index.h b/searchlib/src/vespa/searchlib/memoryindex/field_index.h index 0efb3cbe13f..187ec5ee971 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/field_index.h +++ b/searchlib/src/vespa/searchlib/memoryindex/field_index.h @@ -52,12 +52,12 @@ private: _dict.getAllocator().freeze(); } - void trimHoldLists() { - GenerationHandler::generation_t usedGen = + void reclaim_memory() { + GenerationHandler::generation_t oldest_used_gen = _generationHandler.get_oldest_used_generation(); - _postingListStore.trimHoldLists(usedGen); - _dict.getAllocator().trimHoldLists(usedGen); - _featureStore.trimHoldLists(usedGen); + _postingListStore.reclaim_memory(oldest_used_gen); + _dict.getAllocator().reclaim_memory(oldest_used_gen); + _featureStore.reclaim_memory(oldest_used_gen); } void assign_generation() { @@ -92,7 +92,7 @@ public: freeze(); assign_generation(); incGeneration(); - trimHoldLists(); + reclaim_memory(); } /** diff --git a/searchlib/src/vespa/searchlib/predicate/predicate_index.cpp b/searchlib/src/vespa/searchlib/predicate/predicate_index.cpp index 36312950867..f21ca1b11cc 100644 --- a/searchlib/src/vespa/searchlib/predicate/predicate_index.cpp +++ b/searchlib/src/vespa/searchlib/predicate/predicate_index.cpp @@ -213,11 +213,11 @@ PredicateIndex::commit() { } void -PredicateIndex::trimHoldLists(generation_t used_generation) { - _interval_index.trimHoldLists(used_generation); - _bounds_index.trimHoldLists(used_generation); - _interval_store.trimHoldLists(used_generation); - _zero_constraint_docs.getAllocator().trimHoldLists(used_generation); +PredicateIndex::reclaim_memory(generation_t oldest_used_gen) { + _interval_index.reclaim_memory(oldest_used_gen); + _bounds_index.reclaim_memory(oldest_used_gen); + _interval_store.reclaim_memory(oldest_used_gen); + _zero_constraint_docs.getAllocator().reclaim_memory(oldest_used_gen); } void diff --git a/searchlib/src/vespa/searchlib/predicate/predicate_index.h b/searchlib/src/vespa/searchlib/predicate/predicate_index.h index b6e67961cdc..238314e17f9 100644 --- a/searchlib/src/vespa/searchlib/predicate/predicate_index.h +++ b/searchlib/src/vespa/searchlib/predicate/predicate_index.h @@ -73,7 +73,7 @@ public: void indexDocument(uint32_t doc_id, const PredicateTreeAnnotations &annotations); void removeDocument(uint32_t doc_id); void commit(); - void trimHoldLists(generation_t used_generation); + void reclaim_memory(generation_t oldest_used_gen); void assign_generation(generation_t current_gen); vespalib::MemoryUsage getMemoryUsage() const; diff --git a/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.cpp b/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.cpp index 4def6cf0725..af809b2fa69 100644 --- a/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.cpp +++ b/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.cpp @@ -100,8 +100,8 @@ PredicateIntervalStore::remove(EntryRef ref) { } void -PredicateIntervalStore::trimHoldLists(generation_t used_generation) { - _store.trimHoldLists(used_generation); +PredicateIntervalStore::reclaim_memory(generation_t oldest_used_gen) { + _store.reclaim_memory(oldest_used_gen); } void diff --git a/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.h b/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.h index af14755292e..a96c208393d 100644 --- a/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.h +++ b/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.h @@ -71,7 +71,7 @@ public: */ void remove(vespalib::datastore::EntryRef ref); - void trimHoldLists(generation_t used_generation); + void reclaim_memory(generation_t oldest_used_gen); void assign_generation(generation_t current_gen); diff --git a/searchlib/src/vespa/searchlib/predicate/simple_index.h b/searchlib/src/vespa/searchlib/predicate/simple_index.h index be5229c35aa..d49e42a1e35 100644 --- a/searchlib/src/vespa/searchlib/predicate/simple_index.h +++ b/searchlib/src/vespa/searchlib/predicate/simple_index.h @@ -187,7 +187,7 @@ public: // (and after doc id limits values are determined) to promote posting lists to vectors. void promoteOverThresholdVectors(); void commit(); - void trimHoldLists(generation_t used_generation); + void reclaim_memory(generation_t oldest_used_gen); void assign_generation(generation_t current_gen); vespalib::MemoryUsage getMemoryUsage() const; template <typename FunctionType> diff --git a/searchlib/src/vespa/searchlib/predicate/simple_index.hpp b/searchlib/src/vespa/searchlib/predicate/simple_index.hpp index 7b4cfa1c55d..2c1fdf4038f 100644 --- a/searchlib/src/vespa/searchlib/predicate/simple_index.hpp +++ b/searchlib/src/vespa/searchlib/predicate/simple_index.hpp @@ -291,10 +291,10 @@ SimpleIndex<Posting, Key, DocId>::commit() { template <typename Posting, typename Key, typename DocId> void -SimpleIndex<Posting, Key, DocId>::trimHoldLists(generation_t used_generation) { - _btree_posting_lists.trimHoldLists(used_generation); - _dictionary.getAllocator().trimHoldLists(used_generation); - _vector_posting_lists.getAllocator().trimHoldLists(used_generation); +SimpleIndex<Posting, Key, DocId>::reclaim_memory(generation_t oldest_used_gen) { + _btree_posting_lists.reclaim_memory(oldest_used_gen); + _dictionary.getAllocator().reclaim_memory(oldest_used_gen); + _vector_posting_lists.getAllocator().reclaim_memory(oldest_used_gen); } diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp index 11366952ad2..cd0fc0b88e9 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp @@ -465,7 +465,7 @@ DenseTensorAttribute::removeOldGenerations(generation_t first_used_gen) { TensorAttribute::removeOldGenerations(first_used_gen); if (_index) { - _index->trim_hold_lists(first_used_gen); + _index->reclaim_memory(first_used_gen); } } diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp index 4afdbf12ae5..d505e939a34 100644 --- a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp +++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp @@ -521,11 +521,11 @@ HnswIndex::assign_generation(generation_t current_gen) } void -HnswIndex::trim_hold_lists(generation_t first_used_gen) +HnswIndex::reclaim_memory(generation_t oldest_used_gen) { - _graph.node_refs.removeOldGenerations(first_used_gen); - _graph.nodes.trimHoldLists(first_used_gen); - _graph.links.trimHoldLists(first_used_gen); + _graph.node_refs.removeOldGenerations(oldest_used_gen); + _graph.nodes.reclaim_memory(oldest_used_gen); + _graph.links.reclaim_memory(oldest_used_gen); } void diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_index.h b/searchlib/src/vespa/searchlib/tensor/hnsw_index.h index 04abb197cb9..8a7422907ea 100644 --- a/searchlib/src/vespa/searchlib/tensor/hnsw_index.h +++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index.h @@ -188,7 +188,7 @@ public: void complete_add_document(uint32_t docid, std::unique_ptr<PrepareResult> prepare_result) override; void remove_document(uint32_t docid) override; void assign_generation(generation_t current_gen) override; - void trim_hold_lists(generation_t first_used_gen) override; + void reclaim_memory(generation_t oldest_used_gen) override; void compact_level_arrays(CompactionSpec compaction_spec, const CompactionStrategy& compaction_strategy); void compact_link_arrays(CompactionSpec compaction_spec, const CompactionStrategy& compaction_strategy); bool consider_compact_level_arrays(const CompactionStrategy& compaction_strategy); diff --git a/searchlib/src/vespa/searchlib/tensor/nearest_neighbor_index.h b/searchlib/src/vespa/searchlib/tensor/nearest_neighbor_index.h index 74e0c3e0d18..d40803dcafd 100644 --- a/searchlib/src/vespa/searchlib/tensor/nearest_neighbor_index.h +++ b/searchlib/src/vespa/searchlib/tensor/nearest_neighbor_index.h @@ -69,7 +69,7 @@ public: virtual void remove_document(uint32_t docid) = 0; virtual void assign_generation(generation_t current_gen) = 0; - virtual void trim_hold_lists(generation_t first_used_gen) = 0; + virtual void reclaim_memory(generation_t first_used_gen) = 0; virtual bool consider_compact(const CompactionStrategy& compaction_strategy) = 0; virtual vespalib::MemoryUsage update_stat(const CompactionStrategy& compaction_strategy) = 0; virtual vespalib::MemoryUsage memory_usage() const = 0; diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp index cb1668dae3c..1d147c14cca 100644 --- a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp @@ -112,7 +112,7 @@ TensorAttribute::onUpdateStat() void TensorAttribute::removeOldGenerations(generation_t firstUsed) { - _tensorStore.trimHoldLists(firstUsed); + _tensorStore.reclaim_memory(firstUsed); getGenerationHolder().reclaim(firstUsed); } diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_store.h b/searchlib/src/vespa/searchlib/tensor/tensor_store.h index 9ff6b7ffddd..3f2b408c667 100644 --- a/searchlib/src/vespa/searchlib/tensor/tensor_store.h +++ b/searchlib/src/vespa/searchlib/tensor/tensor_store.h @@ -48,8 +48,8 @@ public: virtual bool encode_stored_tensor(EntryRef ref, vespalib::nbostream& target) const = 0; // Inherit doc from DataStoreBase - void trimHoldLists(generation_t usedGen) { - _store.trimHoldLists(usedGen); + void reclaim_memory(generation_t oldest_used_gen) { + _store.reclaim_memory(oldest_used_gen); } // Inherit doc from DataStoreBase diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp index a57cd36b3b1..e918c523fcf 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp @@ -182,9 +182,9 @@ FakeMemTreeOccMgr::incGeneration() void -FakeMemTreeOccMgr::trimHoldLists() +FakeMemTreeOccMgr::reclaim_memory() { - _allocator.trimHoldLists(_generationHandler.get_oldest_used_generation()); + _allocator.reclaim_memory(_generationHandler.get_oldest_used_generation()); } @@ -194,7 +194,7 @@ FakeMemTreeOccMgr::sync() freeze(); assign_generation(); incGeneration(); - trimHoldLists(); + reclaim_memory(); } diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.h b/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.h index 4081070d8f8..290ba1cf140 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.h @@ -96,7 +96,7 @@ public: void freeze(); void assign_generation(); void incGeneration(); - void trimHoldLists(); + void reclaim_memory(); void sync(); void add(uint32_t wordIdx, index::DocIdAndFeatures &features) override; void remove(uint32_t wordIdx, uint32_t docId) override; diff --git a/storage/src/vespa/storage/bucketdb/generic_btree_bucket_database.hpp b/storage/src/vespa/storage/bucketdb/generic_btree_bucket_database.hpp index 3e4a2f28042..125882f7fe7 100644 --- a/storage/src/vespa/storage/bucketdb/generic_btree_bucket_database.hpp +++ b/storage/src/vespa/storage/bucketdb/generic_btree_bucket_database.hpp @@ -44,8 +44,8 @@ void GenericBTreeBucketDatabase<DataStoreTraitsT>::commit_tree_changes() { _generation_handler.incGeneration(); auto used_gen = _generation_handler.get_oldest_used_generation(); - _store.trimHoldLists(used_gen); - _tree.getAllocator().trimHoldLists(used_gen); + _store.reclaim_memory(used_gen); + _tree.getAllocator().reclaim_memory(used_gen); } template <typename DataStoreTraitsT> diff --git a/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp b/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp index 03bc09211b4..caed5c3543c 100644 --- a/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp +++ b/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp @@ -60,7 +60,7 @@ public: void hold(const AtomicEntryRef& ref) { _store.holdElem(ref.load_relaxed(), 1); } EntryRef move(EntryRef ref); void assign_generation(generation_t current_gen) { _store.assign_generation(current_gen); } - void trim_hold_lists(generation_t gen) { _store.trimHoldLists(gen); } + void reclaim_memory(generation_t gen) { _store.reclaim_memory(gen); } uint32_t get(EntryRef ref) const { return _store.getEntry(ref); } uint32_t get_acquire(const AtomicEntryRef& ref) const { return get(ref.load_acquire()); } uint32_t get_relaxed(const AtomicEntryRef& ref) const { return get(ref.load_relaxed()); } @@ -119,7 +119,7 @@ public: static uint32_t add_relaxed(uint32_t value) noexcept { return value; } static void hold(uint32_t) noexcept { } static void assign_generation(generation_t) noexcept { } - static void trim_hold_lists(generation_t) noexcept { } + static void reclaim_memory(generation_t) noexcept { } static uint32_t get(uint32_t value) noexcept { return value; } static uint32_t get_acquire(uint32_t value) noexcept { return value; } static uint32_t get_relaxed(uint32_t value) noexcept { return value; } @@ -279,10 +279,10 @@ Fixture<Params>::commit() _values.assign_generation(current_gen); allocator.assign_generation(_generationHandler.getCurrentGeneration()); _generationHandler.incGeneration(); - auto first_used_gen = _generationHandler.get_oldest_used_generation(); - allocator.trimHoldLists(first_used_gen); - _keys.trim_hold_lists(first_used_gen); - _values.trim_hold_lists(first_used_gen); + auto oldest_used_gen = _generationHandler.get_oldest_used_generation(); + allocator.reclaim_memory(oldest_used_gen); + _keys.reclaim_memory(oldest_used_gen); + _values.reclaim_memory(oldest_used_gen); } template <typename Params> diff --git a/vespalib/src/tests/btree/btree_store/btree_store_test.cpp b/vespalib/src/tests/btree/btree_store/btree_store_test.cpp index 3dcc4830678..0370b1ce2eb 100644 --- a/vespalib/src/tests/btree/btree_store/btree_store_test.cpp +++ b/vespalib/src/tests/btree/btree_store/btree_store_test.cpp @@ -33,7 +33,7 @@ protected: _store.freeze(); _store.assign_generation(_gen_handler.getCurrentGeneration()); _gen_handler.incGeneration(); - _store.trimHoldLists(_gen_handler.get_oldest_used_generation()); + _store.reclaim_memory(_gen_handler.get_oldest_used_generation()); } EntryRef add_sequence(int start_key, int end_key) diff --git a/vespalib/src/tests/btree/btree_test.cpp b/vespalib/src/tests/btree/btree_test.cpp index 09877e00ac5..f2896cb783c 100644 --- a/vespalib/src/tests/btree/btree_test.cpp +++ b/vespalib/src/tests/btree/btree_test.cpp @@ -165,7 +165,7 @@ cleanup(GenerationHandler & g, ManagerType & m) m.freeze(); m.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - m.trimHoldLists(g.get_oldest_used_generation()); + m.reclaim_memory(g.get_oldest_used_generation()); } template <typename ManagerType, typename NodeType> @@ -876,7 +876,7 @@ TEST_F(BTreeTest, require_that_we_can_insert_and_remove_from_tree) manager.freeze(); manager.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - manager.trimHoldLists(g.get_oldest_used_generation()); + manager.reclaim_memory(g.get_oldest_used_generation()); } // remove entries for (size_t i = 0; i < numEntries; ++i) { @@ -1108,7 +1108,7 @@ TEST_F(BTreeTest, require_that_memory_usage_is_calculated) // trim hold lists tm.assign_generation(gh.getCurrentGeneration()); gh.incGeneration(); - tm.trimHoldLists(gh.get_oldest_used_generation()); + tm.reclaim_memory(gh.get_oldest_used_generation()); mu = vespalib::MemoryUsage(); mu.incAllocatedBytes(adjustAllocatedBytes(initialInternalNodes, sizeof(INode))); mu.incAllocatedBytes(adjustAllocatedBytes(initialLeafNodes, sizeof(LNode))); @@ -1284,7 +1284,7 @@ TEST_F(BTreeTest, require_that_small_nodes_works) s.freeze(); s.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - s.trimHoldLists(g.get_oldest_used_generation()); + s.reclaim_memory(g.get_oldest_used_generation()); } namespace { @@ -1418,7 +1418,7 @@ TEST_F(BTreeTest, require_that_apply_works) s.freeze(); s.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - s.trimHoldLists(g.get_oldest_used_generation()); + s.reclaim_memory(g.get_oldest_used_generation()); } class MyTreeTestIterator : public MyTree::Iterator @@ -1555,7 +1555,7 @@ inc_generation(GenerationHandler &g, Tree &t) s.freeze(); s.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - s.trimHoldLists(g.get_oldest_used_generation()); + s.reclaim_memory(g.get_oldest_used_generation()); } template <typename Tree> diff --git a/vespalib/src/tests/btree/btreeaggregation_test.cpp b/vespalib/src/tests/btree/btreeaggregation_test.cpp index 6bbf9c13790..fb394df9861 100644 --- a/vespalib/src/tests/btree/btreeaggregation_test.cpp +++ b/vespalib/src/tests/btree/btreeaggregation_test.cpp @@ -274,7 +274,7 @@ freezeTree(GenerationHandler &g, ManagerType &m) m.freeze(); m.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - m.trimHoldLists(g.get_oldest_used_generation()); + m.reclaim_memory(g.get_oldest_used_generation()); } template <typename ManagerType> @@ -893,7 +893,7 @@ Test::requireThatWeCanInsertAndRemoveFromTree() manager.freeze(); manager.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - manager.trimHoldLists(g.get_oldest_used_generation()); + manager.reclaim_memory(g.get_oldest_used_generation()); } // remove entries for (size_t i = 0; i < numEntries; ++i) { @@ -1192,7 +1192,7 @@ Test::requireThatSmallNodesWorks() s.freeze(); s.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - s.trimHoldLists(g.get_oldest_used_generation()); + s.reclaim_memory(g.get_oldest_used_generation()); } void diff --git a/vespalib/src/tests/btree/frozenbtree_test.cpp b/vespalib/src/tests/btree/frozenbtree_test.cpp index 55b260fb1d9..0bde2786a0b 100644 --- a/vespalib/src/tests/btree/frozenbtree_test.cpp +++ b/vespalib/src/tests/btree/frozenbtree_test.cpp @@ -136,7 +136,7 @@ FrozenBTreeTest::freeTree(bool verbose) _allocator->freeze(); _allocator->assign_generation(_generationHandler->getCurrentGeneration()); _generationHandler->incGeneration(); - _allocator->trimHoldLists(_generationHandler->get_oldest_used_generation()); + _allocator->reclaim_memory(_generationHandler->get_oldest_used_generation()); delete _tree; _tree = NULL; delete _allocator; diff --git a/vespalib/src/tests/datastore/array_store/array_store_test.cpp b/vespalib/src/tests/datastore/array_store/array_store_test.cpp index 01c97bc98ab..afef530b33e 100644 --- a/vespalib/src/tests/datastore/array_store/array_store_test.cpp +++ b/vespalib/src/tests/datastore/array_store/array_store_test.cpp @@ -123,7 +123,7 @@ struct ArrayStoreTest : public TestT void assert_ref_reused(const EntryVector& first, const EntryVector& second, bool should_reuse) { EntryRef ref1 = add(first); remove(ref1); - trimHoldLists(); + reclaim_memory(); EntryRef ref2 = add(second); EXPECT_EQ(should_reuse, (ref2 == ref1)); assertGet(ref2, second); @@ -136,9 +136,9 @@ struct ArrayStoreTest : public TestT } return EntryRef(); } - void trimHoldLists() { + void reclaim_memory() { store.assign_generation(generation++); - store.trimHoldLists(generation); + store.reclaim_memory(generation); } void compactWorst(bool compactMemory, bool compactAddressSpace) { CompactionSpec compaction_spec(compactMemory, compactAddressSpace); @@ -283,7 +283,7 @@ TEST_P(NumberStoreTest, track_size_of_large_array_allocations_with_free_lists_en assert_buffer_stats(ref, TestBufferStats().used(2).hold(0).dead(1).extra_used(16)); remove({1,2,3,4}); assert_buffer_stats(ref, TestBufferStats().used(2).hold(1).dead(1).extra_hold(16).extra_used(16)); - trimHoldLists(); + reclaim_memory(); assert_buffer_stats(ref, TestBufferStats().used(2).hold(0).dead(2).extra_used(0)); add({5,6,7,8,9}); assert_buffer_stats(ref, TestBufferStats().used(2).hold(0).dead(1).extra_used(20)); @@ -316,7 +316,7 @@ test_compaction(NumberStoreBasicTest &f) EntryRef size2Ref = f.add({2,2}); EntryRef size3Ref = f.add({3,3,3}); f.remove(f.add({5,5})); - f.trimHoldLists(); + f.reclaim_memory(); f.assertBufferState(size1Ref, MemStats().used(1).dead(0)); f.assertBufferState(size2Ref, MemStats().used(4).dead(2)); f.assertBufferState(size3Ref, MemStats().used(2).dead(1)); // Note: First element is reserved @@ -335,7 +335,7 @@ test_compaction(NumberStoreBasicTest &f) EXPECT_NE(size2BufferId, f.getBufferId(f.getEntryRef({2,2}))); f.assertGet(size2Ref, {2,2}); // Old ref should still point to data. EXPECT_TRUE(f.store.bufferState(size2Ref).isOnHold()); - f.trimHoldLists(); + f.reclaim_memory(); EXPECT_TRUE(f.store.bufferState(size2Ref).isFree()); } @@ -360,7 +360,7 @@ void testCompaction(NumberStoreTest &f, bool compactMemory, bool compactAddressS f.remove(f.add({5,5,5})); f.remove(f.add({6})); f.remove(f.add({7})); - f.trimHoldLists(); + f.reclaim_memory(); f.assertBufferState(size1Ref, MemStats().used(3).dead(2)); f.assertBufferState(size2Ref, MemStats().used(2).dead(0)); f.assertBufferState(size3Ref, MemStats().used(6).dead(3)); @@ -397,7 +397,7 @@ void testCompaction(NumberStoreTest &f, bool compactMemory, bool compactAddressS EXPECT_FALSE(f.store.bufferState(size1Ref).isOnHold()); } EXPECT_FALSE(f.store.bufferState(size2Ref).isOnHold()); - f.trimHoldLists(); + f.reclaim_memory(); if (compactMemory) { EXPECT_TRUE(f.store.bufferState(size3Ref).isFree()); } else { @@ -436,7 +436,7 @@ TEST_P(NumberStoreTest, used_onHold_and_dead_memory_usage_is_tracked_for_small_a assertMemoryUsage(exp.used(entrySize() * 3)); remove({1,2,3}); assertMemoryUsage(exp.hold(entrySize() * 3)); - trimHoldLists(); + reclaim_memory(); assertMemoryUsage(exp.holdToDead(entrySize() * 3)); } @@ -447,7 +447,7 @@ TEST_P(NumberStoreTest, used_onHold_and_dead_memory_usage_is_tracked_for_large_a assertMemoryUsage(exp.used(largeArraySize() + entrySize() * 4)); remove({1,2,3,4}); assertMemoryUsage(exp.hold(largeArraySize() + entrySize() * 4)); - trimHoldLists(); + reclaim_memory(); assertMemoryUsage(exp.decUsed(entrySize() * 4).decHold(largeArraySize() + entrySize() * 4). dead(largeArraySize())); } diff --git a/vespalib/src/tests/datastore/datastore/datastore_test.cpp b/vespalib/src/tests/datastore/datastore/datastore_test.cpp index cd1f869ab64..10b96a87444 100644 --- a/vespalib/src/tests/datastore/datastore/datastore_test.cpp +++ b/vespalib/src/tests/datastore/datastore/datastore_test.cpp @@ -283,7 +283,7 @@ TEST(DataStoreTest, require_that_we_can_hold_and_trim_buffers) EXPECT_TRUE(s.getBufferState(1).size() != 0); EXPECT_TRUE(s.getBufferState(2).size() != 0); EXPECT_TRUE(s.getBufferState(3).size() != 0); - s.trimHoldLists(11); + s.reclaim_memory(11); EXPECT_TRUE(s.getBufferState(0).size() == 0); EXPECT_TRUE(s.getBufferState(1).size() != 0); EXPECT_TRUE(s.getBufferState(2).size() != 0); @@ -292,7 +292,7 @@ TEST(DataStoreTest, require_that_we_can_hold_and_trim_buffers) s.switch_primary_buffer(); EXPECT_EQ(0u, s.primary_buffer_id()); EXPECT_EQ(0u, MyRef(s.addEntry(5)).bufferId()); - s.trimHoldLists(41); + s.reclaim_memory(41); EXPECT_TRUE(s.getBufferState(0).size() != 0); EXPECT_TRUE(s.getBufferState(1).size() == 0); EXPECT_TRUE(s.getBufferState(2).size() == 0); @@ -446,7 +446,7 @@ TEST(DataStoreTest, require_that_memory_stats_are_calculated) m._freeBuffers--; // trim hold buffer - s.trimHoldLists(101); + s.reclaim_memory(101); m._allocElems -= MyRef::offsetSize(); m._usedElems = 1; m._deadElems = 0; @@ -485,7 +485,7 @@ TEST(DataStoreTest, require_that_memory_usage_is_calculated) EXPECT_EQ(5 * sizeof(int), m.usedBytes()); EXPECT_EQ(0 * sizeof(int), m.deadBytes()); EXPECT_EQ(5 * sizeof(int), m.allocatedBytesOnHold()); - s.trimHoldLists(101); + s.reclaim_memory(101); } TEST(DataStoreTest, require_that_we_can_disable_elemement_hold_list) @@ -514,7 +514,7 @@ TEST(DataStoreTest, require_that_we_can_disable_elemement_hold_list) EXPECT_EQ(2 * sizeof(int), m.deadBytes()); EXPECT_EQ(1 * sizeof(int), m.allocatedBytesOnHold()); s.assign_generation(100); - s.trimHoldLists(101); + s.reclaim_memory(101); } using IntGrowStore = GrowStore<int, EntryRefT<24>>; @@ -636,7 +636,7 @@ TEST(DataStoreTest, can_set_memory_allocator) s.holdBuffer(0); s.assign_generation(10); EXPECT_EQ(AllocStats(3, 0), stats); - s.trimHoldLists(11); + s.reclaim_memory(11); EXPECT_EQ(AllocStats(3, 2), stats); } EXPECT_EQ(AllocStats(3, 3), stats); @@ -694,7 +694,7 @@ void test_free_element_to_held_buffer(bool direct, bool before_hold_buffer) } } s.assign_generation(100); - s.trimHoldLists(101); + s.reclaim_memory(101); } } diff --git a/vespalib/src/tests/datastore/fixed_size_hash_map/fixed_size_hash_map_test.cpp b/vespalib/src/tests/datastore/fixed_size_hash_map/fixed_size_hash_map_test.cpp index 053cb804f21..4f4c3ac94eb 100644 --- a/vespalib/src/tests/datastore/fixed_size_hash_map/fixed_size_hash_map_test.cpp +++ b/vespalib/src/tests/datastore/fixed_size_hash_map/fixed_size_hash_map_test.cpp @@ -92,8 +92,8 @@ DataStoreFixedSizeHashTest::commit() _hash_map->assign_generation(_generation_handler.getCurrentGeneration()); _generation_holder.assign_generation(_generation_handler.getCurrentGeneration()); _generation_handler.incGeneration(); - _store.trimHoldLists(_generation_handler.get_oldest_used_generation()); - _hash_map->trim_hold_lists(_generation_handler.get_oldest_used_generation()); + _store.reclaim_memory(_generation_handler.get_oldest_used_generation()); + _hash_map->reclaim_memory(_generation_handler.get_oldest_used_generation()); _generation_holder.reclaim(_generation_handler.get_oldest_used_generation()); } diff --git a/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp b/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp index d19a45a263e..4c3fe1756c5 100644 --- a/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp +++ b/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp @@ -171,8 +171,8 @@ DataStoreShardedHashTest::commit() _store.assign_generation(_generationHandler.getCurrentGeneration()); _hash_map.assign_generation(_generationHandler.getCurrentGeneration()); _generationHandler.incGeneration(); - _store.trimHoldLists(_generationHandler.get_oldest_used_generation()); - _hash_map.trim_hold_lists(_generationHandler.get_oldest_used_generation()); + _store.reclaim_memory(_generationHandler.get_oldest_used_generation()); + _hash_map.reclaim_memory(_generationHandler.get_oldest_used_generation()); } void diff --git a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp index ff5b040dbf6..48a0ecafbc6 100644 --- a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp +++ b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp @@ -112,10 +112,10 @@ struct TestBase : public ::testing::Test { } return EntryRef(); } - void trimHoldLists() { + void reclaim_memory() { store.freeze(); store.assign_generation(generation++); - store.trimHoldLists(generation); + store.reclaim_memory(generation); } void compactWorst() { CompactionSpec compaction_spec(true, true); @@ -364,7 +364,7 @@ TYPED_TEST(TestBase, store_can_be_compacted) EntryRef val0Ref = this->add(this->values()[0]); EntryRef val1Ref = this->add(this->values()[1]); this->remove(this->add(this->values()[2])); - this->trimHoldLists(); + this->reclaim_memory(); size_t reserved = this->get_reserved(val0Ref); size_t array_size = this->get_array_size(val0Ref); this->assertBufferState(val0Ref, TestBufferStats().used(reserved + 3 * array_size).dead(reserved + array_size)); @@ -381,7 +381,7 @@ TYPED_TEST(TestBase, store_can_be_compacted) this->assertGet(val0Ref, this->values()[0]); this->assertGet(val1Ref, this->values()[1]); EXPECT_TRUE(this->store.bufferState(val0Ref).isOnHold()); - this->trimHoldLists(); + this->reclaim_memory(); EXPECT_TRUE(this->store.bufferState(val0Ref).isFree()); this->assertStoreContent(); } @@ -415,7 +415,7 @@ TYPED_TEST(TestBase, store_can_be_enumerated) EntryRef val0Ref = this->add(this->values()[0]); EntryRef val1Ref = this->add(this->values()[1]); this->remove(this->add(this->values()[2])); - this->trimHoldLists(); + this->reclaim_memory(); auto enumerator = this->getEnumerator(true); std::vector<uint32_t> refs; @@ -460,7 +460,7 @@ TEST_F(DoubleTest, nan_is_handled) for (auto &value : myvalues) { refs.emplace_back(add(value)); } - trimHoldLists(); + reclaim_memory(); EXPECT_TRUE(std::isnan(store.get(refs[1]))); EXPECT_TRUE(std::signbit(store.get(refs[1]))); EXPECT_TRUE(std::isinf(store.get(refs[2]))); diff --git a/vespalib/src/tests/datastore/unique_store_dictionary/unique_store_dictionary_test.cpp b/vespalib/src/tests/datastore/unique_store_dictionary/unique_store_dictionary_test.cpp index 1ee9e354285..496bc814d0d 100644 --- a/vespalib/src/tests/datastore/unique_store_dictionary/unique_store_dictionary_test.cpp +++ b/vespalib/src/tests/datastore/unique_store_dictionary/unique_store_dictionary_test.cpp @@ -64,7 +64,7 @@ struct UniqueStoreDictionaryTest : public ::testing::Test { dict.freeze(); dict.assign_generation(gen_handler.getCurrentGeneration()); gen_handler.incGeneration(); - dict.trim_hold_lists(gen_handler.get_oldest_used_generation()); + dict.reclaim_memory(gen_handler.get_oldest_used_generation()); } void take_snapshot() { dict.freeze(); diff --git a/vespalib/src/tests/datastore/unique_store_string_allocator/unique_store_string_allocator_test.cpp b/vespalib/src/tests/datastore/unique_store_string_allocator/unique_store_string_allocator_test.cpp index 4835af53b34..e865239787b 100644 --- a/vespalib/src/tests/datastore/unique_store_string_allocator/unique_store_string_allocator_test.cpp +++ b/vespalib/src/tests/datastore/unique_store_string_allocator/unique_store_string_allocator_test.cpp @@ -67,9 +67,9 @@ struct TestBase : public ::testing::Test { EXPECT_EQ(expStats._extra_used, buffer_state(ref).stats().extra_used_bytes()); EXPECT_EQ(expStats._extra_hold, buffer_state(ref).stats().extra_hold_bytes()); } - void trim_hold_lists() { + void reclaim_memory() { allocator.get_data_store().assign_generation(generation++); - allocator.get_data_store().trimHoldLists(generation); + allocator.get_data_store().reclaim_memory(generation); } }; @@ -89,7 +89,7 @@ TEST_F(StringTest, elements_are_put_on_hold_when_value_is_removed) assert_buffer_state(ref, TestBufferStats().used(16).hold(0).dead(0)); remove(ref); assert_buffer_state(ref, TestBufferStats().used(16).hold(16).dead(0)); - trim_hold_lists(); + reclaim_memory(); assert_buffer_state(ref, TestBufferStats().used(16).hold(0).dead(16)); } @@ -100,7 +100,7 @@ TEST_F(StringTest, extra_bytes_used_is_tracked) assert_buffer_state(ref, TestBufferStats().used(2).hold(0).dead(1).extra_used(1001)); remove(ref); assert_buffer_state(ref, TestBufferStats().used(2).hold(1).dead(1).extra_used(1001).extra_hold(1001)); - trim_hold_lists(); + reclaim_memory(); assert_buffer_state(ref, TestBufferStats().used(2).hold(0).dead(2)); ref = add(spaces1000.c_str()); assert_buffer_state(ref, TestBufferStats().used(2).hold(0).dead(1).extra_used(1001)); @@ -110,7 +110,7 @@ TEST_F(StringTest, extra_bytes_used_is_tracked) remove(ref); remove(ref2); assert_buffer_state(ref, TestBufferStats().used(3).hold(2).dead(1).extra_used(2002).extra_hold(2002)); - trim_hold_lists(); + reclaim_memory(); assert_buffer_state(ref, TestBufferStats().used(3).hold(0).dead(3)); } @@ -134,7 +134,7 @@ TEST_F(StringTest, free_list_is_used_when_enabled) EntryRef ref2 = add(spaces1000.c_str()); remove(ref1); remove(ref2); - trim_hold_lists(); + reclaim_memory(); EntryRef ref3 = add(small.c_str()); EntryRef ref4 = add(spaces1000.c_str()); EXPECT_EQ(ref1, ref3); @@ -150,7 +150,7 @@ TEST_F(StringTest, free_list_is_not_used_when_disabled) EntryRef ref2 = add(spaces1000.c_str()); remove(ref1); remove(ref2); - trim_hold_lists(); + reclaim_memory(); EntryRef ref3 = add(small.c_str()); EntryRef ref4 = add(spaces1000.c_str()); EXPECT_NE(ref1, ref3); @@ -168,7 +168,7 @@ TEST_F(StringTest, free_list_is_never_used_for_move_on_compact) EntryRef ref4 = add(spaces1000.c_str()); remove(ref3); remove(ref4); - trim_hold_lists(); + reclaim_memory(); EntryRef ref5 = move_on_compact(ref1); EntryRef ref6 = move_on_compact(ref2); EXPECT_NE(ref5, ref3); diff --git a/vespalib/src/vespa/vespalib/btree/btreenodeallocator.h b/vespalib/src/vespa/vespalib/btree/btreenodeallocator.h index 6835ca723d4..f803fce26b6 100644 --- a/vespalib/src/vespa/vespalib/btree/btreenodeallocator.h +++ b/vespalib/src/vespa/vespalib/btree/btreenodeallocator.h @@ -101,7 +101,7 @@ public: /** * Try to free held nodes if nobody can be referencing them. */ - void trimHoldLists(generation_t usedGen); + void reclaim_memory(generation_t oldest_used_gen); /** * Transfer nodes from hold1 lists to hold2 lists, they are no diff --git a/vespalib/src/vespa/vespalib/btree/btreenodeallocator.hpp b/vespalib/src/vespa/vespalib/btree/btreenodeallocator.hpp index 30dea7bf28b..8c10538acf7 100644 --- a/vespalib/src/vespa/vespalib/btree/btreenodeallocator.hpp +++ b/vespalib/src/vespa/vespalib/btree/btreenodeallocator.hpp @@ -266,9 +266,9 @@ template <typename KeyT, typename DataT, typename AggrT, size_t INTERNAL_SLOTS, size_t LEAF_SLOTS> void BTreeNodeAllocator<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS>:: -trimHoldLists(generation_t usedGen) +reclaim_memory(generation_t oldest_used_gen) { - _nodeStore.trimHoldLists(usedGen); + _nodeStore.reclaim_memory(oldest_used_gen); } template <typename KeyT, typename DataT, typename AggrT, diff --git a/vespalib/src/vespa/vespalib/btree/btreenodestore.h b/vespalib/src/vespa/vespalib/btree/btreenodestore.h index 28efd3b4efe..7d273c65e0e 100644 --- a/vespalib/src/vespa/vespalib/btree/btreenodestore.h +++ b/vespalib/src/vespa/vespalib/btree/btreenodestore.h @@ -172,8 +172,8 @@ public: } // Inherit doc from DataStoreBase - void trimHoldLists(generation_t usedGen) { - _store.trimHoldLists(usedGen); + void reclaim_memory(generation_t oldest_used_gen) { + _store.reclaim_memory(oldest_used_gen); } void clearHoldLists() { diff --git a/vespalib/src/vespa/vespalib/btree/btreestore.h b/vespalib/src/vespa/vespalib/btree/btreestore.h index 66a1c53814d..7bb7f978ae1 100644 --- a/vespalib/src/vespa/vespalib/btree/btreestore.h +++ b/vespalib/src/vespa/vespalib/btree/btreestore.h @@ -332,10 +332,10 @@ public: // Inherit doc from DataStoreBase void - trimHoldLists(generation_t usedGen) + reclaim_memory(generation_t oldest_used_gen) { - _allocator.trimHoldLists(usedGen); - _store.trimHoldLists(usedGen); + _allocator.reclaim_memory(oldest_used_gen); + _store.reclaim_memory(oldest_used_gen); } // Inherit doc from DataStoreBase diff --git a/vespalib/src/vespa/vespalib/datastore/array_store.h b/vespalib/src/vespa/vespalib/datastore/array_store.h index d807b02a879..e7662b9eb73 100644 --- a/vespalib/src/vespa/vespalib/datastore/array_store.h +++ b/vespalib/src/vespa/vespalib/datastore/array_store.h @@ -115,7 +115,7 @@ public: // Pass on hold list management to underlying store void assign_generation(generation_t current_gen) { _store.assign_generation(current_gen); } - void trimHoldLists(generation_t firstUsed) { _store.trimHoldLists(firstUsed); } + void reclaim_memory(generation_t oldest_used_gen) { _store.reclaim_memory(oldest_used_gen); } vespalib::GenerationHolder &getGenerationHolder() { return _store.getGenerationHolder(); } void setInitializing(bool initializing) { _store.setInitializing(initializing); } diff --git a/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp b/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp index 099410a502b..0d0287a1c78 100644 --- a/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp +++ b/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp @@ -235,10 +235,10 @@ DataStoreBase::doneHoldBuffer(uint32_t bufferId) } void -DataStoreBase::trimHoldLists(generation_t usedGen) +DataStoreBase::reclaim_memory(generation_t oldest_used_gen) { - reclaim_entry_refs(usedGen); // Trim entries before trimming buffers - _genHolder.reclaim(usedGen); + reclaim_entry_refs(oldest_used_gen); // Trim entries before trimming buffers + _genHolder.reclaim(oldest_used_gen); } void diff --git a/vespalib/src/vespa/vespalib/datastore/datastorebase.h b/vespalib/src/vespa/vespalib/datastore/datastorebase.h index d334692baad..931f81ee7fd 100644 --- a/vespalib/src/vespa/vespalib/datastore/datastorebase.h +++ b/vespalib/src/vespa/vespalib/datastore/datastorebase.h @@ -201,11 +201,11 @@ private: public: /** - * Trim hold lists, freeing buffers that no longer needs to be held. + * Reclaim memory from hold lists, freeing buffers and entry refs that no longer needs to be held. * - * @param usedGen lowest generation that is still used. + * @param oldest_used_gen oldest generation that is still used. */ - void trimHoldLists(generation_t usedGen); + void reclaim_memory(generation_t oldest_used_gen); void clearHoldLists(); diff --git a/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.cpp b/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.cpp index ad3fa7bd235..5338ce0c6b2 100644 --- a/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.cpp +++ b/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.cpp @@ -108,11 +108,11 @@ FixedSizeHashMap::assign_generation_slow(generation_t current_gen) void -FixedSizeHashMap::trim_hold_lists_slow(generation_t first_used) +FixedSizeHashMap::reclaim_memory_slow(generation_t oldest_used_gen) { while (!_hold_2_list.empty()) { auto& first = _hold_2_list.front(); - if (static_cast<sgeneration_t>(first.first - first_used) >= 0) { + if (static_cast<sgeneration_t>(first.first - oldest_used_gen) >= 0) { break; } uint32_t node_idx = first.second; diff --git a/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.h b/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.h index e2f4a2a89a5..de05ec1deb0 100644 --- a/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.h +++ b/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.h @@ -57,7 +57,7 @@ private: * that memory is held while it can be accessed by reader. * * The writer must update generation and call assign_generation and - * trim_hold_lists as needed to free up memory no longer needed by any + * reclaim_memory as needed to free up memory no longer needed by any * readers. */ class FixedSizeHashMap { @@ -115,7 +115,7 @@ private: uint32_t _num_shards; void assign_generation_slow(generation_t current_gen); - void trim_hold_lists_slow(generation_t first_used); + void reclaim_memory_slow(generation_t oldest_used_gen); void force_add(const EntryComparator& comp, const KvType& kv); public: FixedSizeHashMap(uint32_t module, uint32_t capacity, uint32_t num_shards); @@ -149,9 +149,9 @@ public: } } - void trim_hold_lists(generation_t first_used) { - if (!_hold_2_list.empty() && static_cast<sgeneration_t>(_hold_2_list.front().first - first_used) < 0) { - trim_hold_lists_slow(first_used); + void reclaim_memory(generation_t oldest_used_gen) { + if (!_hold_2_list.empty() && static_cast<sgeneration_t>(_hold_2_list.front().first - oldest_used_gen) < 0) { + reclaim_memory_slow(oldest_used_gen); } } diff --git a/vespalib/src/vespa/vespalib/datastore/i_unique_store_dictionary.h b/vespalib/src/vespa/vespalib/datastore/i_unique_store_dictionary.h index 533407d2f97..5a75a30d182 100644 --- a/vespalib/src/vespa/vespalib/datastore/i_unique_store_dictionary.h +++ b/vespalib/src/vespa/vespalib/datastore/i_unique_store_dictionary.h @@ -26,7 +26,7 @@ public: virtual ~IUniqueStoreDictionary() = default; virtual void freeze() = 0; virtual void assign_generation(generation_t current_gen) = 0; - virtual void trim_hold_lists(generation_t firstUsed) = 0; + virtual void reclaim_memory(generation_t oldest_used_gen) = 0; virtual UniqueStoreAddResult add(const EntryComparator& comp, std::function<EntryRef(void)> insertEntry) = 0; virtual EntryRef find(const EntryComparator& comp) = 0; virtual void remove(const EntryComparator& comp, EntryRef ref) = 0; diff --git a/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.cpp b/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.cpp index f72162a6be7..a28c3071646 100644 --- a/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.cpp +++ b/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.cpp @@ -119,15 +119,15 @@ ShardedHashMap::assign_generation(generation_t current_gen) } void -ShardedHashMap::trim_hold_lists(generation_t first_used) +ShardedHashMap::reclaim_memory(generation_t oldest_used_gen) { for (size_t i = 0; i < num_shards; ++i) { auto map = _maps[i].load(std::memory_order_relaxed); if (map != nullptr) { - map->trim_hold_lists(first_used); + map->reclaim_memory(oldest_used_gen); } } - _gen_holder.reclaim(first_used); + _gen_holder.reclaim(oldest_used_gen); } size_t diff --git a/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.h b/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.h index 89f24e66e69..572a8790828 100644 --- a/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.h +++ b/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.h @@ -29,7 +29,7 @@ struct ICompactable; * that memory is held while it can be accessed by reader. * * The writer must update generation and call assign_generation and - * trim_hold_lists as needed to free up memory no longer needed by any + * reclaim_memory as needed to free up memory no longer needed by any * readers. */ class ShardedHashMap { @@ -53,7 +53,7 @@ public: KvType* find(const EntryComparator& comp, EntryRef key_ref); const KvType* find(const EntryComparator& comp, EntryRef key_ref) const; void assign_generation(generation_t current_gen); - void trim_hold_lists(generation_t first_used); + void reclaim_memory(generation_t oldest_used_gen); size_t size() const noexcept; const EntryComparator &get_default_comparator() const noexcept { return *_comp; } MemoryUsage get_memory_usage() const; diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store.h b/vespalib/src/vespa/vespalib/datastore/unique_store.h index acbb3de3d17..1313d57fbab 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store.h +++ b/vespalib/src/vespa/vespalib/datastore/unique_store.h @@ -71,7 +71,7 @@ public: // Pass on hold list management to underlying store void assign_generation(generation_t current_gen); - void trimHoldLists(generation_t firstUsed); + void reclaim_memory(generation_t oldest_used_gen); vespalib::GenerationHolder &getGenerationHolder() { return _store.getGenerationHolder(); } void setInitializing(bool initializing) { _store.setInitializing(initializing); } void freeze(); diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp index 8477111dd01..b8493017020 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp @@ -198,10 +198,10 @@ UniqueStore<EntryT, RefT, Compare, Allocator>::assign_generation(generation_t cu template <typename EntryT, typename RefT, typename Compare, typename Allocator> void -UniqueStore<EntryT, RefT, Compare, Allocator>::trimHoldLists(generation_t firstUsed) +UniqueStore<EntryT, RefT, Compare, Allocator>::reclaim_memory(generation_t oldest_used_gen) { - _dict->trim_hold_lists(firstUsed); - _store.trimHoldLists(firstUsed); + _dict->reclaim_memory(oldest_used_gen); + _store.reclaim_memory(oldest_used_gen); } template <typename EntryT, typename RefT, typename Compare, typename Allocator> diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.h b/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.h index 3cbf7b999ff..8c5f284bb14 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.h +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.h @@ -75,7 +75,7 @@ public: ~UniqueStoreDictionary() override; void freeze() override; void assign_generation(generation_t current_gen) override; - void trim_hold_lists(generation_t firstUsed) override; + void reclaim_memory(generation_t oldest_used_gen) override; UniqueStoreAddResult add(const EntryComparator& comp, std::function<EntryRef(void)> insertEntry) override; EntryRef find(const EntryComparator& comp) override; void remove(const EntryComparator& comp, EntryRef ref) override; diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp index a3a477f334f..6708b4c1448 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp @@ -53,13 +53,13 @@ UniqueStoreDictionary<BTreeDictionaryT, ParentT, HashDictionaryT>::assign_genera template <typename BTreeDictionaryT, typename ParentT, typename HashDictionaryT> void -UniqueStoreDictionary<BTreeDictionaryT, ParentT, HashDictionaryT>::trim_hold_lists(generation_t firstUsed) +UniqueStoreDictionary<BTreeDictionaryT, ParentT, HashDictionaryT>::reclaim_memory(generation_t oldest_used_gen) { if constexpr (has_btree_dictionary) { - this->_btree_dict.getAllocator().trimHoldLists(firstUsed); + this->_btree_dict.getAllocator().reclaim_memory(oldest_used_gen); } if constexpr (has_hash_dictionary) { - this->_hash_dict.trim_hold_lists(firstUsed); + this->_hash_dict.reclaim_memory(oldest_used_gen); } } |