diff options
author | Geir Storli <geirst@yahooinc.com> | 2022-10-12 17:21:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-12 17:21:55 +0200 |
commit | 136d2dd0be0515a1cc2c4771081509dc4d080d7d (patch) | |
tree | e8ad6f37a4a41ade82d7d78c8cca9b3b97b84cd7 | |
parent | c2fff990ef096c124b235ce34e3975ccccdbe8d6 (diff) | |
parent | 10c830d6c43ca29cb13842ce41dfdc32c8a88969 (diff) |
Merge pull request #24407 from vespa-engine/geirst/generation-hold-list-terminology
Use more general terminology for handling of generation hold lists
94 files changed, 436 insertions, 439 deletions
diff --git a/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp b/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp index c52978261a7..7a5c76b201a 100644 --- a/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp +++ b/searchcore/src/tests/proton/attribute/imported_attributes_context/imported_attributes_context_test.cpp @@ -56,10 +56,11 @@ hasActiveEnumGuards(AttributeVector &attr) } void -assertGuards(AttributeVector &attr, generation_t expCurrentGeneration, generation_t expFirstUsedGeneration, bool expHasActiveEnumGuards) +assertGuards(AttributeVector &attr, generation_t expCurrentGeneration, generation_t exp_oldest_used_generation, + bool expHasActiveEnumGuards) { EXPECT_EQUAL(expCurrentGeneration, attr.getCurrentGeneration()); - EXPECT_EQUAL(expFirstUsedGeneration, attr.getFirstUsedGeneration()); + EXPECT_EQUAL(exp_oldest_used_generation, attr.get_oldest_used_generation()); EXPECT_EQUAL(expHasActiveEnumGuards, hasActiveEnumGuards(attr)); } 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/tests/proton/reference/gid_to_lid_mapper/gid_to_lid_mapper_test.cpp b/searchcore/src/tests/proton/reference/gid_to_lid_mapper/gid_to_lid_mapper_test.cpp index 2f4c26094c7..5152d09fae5 100644 --- a/searchcore/src/tests/proton/reference/gid_to_lid_mapper/gid_to_lid_mapper_test.cpp +++ b/searchcore/src/tests/proton/reference/gid_to_lid_mapper/gid_to_lid_mapper_test.cpp @@ -126,11 +126,11 @@ struct Fixture return std::make_shared<GidToLidMapperFactory>(_dmsContext); } - void assertGenerations(generation_t currentGeneration, generation_t firstUsedGeneration) + void assertGenerations(generation_t currentGeneration, generation_t oldest_used_generation) { const GenerationHandler &handler = _dms->getGenerationHandler(); EXPECT_EQUAL(currentGeneration, handler.getCurrentGeneration()); - EXPECT_EQUAL(firstUsedGeneration, handler.getFirstUsedGeneration()); + EXPECT_EQUAL(oldest_used_generation, handler.get_oldest_used_generation()); } template <typename Function> diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_vector_explorer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_vector_explorer.cpp index eeb8cafb859..c153f873480 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_vector_explorer.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_vector_explorer.cpp @@ -47,7 +47,7 @@ convertStatusToSlime(const Status &status, Cursor &object) void convertGenerationToSlime(const AttributeVector &attr, Cursor &object) { - object.setLong("firstUsed", attr.getFirstUsedGeneration()); + object.setLong("oldest_used", attr.get_oldest_used_generation()); object.setLong("current", attr.getCurrentGeneration()); } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp index 1853e939d42..c6ef6994b81 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp @@ -244,7 +244,7 @@ void DocumentMetaStore::onGenerationChange(generation_t generation) { _gidToLidMap.getAllocator().freeze(); - _gidToLidMap.getAllocator().transferHoldLists(generation - 1); + _gidToLidMap.getAllocator().assign_generation(generation - 1); getGenerationHolder().assign_generation(generation - 1); updateStat(false); } @@ -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); } @@ -318,7 +318,7 @@ DocumentMetaStore::onLoad(vespalib::Executor *) _gidToLidMap.assign(treeBuilder); _gidToLidMap.getAllocator().freeze(); // create initial frozen tree generation_t generation = getGenerationHandler().getCurrentGeneration(); - _gidToLidMap.getAllocator().transferHoldLists(generation); + _gidToLidMap.getAllocator().assign_generation(generation); setNumDocs(_metaDataStore.size()); setCommittedDocIdLimit(_metaDataStore.size()); @@ -433,7 +433,7 @@ DocumentMetaStore::DocumentMetaStore(BucketDBOwnerSP bucketDB, setCommittedDocIdLimit(1u); // lid 0 is reserved _gidToLidMap.getAllocator().freeze(); // create initial frozen tree generation_t generation = getGenerationHandler().getCurrentGeneration(); - _gidToLidMap.getAllocator().transferHoldLists(generation); + _gidToLidMap.getAllocator().assign_generation(generation); updateStat(true); } 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/attributemanager/attributemanager_test.cpp b/searchlib/src/tests/attribute/attributemanager/attributemanager_test.cpp index 7f0a88c9f86..3fa74b78d2a 100644 --- a/searchlib/src/tests/attribute/attributemanager/attributemanager_test.cpp +++ b/searchlib/src/tests/attribute/attributemanager/attributemanager_test.cpp @@ -38,8 +38,7 @@ public: generation_t getGen() const { return getCurrentGeneration(); } uint32_t getRefCount(generation_t gen) const { return getGenerationRefCount(gen); } void incGen() { incGeneration(); } - void updateFirstUsedGen() { updateFirstUsedGeneration(); } - generation_t getFirstUsedGen() const { return getFirstUsedGeneration(); } + generation_t oldest_used_gen() const { return get_oldest_used_generation(); } }; @@ -49,35 +48,35 @@ TEST("Test attribute guards") TestAttribute * v = static_cast<TestAttribute *> (vec.get()); EXPECT_EQUAL(v->getGen(), unsigned(0)); EXPECT_EQUAL(v->getRefCount(0), unsigned(0)); - EXPECT_EQUAL(v->getFirstUsedGen(), unsigned(0)); + EXPECT_EQUAL(v->oldest_used_gen(), unsigned(0)); { AttributeGuard g0(vec); EXPECT_EQUAL(v->getGen(), unsigned(0)); EXPECT_EQUAL(v->getRefCount(0), unsigned(1)); - EXPECT_EQUAL(v->getFirstUsedGen(), unsigned(0)); + EXPECT_EQUAL(v->oldest_used_gen(), unsigned(0)); { AttributeGuard g1(vec); EXPECT_EQUAL(v->getGen(), unsigned(0)); EXPECT_EQUAL(v->getRefCount(0), unsigned(2)); - EXPECT_EQUAL(v->getFirstUsedGen(), unsigned(0)); + EXPECT_EQUAL(v->oldest_used_gen(), unsigned(0)); } EXPECT_EQUAL(v->getRefCount(0), unsigned(1)); - EXPECT_EQUAL(v->getFirstUsedGen(), unsigned(0)); + EXPECT_EQUAL(v->oldest_used_gen(), unsigned(0)); } EXPECT_EQUAL(v->getRefCount(0), unsigned(0)); - EXPECT_EQUAL(v->getFirstUsedGen(), unsigned(0)); + EXPECT_EQUAL(v->oldest_used_gen(), unsigned(0)); v->incGen(); EXPECT_EQUAL(v->getGen(), unsigned(1)); EXPECT_EQUAL(v->getRefCount(0), unsigned(0)); EXPECT_EQUAL(v->getRefCount(1), unsigned(0)); - EXPECT_EQUAL(v->getFirstUsedGen(), unsigned(1)); + EXPECT_EQUAL(v->oldest_used_gen(), unsigned(1)); { AttributeGuard g0(vec); EXPECT_EQUAL(v->getGen(), unsigned(1)); EXPECT_EQUAL(v->getRefCount(0), unsigned(0)); EXPECT_EQUAL(v->getRefCount(1), unsigned(1)); - EXPECT_EQUAL(v->getFirstUsedGen(), unsigned(1)); + EXPECT_EQUAL(v->oldest_used_gen(), unsigned(1)); { v->incGen(); AttributeGuard g1(vec); @@ -85,19 +84,19 @@ TEST("Test attribute guards") EXPECT_EQUAL(v->getRefCount(0), unsigned(0)); EXPECT_EQUAL(v->getRefCount(1), unsigned(1)); EXPECT_EQUAL(v->getRefCount(2), unsigned(1)); - EXPECT_EQUAL(v->getFirstUsedGen(), unsigned(1)); + EXPECT_EQUAL(v->oldest_used_gen(), unsigned(1)); } EXPECT_EQUAL(v->getRefCount(0), unsigned(0)); EXPECT_EQUAL(v->getRefCount(1), unsigned(1)); EXPECT_EQUAL(v->getRefCount(2), unsigned(0)); - EXPECT_EQUAL(v->getFirstUsedGen(), unsigned(1)); + EXPECT_EQUAL(v->oldest_used_gen(), unsigned(1)); } EXPECT_EQUAL(v->getRefCount(0), unsigned(0)); EXPECT_EQUAL(v->getRefCount(1), unsigned(0)); EXPECT_EQUAL(v->getRefCount(2), unsigned(0)); - EXPECT_EQUAL(v->getFirstUsedGen(), unsigned(1)); - v->updateFirstUsedGeneration(); - EXPECT_EQUAL(v->getFirstUsedGen(), unsigned(2)); + EXPECT_EQUAL(v->oldest_used_gen(), unsigned(1)); + v->update_oldest_used_generation(); + EXPECT_EQUAL(v->oldest_used_gen(), unsigned(2)); EXPECT_EQUAL(v->getGen(), unsigned(2)); } 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 e27065f1c25..b89a3827cc2 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 @@ -135,7 +135,7 @@ DocumentWeightOrFilterSearchTest::~DocumentWeightOrFilterSearchTest() _postings.clear(tree); } _postings.clearBuilder(); - _postings.clearHoldLists(); + _postings.reclaim_all_memory(); inc_generation(); } @@ -143,10 +143,10 @@ void DocumentWeightOrFilterSearchTest::inc_generation() { _postings.freeze(); - _postings.transferHoldLists(_gens.getCurrentGeneration()); + _postings.assign_generation(_gens.getCurrentGeneration()); _gens.incGeneration(); - _gens.updateFirstUsedGeneration(); - _postings.trimHoldLists(_gens.getFirstUsedGeneration()); + _gens.update_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 1d76473754f..9d717202551 100644 --- a/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp +++ b/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp @@ -147,9 +147,9 @@ TEST("requireThatComparatorWithTreeIsWorking") EXPECT_EQUAL(101, exp); t.clear(m); m.freeze(); - m.transferHoldLists(g.getCurrentGeneration()); + m.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - m.trimHoldLists(g.getFirstUsedGeneration()); + 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 02ff01043b0..0542a253cc5 100644 --- a/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp +++ b/searchlib/src/tests/attribute/enumstore/enumstore_test.cpp @@ -345,8 +345,8 @@ TEST(EnumStoreTest, test_hold_lists_and_generation) // check readers again checkReaders(ses, readers); - ses.transfer_hold_lists(sesGen); - ses.trim_hold_lists(sesGen + 1); + ses.assign_generation(sesGen); + ses.reclaim_memory(sesGen + 1); } void @@ -357,8 +357,8 @@ dec_ref_count(NumericEnumStore& store, NumericEnumStore::Index idx) updater.commit(); generation_t gen = 5; - store.transfer_hold_lists(gen); - store.trim_hold_lists(gen + 1); + store.assign_generation(gen); + store.reclaim_memory(gen + 1); } TEST(EnumStoreTest, address_space_usage_is_reported) @@ -882,9 +882,9 @@ namespace { void inc_generation(generation_t &gen, NumericEnumStore &store) { store.freeze_dictionary(); - store.transfer_hold_lists(gen); + store.assign_generation(gen); ++gen; - store.trim_hold_lists(gen); + store.reclaim_memory(gen); } } diff --git a/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp b/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp index b9f3c23213e..0d2ce048111 100644 --- a/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp +++ b/searchlib/src/tests/attribute/imported_attribute_vector/imported_attribute_vector_test.cpp @@ -73,14 +73,14 @@ TEST_F("makeReadGuard(false) acquires guards on both target and reference attrib EXPECT_EQUAL(2u, f.target_attr->getCurrentGeneration()); EXPECT_EQUAL(2u, f.reference_attr->getCurrentGeneration()); // Should still be holding guard for first generation of writes for both attributes - EXPECT_EQUAL(1u, f.target_attr->getFirstUsedGeneration()); - EXPECT_EQUAL(1u, f.reference_attr->getFirstUsedGeneration()); + EXPECT_EQUAL(1u, f.target_attr->get_oldest_used_generation()); + EXPECT_EQUAL(1u, f.reference_attr->get_oldest_used_generation()); } // Force a generation handler update add_n_docs_with_undefined_values(*f.reference_attr, 1); add_n_docs_with_undefined_values(*f.target_attr, 1); - EXPECT_EQUAL(3u, f.target_attr->getFirstUsedGeneration()); - EXPECT_EQUAL(3u, f.reference_attr->getFirstUsedGeneration()); + EXPECT_EQUAL(3u, f.target_attr->get_oldest_used_generation()); + EXPECT_EQUAL(3u, f.reference_attr->get_oldest_used_generation()); } TEST_F("makeReadGuard(true) acquires enum guard on target and regular guard on reference attribute", Fixture) { @@ -95,15 +95,15 @@ TEST_F("makeReadGuard(true) acquires enum guard on target and regular guard on r EXPECT_EQUAL(5u, f.target_attr->getCurrentGeneration()); EXPECT_EQUAL(2u, f.reference_attr->getCurrentGeneration()); - EXPECT_EQUAL(3u, f.target_attr->getFirstUsedGeneration()); - EXPECT_EQUAL(1u, f.reference_attr->getFirstUsedGeneration()); + EXPECT_EQUAL(3u, f.target_attr->get_oldest_used_generation()); + EXPECT_EQUAL(1u, f.reference_attr->get_oldest_used_generation()); EXPECT_TRUE(has_active_enum_guards(*f.target_attr)); } // Force a generation handler update add_n_docs_with_undefined_values(*f.reference_attr, 1); add_n_docs_with_undefined_values(*f.target_attr, 1); - EXPECT_EQUAL(7u, f.target_attr->getFirstUsedGeneration()); - EXPECT_EQUAL(3u, f.reference_attr->getFirstUsedGeneration()); + EXPECT_EQUAL(7u, f.target_attr->get_oldest_used_generation()); + EXPECT_EQUAL(3u, f.reference_attr->get_oldest_used_generation()); EXPECT_FALSE(has_active_enum_guards(*f.target_attr)); } 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 735ebcff6cf..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,10 +42,10 @@ 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.transferHoldLists(generation - 1); + _mvMapping.assign_generation(generation - 1); } public: @@ -115,8 +115,8 @@ public: ConstArrayRef act = get(docId); EXPECT_EQ(exp, std::vector<EntryT>(act.cbegin(), act.cend())); } - void transferHoldLists(generation_t generation) { _mvMapping->transferHoldLists(generation); } - void trimHoldLists(generation_t firstUsed) { _mvMapping->trimHoldLists(firstUsed); } + void assign_generation(generation_t current_gen) { _mvMapping->assign_generation(current_gen); } + 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; @@ -245,12 +245,12 @@ TEST_F(IntMappingTest, test_that_old_value_is_not_overwritten_while_held) auto old3 = get(3); assertArray({5}, old3); set(3, {7}); - transferHoldLists(10); + 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 36babec6a89..75e7faf0227 100644 --- a/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp +++ b/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp @@ -64,11 +64,11 @@ protected: { _value_store.freeze_dictionary(); _store.freeze(); - _value_store.transfer_hold_lists(_gen_handler.getCurrentGeneration()); - _store.transferHoldLists(_gen_handler.getCurrentGeneration()); + _value_store.assign_generation(_gen_handler.getCurrentGeneration()); + _store.assign_generation(_gen_handler.getCurrentGeneration()); _gen_handler.incGeneration(); - _value_store.trim_hold_lists(_gen_handler.getFirstUsedGeneration()); - _store.trimHoldLists(_gen_handler.getFirstUsedGeneration()); + _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 54efb3261c8..e41aaec351e 100644 --- a/searchlib/src/tests/attribute/postinglist/postinglist.cpp +++ b/searchlib/src/tests/attribute/postinglist/postinglist.cpp @@ -259,12 +259,12 @@ AttributePostingListTest::freeTree(bool verbose) static_cast<uint64_t>(_intNodeAlloc->getMemoryUsage().allocatedBytesOnHold())); _intNodeAlloc->freeze(); _intPostings->freeze(); - _intNodeAlloc->transferHoldLists(_handler.getCurrentGeneration()); + _intNodeAlloc->assign_generation(_handler.getCurrentGeneration()); _intPostings->clearBuilder(); - _intPostings->transferHoldLists(_handler.getCurrentGeneration()); + _intPostings->assign_generation(_handler.getCurrentGeneration()); _handler.incGeneration(); - _intNodeAlloc->trimHoldLists(_handler.getFirstUsedGeneration()); - _intPostings->trimHoldLists(_handler.getFirstUsedGeneration()); + _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()), @@ -613,9 +613,9 @@ AttributePostingListTest::doCompactEnumStore(Tree &tree, valueHandle.holdBuffer(*it); } generation_t generation = _handler.getCurrentGeneration(); - valueHandle.transferHoldLists(generation); + valueHandle.assign_generation(generation); _handler.incGeneration(); - valueHandle.trimHoldLists(_handler.getFirstUsedGeneration()); + valueHandle.reclaim_memory(_handler.get_oldest_used_generation()); LOG(info, "doCompactEnumStore done"); @@ -658,8 +658,8 @@ bumpGeneration(Tree &tree, (void) tree; (void) valueHandle; postingsAlloc.freeze(); - postingsAlloc.transferHoldLists(_handler.getCurrentGeneration()); - postings.transferHoldLists(_handler.getCurrentGeneration()); + postingsAlloc.assign_generation(_handler.getCurrentGeneration()); + postings.assign_generation(_handler.getCurrentGeneration()); _handler.incGeneration(); } @@ -672,8 +672,8 @@ removeOldGenerations(Tree &tree, { (void) tree; (void) valueHandle; - postingsAlloc.trimHoldLists(_handler.getFirstUsedGeneration()); - postings.trimHoldLists(_handler.getFirstUsedGeneration()); + postingsAlloc.reclaim_memory(_handler.get_oldest_used_generation()); + postings.reclaim_memory(_handler.get_oldest_used_generation()); } int @@ -689,7 +689,7 @@ AttributePostingListTest::Main() lookupRandomValues(*_intTree, *_intNodeAlloc, *_intKeyStore, *_intPostings, _stlTree, _randomValues); _intNodeAlloc->freeze(); - _intNodeAlloc->transferHoldLists(_handler.getCurrentGeneration()); + _intNodeAlloc->assign_generation(_handler.getCurrentGeneration()); doCompactEnumStore(*_intTree, *_intNodeAlloc, *_intKeyStore); removeRandomValues(*_intTree, *_intNodeAlloc, *_intKeyStore, *_intPostings, _stlTree, _randomValues); diff --git a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp index 222a3341ef9..9127c4b59fc 100644 --- a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp +++ b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp @@ -221,11 +221,11 @@ public: auto vector = _vectors.get_vector(docid).typify<double>(); _removes.emplace_back(docid, DoubleVector(vector.begin(), vector.end())); } - void transfer_hold_lists(generation_t current_gen) override { + 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/direct_tensor_store/direct_tensor_store_test.cpp b/searchlib/src/tests/tensor/direct_tensor_store/direct_tensor_store_test.cpp index 64cb6a6c146..cb9fa8522a8 100644 --- a/searchlib/src/tests/tensor/direct_tensor_store/direct_tensor_store_test.cpp +++ b/searchlib/src/tests/tensor/direct_tensor_store/direct_tensor_store_test.cpp @@ -58,7 +58,7 @@ public: DirectTensorStoreTest() : store() {} virtual ~DirectTensorStoreTest() { - store.clearHoldLists(); + store.reclaim_all_memory(); } void expect_tensor(const Value* exp, EntryRef ref) { 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 7877b488065..958423860e5 100644 --- a/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp +++ b/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp @@ -99,10 +99,10 @@ public: commit(); } void commit() { - index->transfer_hold_lists(gen_handler.getCurrentGeneration()); + index->assign_generation(gen_handler.getCurrentGeneration()); gen_handler.incGeneration(); - gen_handler.updateFirstUsedGeneration(); - index->trim_hold_lists(gen_handler.getFirstUsedGeneration()); + gen_handler.update_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 d559fa592ad..47812c2a63c 100644 --- a/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp +++ b/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp @@ -267,10 +267,10 @@ public: ASSERT_EQ(r.get(), nullptr); } void commit(uint32_t docid) { - index->transfer_hold_lists(gen_handler.getCurrentGeneration()); + index->assign_generation(gen_handler.getCurrentGeneration()); gen_handler.incGeneration(); - gen_handler.updateFirstUsedGeneration(); - index->trim_hold_lists(gen_handler.getFirstUsedGeneration()); + gen_handler.update_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/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp index 963285d760d..876830bb186 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp @@ -409,8 +409,8 @@ bool AttributeVector::applyWeight(DocId, const FieldValue&, const AssignValueUpd void AttributeVector::removeAllOldGenerations() { - _genHandler.updateFirstUsedGeneration(); - removeOldGenerations(_genHandler.getFirstUsedGeneration()); + _genHandler.update_oldest_used_generation(); + removeOldGenerations(_genHandler.get_oldest_used_generation()); } @@ -483,14 +483,12 @@ AttributeVector::compactLidSpace(uint32_t wantedLidLimit) { incGeneration(); } - bool AttributeVector::canShrinkLidSpace() const { return wantShrinkLidSpace() && - _compactLidSpaceGeneration.load(std::memory_order_relaxed) < getFirstUsedGeneration(); + _compactLidSpaceGeneration.load(std::memory_order_relaxed) < get_oldest_used_generation(); } - void AttributeVector::shrinkLidSpace() { diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h index f245a216aeb..4d4cd8ac35f 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.h +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h @@ -158,8 +158,8 @@ public: void incGeneration(); void removeAllOldGenerations(); - generation_t getFirstUsedGeneration() const { - return _genHandler.getFirstUsedGeneration(); + generation_t get_oldest_used_generation() const { + return _genHandler.get_oldest_used_generation(); } generation_t getCurrentGeneration() const { @@ -466,8 +466,8 @@ public: /** * Should be called by the writer thread. */ - void updateFirstUsedGeneration() { - _genHandler.updateFirstUsedGeneration(); + void update_oldest_used_generation() { + _genHandler.update_oldest_used_generation(); } /** diff --git a/searchlib/src/vespa/searchlib/attribute/enumstore.h b/searchlib/src/vespa/searchlib/attribute/enumstore.h index 52f42ed368e..0a0b2040b2a 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstore.h +++ b/searchlib/src/vespa/searchlib/attribute/enumstore.h @@ -96,8 +96,8 @@ public: vespalib::AddressSpace get_values_address_space_usage() const override; - void transfer_hold_lists(generation_t generation); - void trim_hold_lists(generation_t first_used); + void assign_generation(generation_t current_gen); + 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 1ef194f6812..b863e56fb4a 100644 --- a/searchlib/src/vespa/searchlib/attribute/enumstore.hpp +++ b/searchlib/src/vespa/searchlib/attribute/enumstore.hpp @@ -104,17 +104,17 @@ EnumStoreT<EntryT>::get_values_address_space_usage() const template <typename EntryT> void -EnumStoreT<EntryT>::transfer_hold_lists(generation_t generation) +EnumStoreT<EntryT>::assign_generation(generation_t current_gen) { - _store.transferHoldLists(generation); + _store.assign_generation(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 61798959f3e..98587baadd2 100644 --- a/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.h +++ b/searchlib/src/vespa/searchlib/attribute/multi_value_mapping.h @@ -48,8 +48,8 @@ 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 transferHoldLists(generation_t generation) { _store.transferHoldLists(generation); } - void trimHoldLists(generation_t firstUsed) { _store.trimHoldLists(firstUsed); } + void assign_generation(generation_t current_gen) { _store.assign_generation(current_gen); } + 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 ec948882312..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> @@ -211,8 +211,8 @@ MultiValueEnumAttribute<B, M>::onGenerationChange(generation_t generation) * sufficiently new frozen tree. */ freezeEnumDictionary(); - this->_mvMapping.transferHoldLists(generation - 1); - this->_enumStore.transfer_hold_lists(generation - 1); + this->_mvMapping.assign_generation(generation - 1); + this->_enumStore.assign_generation(generation - 1); } template <typename B, typename M> diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp index 8cabd8483bf..2405841f331 100644 --- a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp +++ b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.hpp @@ -98,14 +98,14 @@ 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); } template <typename B, typename M> void MultiValueNumericAttribute<B, M>::onGenerationChange(generation_t generation) { - this->_mvMapping.transferHoldLists(generation - 1); + this->_mvMapping.assign_generation(generation - 1); } template <typename B, typename M> diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multinumericpostattribute.hpp index 9a8c9738bc0..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> @@ -68,7 +68,7 @@ MultiValueNumericPostingAttribute<B, M>::onGenerationChange(generation_t generat { _postingList.freeze(); MultiValueNumericEnumAttribute<B, M>::onGenerationChange(generation); - _postingList.transferHoldLists(generation - 1); + _postingList.assign_generation(generation - 1); } template <typename B, typename M> diff --git a/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/multistringpostattribute.hpp index fef3db582c8..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> @@ -87,7 +87,7 @@ MultiValueStringPostingAttributeT<B, T>::onGenerationChange(generation_t generat { _postingList.freeze(); MultiValueStringAttributeT<B, T>::onGenerationChange(generation); - _postingList.transferHoldLists(generation - 1); + _postingList.assign_generation(generation - 1); } diff --git a/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp index f2e07bba853..8593b013443 100644 --- a/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp +++ b/searchlib/src/vespa/searchlib/attribute/predicate_attribute.cpp @@ -128,14 +128,14 @@ void PredicateAttribute::removeOldGenerations(generation_t firstUsed) { getGenerationHolder().reclaim(firstUsed); - _index->trimHoldLists(firstUsed); + _index->reclaim_memory(firstUsed); } void PredicateAttribute::onGenerationChange(generation_t generation) { getGenerationHolder().assign_generation(generation - 1); - _index->transferHoldLists(generation - 1); + _index->assign_generation(generation - 1); } void diff --git a/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/reference_attribute.cpp index 36fb02f4c4b..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); } @@ -173,8 +173,8 @@ ReferenceAttribute::onGenerationChange(generation_t generation) { _referenceMappings.freeze(); _store.freeze(); - _referenceMappings.transferHoldLists(generation - 1); - _store.transferHoldLists(generation - 1); + _referenceMappings.assign_generation(generation - 1); + _store.assign_generation(generation - 1); getGenerationHolder().assign_generation(generation - 1); } diff --git a/searchlib/src/vespa/searchlib/attribute/reference_mappings.h b/searchlib/src/vespa/searchlib/attribute/reference_mappings.h index 2ccc164bf08..cf26b424208 100644 --- a/searchlib/src/vespa/searchlib/attribute/reference_mappings.h +++ b/searchlib/src/vespa/searchlib/attribute/reference_mappings.h @@ -59,9 +59,9 @@ 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 transferHoldLists(generation_t generation) { _reverseMapping.transferHoldLists(generation); } + void assign_generation(generation_t current_gen) { _reverseMapping.assign_generation(current_gen); } // Handle mapping changes void notifyReferencedPut(const Reference &entry, uint32_t targetLid); diff --git a/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singleenumattribute.hpp index 11742bf8f48..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); } @@ -282,7 +282,7 @@ SingleValueEnumAttribute<B>::onGenerationChange(generation_t generation) */ freezeEnumDictionary(); getGenerationHolder().assign_generation(generation - 1); - this->_enumStore.transfer_hold_lists(generation - 1); + this->_enumStore.assign_generation(generation - 1); } diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlenumericpostattribute.hpp index 2050f887c33..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> @@ -139,7 +139,7 @@ SingleValueNumericPostingAttribute<B>::onGenerationChange(generation_t generatio { _postingList.freeze(); SingleValueNumericEnumAttribute<B>::onGenerationChange(generation); - _postingList.transferHoldLists(generation - 1); + _postingList.assign_generation(generation - 1); } template <typename B> diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlestringpostattribute.hpp index f340d9f70c3..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> @@ -139,7 +139,7 @@ SingleValueStringPostingAttributeT<B>::onGenerationChange(generation_t generatio { _postingList.freeze(); SingleValueStringAttributeT<B>::onGenerationChange(generation); - _postingList.transferHoldLists(generation - 1); + _postingList.assign_generation(generation - 1); } template <typename B> diff --git a/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp b/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp index 7036ef238b6..cdf7e5f5ea8 100644 --- a/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp +++ b/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp @@ -109,8 +109,8 @@ LogDataStore::~LogDataStore() { // Must be called before ending threads as there are sanity checks. _fileChunks.clear(); - _genHandler.updateFirstUsedGeneration(); - _lidInfo.removeOldGenerations(_genHandler.getFirstUsedGeneration()); + _genHandler.update_oldest_used_generation(); + _lidInfo.removeOldGenerations(_genHandler.get_oldest_used_generation()); } void @@ -485,8 +485,8 @@ void LogDataStore::compactFile(FileId fileId) FileChunk::UP toDie; for (;;) { MonitorGuard guard(_updateLock); - _genHandler.updateFirstUsedGeneration(); - if (currentGeneration < _genHandler.getFirstUsedGeneration()) { + _genHandler.update_oldest_used_generation(); + if (currentGeneration < _genHandler.get_oldest_used_generation()) { if (_holdFileChunks[fc->getFileId().getId()] == 0u) { toDie = std::move(fc); break; @@ -939,8 +939,8 @@ LogDataStore::setLid(const MonitorGuard &guard, uint32_t lid, const LidInfo &met { (void) guard; if (lid < _lidInfo.size()) { - _genHandler.updateFirstUsedGeneration(); - _lidInfo.removeOldGenerations(_genHandler.getFirstUsedGeneration()); + _genHandler.update_oldest_used_generation(); + _lidInfo.removeOldGenerations(_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()); @@ -958,8 +958,8 @@ LogDataStore::incGeneration() { _lidInfo.setGeneration(_genHandler.getNextGeneration()); _genHandler.incGeneration(); - _genHandler.updateFirstUsedGeneration(); - _lidInfo.removeOldGenerations(_genHandler.getFirstUsedGeneration()); + _genHandler.update_oldest_used_generation(); + _lidInfo.removeOldGenerations(_genHandler.get_oldest_used_generation()); } size_t @@ -1213,7 +1213,7 @@ LogDataStore::canShrinkLidSpace(const MonitorGuard &) const { // Update lock is held, allowing call to _lidInfo.get_size() return getDocIdLimit() < _lidInfo.get_size() && - _compactLidSpaceGeneration < _genHandler.getFirstUsedGeneration(); + _compactLidSpaceGeneration < _genHandler.get_oldest_used_generation(); } size_t diff --git a/searchlib/src/vespa/searchlib/memoryindex/feature_store.h b/searchlib/src/vespa/searchlib/memoryindex/feature_store.h index adeeba4d06e..5f5e782a382 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/feature_store.h +++ b/searchlib/src/vespa/searchlib/memoryindex/feature_store.h @@ -205,9 +205,9 @@ public: const std::vector<PosOccFieldsParams> &getFieldsParams() const { return _fieldsParams; } - void trimHoldLists(generation_t usedGen) { _store.trimHoldLists(usedGen); } - void transferHoldLists(generation_t generation) { _store.transferHoldLists(generation); } - void clearHoldLists() { _store.clearHoldLists();} + 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 reclaim_all_memory() { _store.reclaim_all_memory();} std::unique_ptr<vespalib::datastore::CompactingBuffers> start_compact(); vespalib::MemoryUsage getMemoryUsage() const { return _store.getMemoryUsage(); } vespalib::datastore::MemoryStats getMemStats() const { return _store.getMemStats(); } diff --git a/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp b/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp index da95f2598b7..4be3031303e 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp +++ b/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp @@ -69,12 +69,12 @@ FieldIndex<interleaved_features>::~FieldIndex() } _postingListStore.clearBuilder(); freeze(); // Flush all pending posting list tree freezes - transferHoldLists(); + assign_generation(); _dict.clear(); // Clear dictionary freeze(); // Flush pending freeze for dictionary tree. - transferHoldLists(); + assign_generation(); incGeneration(); - trimHoldLists(); + reclaim_memory(); } template <bool interleaved_features> @@ -143,7 +143,7 @@ FieldIndex<interleaved_features>::compactFeatures() using generation_t = GenerationHandler::generation_t; compacting_buffers->finish(); generation_t generation = _generationHandler.getCurrentGeneration(); - _featureStore.transferHoldLists(generation); + _featureStore.assign_generation(generation); } 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 fb02ed880b4..187ec5ee971 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/field_index.h +++ b/searchlib/src/vespa/searchlib/memoryindex/field_index.h @@ -52,20 +52,20 @@ private: _dict.getAllocator().freeze(); } - void trimHoldLists() { - GenerationHandler::generation_t usedGen = - _generationHandler.getFirstUsedGeneration(); - _postingListStore.trimHoldLists(usedGen); - _dict.getAllocator().trimHoldLists(usedGen); - _featureStore.trimHoldLists(usedGen); + void reclaim_memory() { + GenerationHandler::generation_t oldest_used_gen = + _generationHandler.get_oldest_used_generation(); + _postingListStore.reclaim_memory(oldest_used_gen); + _dict.getAllocator().reclaim_memory(oldest_used_gen); + _featureStore.reclaim_memory(oldest_used_gen); } - void transferHoldLists() { + void assign_generation() { GenerationHandler::generation_t generation = _generationHandler.getCurrentGeneration(); - _postingListStore.transferHoldLists(generation); - _dict.getAllocator().transferHoldLists(generation); - _featureStore.transferHoldLists(generation); + _postingListStore.assign_generation(generation); + _dict.getAllocator().assign_generation(generation); + _featureStore.assign_generation(generation); } void incGeneration() { @@ -90,9 +90,9 @@ public: void commit() override { _remover.flush(); freeze(); - transferHoldLists(); + 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 c64c490039b..f21ca1b11cc 100644 --- a/searchlib/src/vespa/searchlib/predicate/predicate_index.cpp +++ b/searchlib/src/vespa/searchlib/predicate/predicate_index.cpp @@ -213,19 +213,19 @@ 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 -PredicateIndex::transferHoldLists(generation_t generation) { - _interval_index.transferHoldLists(generation); - _bounds_index.transferHoldLists(generation); - _interval_store.transferHoldLists(generation); - _zero_constraint_docs.getAllocator().transferHoldLists(generation); +PredicateIndex::assign_generation(generation_t current_gen) { + _interval_index.assign_generation(current_gen); + _bounds_index.assign_generation(current_gen); + _interval_store.assign_generation(current_gen); + _zero_constraint_docs.getAllocator().assign_generation(current_gen); } vespalib::MemoryUsage diff --git a/searchlib/src/vespa/searchlib/predicate/predicate_index.h b/searchlib/src/vespa/searchlib/predicate/predicate_index.h index 1bad95c6aa9..238314e17f9 100644 --- a/searchlib/src/vespa/searchlib/predicate/predicate_index.h +++ b/searchlib/src/vespa/searchlib/predicate/predicate_index.h @@ -73,8 +73,8 @@ 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 transferHoldLists(generation_t generation); + void reclaim_memory(generation_t oldest_used_gen); + void assign_generation(generation_t current_gen); vespalib::MemoryUsage getMemoryUsage() const; int getArity() const { return _arity; } diff --git a/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.cpp b/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.cpp index 379c859f6c3..af809b2fa69 100644 --- a/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.cpp +++ b/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.cpp @@ -100,13 +100,13 @@ 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 -PredicateIntervalStore::transferHoldLists(generation_t generation) { - _store.transferHoldLists(generation); +PredicateIntervalStore::assign_generation(generation_t current_gen) { + _store.assign_generation(current_gen); } } diff --git a/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.h b/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.h index 0b3e32ec6b7..a96c208393d 100644 --- a/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.h +++ b/searchlib/src/vespa/searchlib/predicate/predicate_interval_store.h @@ -71,9 +71,9 @@ public: */ void remove(vespalib::datastore::EntryRef ref); - void trimHoldLists(generation_t used_generation); + void reclaim_memory(generation_t oldest_used_gen); - void transferHoldLists(generation_t generation); + void assign_generation(generation_t current_gen); /** * Return memory usage (only the data store is included) diff --git a/searchlib/src/vespa/searchlib/predicate/simple_index.h b/searchlib/src/vespa/searchlib/predicate/simple_index.h index 78805820a30..d49e42a1e35 100644 --- a/searchlib/src/vespa/searchlib/predicate/simple_index.h +++ b/searchlib/src/vespa/searchlib/predicate/simple_index.h @@ -187,8 +187,8 @@ 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 transferHoldLists(generation_t generation); + void reclaim_memory(generation_t oldest_used_gen); + void assign_generation(generation_t current_gen); vespalib::MemoryUsage getMemoryUsage() const; template <typename FunctionType> void foreach_frozen_key(vespalib::datastore::EntryRef ref, Key key, FunctionType func) const; diff --git a/searchlib/src/vespa/searchlib/predicate/simple_index.hpp b/searchlib/src/vespa/searchlib/predicate/simple_index.hpp index cb37fec26ea..c6f640d72ed 100644 --- a/searchlib/src/vespa/searchlib/predicate/simple_index.hpp +++ b/searchlib/src/vespa/searchlib/predicate/simple_index.hpp @@ -54,17 +54,17 @@ SimpleIndex<Posting, Key, DocId>::~SimpleIndex() { _vector_posting_lists.disableElemHoldList(); _vector_posting_lists.clear(); _vector_posting_lists.getAllocator().freeze(); - _vector_posting_lists.getAllocator().clearHoldLists(); + _vector_posting_lists.getAllocator().reclaim_all_memory(); _dictionary.disableFreeLists(); _dictionary.disableElemHoldList(); _dictionary.clear(); _dictionary.getAllocator().freeze(); - _dictionary.getAllocator().clearHoldLists(); + _dictionary.getAllocator().reclaim_all_memory(); _btree_posting_lists.clearBuilder(); _btree_posting_lists.freeze(); - _btree_posting_lists.clearHoldLists(); + _btree_posting_lists.reclaim_all_memory(); } template <typename Posting, typename Key, typename DocId> @@ -291,19 +291,19 @@ 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); } template <typename Posting, typename Key, typename DocId> void -SimpleIndex<Posting, Key, DocId>::transferHoldLists(generation_t generation) { - _dictionary.getAllocator().transferHoldLists(generation); - _btree_posting_lists.transferHoldLists(generation); - _vector_posting_lists.getAllocator().transferHoldLists(generation); +SimpleIndex<Posting, Key, DocId>::assign_generation(generation_t current_gen) { + _dictionary.getAllocator().assign_generation(current_gen); + _btree_posting_lists.assign_generation(current_gen); + _vector_posting_lists.getAllocator().assign_generation(current_gen); } template <typename Posting, typename Key, typename DocId> diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp index 0c797fa7fe1..6a47e0da5df 100644 --- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp @@ -173,7 +173,7 @@ DenseTensorAttribute::DenseTensorAttribute(vespalib::stringref baseFileName, con DenseTensorAttribute::~DenseTensorAttribute() { getGenerationHolder().reclaim_all(); - _tensorStore.clearHoldLists(); + _tensorStore.reclaim_all_memory(); } uint32_t @@ -456,7 +456,7 @@ DenseTensorAttribute::onGenerationChange(generation_t next_gen) // This applies for entire attribute vector code. TensorAttribute::onGenerationChange(next_gen); if (_index) { - _index->transfer_hold_lists(next_gen - 1); + _index->assign_generation(next_gen - 1); } } @@ -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/direct_tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/direct_tensor_attribute.cpp index a68f7fcc3da..22db5dc5b47 100644 --- a/searchlib/src/vespa/searchlib/tensor/direct_tensor_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/direct_tensor_attribute.cpp @@ -16,7 +16,7 @@ DirectTensorAttribute::DirectTensorAttribute(stringref name, const Config &cfg) DirectTensorAttribute::~DirectTensorAttribute() { getGenerationHolder().reclaim_all(); - _tensorStore.clearHoldLists(); + _tensorStore.reclaim_all_memory(); } void diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp index d23bbcfbed4..d505e939a34 100644 --- a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp +++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp @@ -511,21 +511,21 @@ HnswIndex::remove_document(uint32_t docid) } void -HnswIndex::transfer_hold_lists(generation_t current_gen) +HnswIndex::assign_generation(generation_t current_gen) { // Note: RcuVector transfers hold lists as part of reallocation based on current generation. // We need to set the next generation here, as it is incremented on a higher level right after this call. _graph.node_refs.setGeneration(current_gen + 1); - _graph.nodes.transferHoldLists(current_gen); - _graph.links.transferHoldLists(current_gen); + _graph.nodes.assign_generation(current_gen); + _graph.links.assign_generation(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 e3ffada1fc2..8a7422907ea 100644 --- a/searchlib/src/vespa/searchlib/tensor/hnsw_index.h +++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index.h @@ -187,8 +187,8 @@ public: vespalib::GenerationHandler::Guard read_guard) const override; void complete_add_document(uint32_t docid, std::unique_ptr<PrepareResult> prepare_result) override; void remove_document(uint32_t docid) override; - void transfer_hold_lists(generation_t current_gen) override; - void trim_hold_lists(generation_t first_used_gen) override; + void assign_generation(generation_t current_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 51d66fdd14d..d40803dcafd 100644 --- a/searchlib/src/vespa/searchlib/tensor/nearest_neighbor_index.h +++ b/searchlib/src/vespa/searchlib/tensor/nearest_neighbor_index.h @@ -68,8 +68,8 @@ public: virtual void complete_add_document(uint32_t docid, std::unique_ptr<PrepareResult> prepare_result) = 0; virtual void remove_document(uint32_t docid) = 0; - virtual void transfer_hold_lists(generation_t current_gen) = 0; - virtual void trim_hold_lists(generation_t first_used_gen) = 0; + virtual void assign_generation(generation_t current_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/serialized_fast_value_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/serialized_fast_value_attribute.cpp index d2153ac93ad..bb1c1a3d880 100644 --- a/searchlib/src/vespa/searchlib/tensor/serialized_fast_value_attribute.cpp +++ b/searchlib/src/vespa/searchlib/tensor/serialized_fast_value_attribute.cpp @@ -24,7 +24,7 @@ SerializedFastValueAttribute::SerializedFastValueAttribute(stringref name, const SerializedFastValueAttribute::~SerializedFastValueAttribute() { getGenerationHolder().reclaim_all(); - _tensorStore.clearHoldLists(); + _tensorStore.reclaim_all_memory(); } void diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/tensor_attribute.cpp index b233960e339..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); } @@ -120,7 +120,7 @@ void TensorAttribute::onGenerationChange(generation_t generation) { getGenerationHolder().assign_generation(generation - 1); - _tensorStore.transferHoldLists(generation - 1); + _tensorStore.assign_generation(generation - 1); } bool diff --git a/searchlib/src/vespa/searchlib/tensor/tensor_store.h b/searchlib/src/vespa/searchlib/tensor/tensor_store.h index e2426d2e899..53551bc48fa 100644 --- a/searchlib/src/vespa/searchlib/tensor/tensor_store.h +++ b/searchlib/src/vespa/searchlib/tensor/tensor_store.h @@ -48,17 +48,17 @@ 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 - void transferHoldLists(generation_t generation) { - _store.transferHoldLists(generation); + void assign_generation(generation_t current_gen) { + _store.assign_generation(current_gen); } - void clearHoldLists() { - _store.clearHoldLists(); + void reclaim_all_memory() { + _store.reclaim_all_memory(); } vespalib::MemoryUsage getMemoryUsage() const { diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp index 6e86d70fe52..e918c523fcf 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp @@ -169,9 +169,9 @@ FakeMemTreeOccMgr::freeze() void -FakeMemTreeOccMgr::transferHoldLists() +FakeMemTreeOccMgr::assign_generation() { - _allocator.transferHoldLists(_generationHandler.getCurrentGeneration()); + _allocator.assign_generation(_generationHandler.getCurrentGeneration()); } void @@ -182,9 +182,9 @@ FakeMemTreeOccMgr::incGeneration() void -FakeMemTreeOccMgr::trimHoldLists() +FakeMemTreeOccMgr::reclaim_memory() { - _allocator.trimHoldLists(_generationHandler.getFirstUsedGeneration()); + _allocator.reclaim_memory(_generationHandler.get_oldest_used_generation()); } @@ -192,9 +192,9 @@ void FakeMemTreeOccMgr::sync() { freeze(); - transferHoldLists(); + 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 d0a75930ed5..290ba1cf140 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.h +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.h @@ -94,9 +94,9 @@ public: ~FakeMemTreeOccMgr(); void freeze(); - void transferHoldLists(); + 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 9db36e96fc0..125882f7fe7 100644 --- a/storage/src/vespa/storage/bucketdb/generic_btree_bucket_database.hpp +++ b/storage/src/vespa/storage/bucketdb/generic_btree_bucket_database.hpp @@ -38,14 +38,14 @@ void GenericBTreeBucketDatabase<DataStoreTraitsT>::commit_tree_changes() { _tree.getAllocator().freeze(); auto current_gen = _generation_handler.getCurrentGeneration(); - _store.transferHoldLists(current_gen); - _tree.getAllocator().transferHoldLists(current_gen); + _store.assign_generation(current_gen); + _tree.getAllocator().assign_generation(current_gen); _generation_handler.incGeneration(); - auto used_gen = _generation_handler.getFirstUsedGeneration(); - _store.trimHoldLists(used_gen); - _tree.getAllocator().trimHoldLists(used_gen); + auto used_gen = _generation_handler.get_oldest_used_generation(); + _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 3ba7bf85e42..caed5c3543c 100644 --- a/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp +++ b/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp @@ -59,8 +59,8 @@ public: AtomicEntryRef add_relaxed(uint32_t value) { return AtomicEntryRef(add(value)); } void hold(const AtomicEntryRef& ref) { _store.holdElem(ref.load_relaxed(), 1); } EntryRef move(EntryRef ref); - void transfer_hold_lists(generation_t gen) { _store.transferHoldLists(gen); } - void trim_hold_lists(generation_t gen) { _store.trimHoldLists(gen); } + void assign_generation(generation_t current_gen) { _store.assign_generation(current_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()); } @@ -118,8 +118,8 @@ public: static uint32_t add(uint32_t value) noexcept { return value; } static uint32_t add_relaxed(uint32_t value) noexcept { return value; } static void hold(uint32_t) noexcept { } - static void transfer_hold_lists(generation_t) noexcept { } - static void trim_hold_lists(generation_t) noexcept { } + static void assign_generation(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; } @@ -274,15 +274,15 @@ Fixture<Params>::commit() auto &allocator = _tree.getAllocator(); allocator.freeze(); auto current_gen = _generationHandler.getCurrentGeneration(); - allocator.transferHoldLists(current_gen); - _keys.transfer_hold_lists(current_gen); - _values.transfer_hold_lists(current_gen); - allocator.transferHoldLists(_generationHandler.getCurrentGeneration()); + allocator.assign_generation(current_gen); + _keys.assign_generation(current_gen); + _values.assign_generation(current_gen); + allocator.assign_generation(_generationHandler.getCurrentGeneration()); _generationHandler.incGeneration(); - auto first_used_gen = _generationHandler.getFirstUsedGeneration(); - 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 4da34c64ed9..0370b1ce2eb 100644 --- a/vespalib/src/tests/btree/btree_store/btree_store_test.cpp +++ b/vespalib/src/tests/btree/btree_store/btree_store_test.cpp @@ -31,9 +31,9 @@ protected: void inc_generation() { _store.freeze(); - _store.transferHoldLists(_gen_handler.getCurrentGeneration()); + _store.assign_generation(_gen_handler.getCurrentGeneration()); _gen_handler.incGeneration(); - _store.trimHoldLists(_gen_handler.getFirstUsedGeneration()); + _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 3fd00a26189..f2896cb783c 100644 --- a/vespalib/src/tests/btree/btree_test.cpp +++ b/vespalib/src/tests/btree/btree_test.cpp @@ -163,9 +163,9 @@ void cleanup(GenerationHandler & g, ManagerType & m) { m.freeze(); - m.transferHoldLists(g.getCurrentGeneration()); + m.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - m.trimHoldLists(g.getFirstUsedGeneration()); + m.reclaim_memory(g.get_oldest_used_generation()); } template <typename ManagerType, typename NodeType> @@ -874,9 +874,9 @@ TEST_F(BTreeTest, require_that_we_can_insert_and_remove_from_tree) } compacting_buffers->finish(); manager.freeze(); - manager.transferHoldLists(g.getCurrentGeneration()); + manager.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - manager.trimHoldLists(g.getFirstUsedGeneration()); + manager.reclaim_memory(g.get_oldest_used_generation()); } // remove entries for (size_t i = 0; i < numEntries; ++i) { @@ -1106,9 +1106,9 @@ TEST_F(BTreeTest, require_that_memory_usage_is_calculated) EXPECT_TRUE(assertMemoryUsage(mu, tm.getMemoryUsage())); // trim hold lists - tm.transferHoldLists(gh.getCurrentGeneration()); + tm.assign_generation(gh.getCurrentGeneration()); gh.incGeneration(); - tm.trimHoldLists(gh.getFirstUsedGeneration()); + tm.reclaim_memory(gh.get_oldest_used_generation()); mu = vespalib::MemoryUsage(); mu.incAllocatedBytes(adjustAllocatedBytes(initialInternalNodes, sizeof(INode))); mu.incAllocatedBytes(adjustAllocatedBytes(initialLeafNodes, sizeof(LNode))); @@ -1282,9 +1282,9 @@ TEST_F(BTreeTest, require_that_small_nodes_works) s.clear(root); s.clearBuilder(); s.freeze(); - s.transferHoldLists(g.getCurrentGeneration()); + s.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - s.trimHoldLists(g.getFirstUsedGeneration()); + s.reclaim_memory(g.get_oldest_used_generation()); } namespace { @@ -1416,9 +1416,9 @@ TEST_F(BTreeTest, require_that_apply_works) s.clear(root); s.clearBuilder(); s.freeze(); - s.transferHoldLists(g.getCurrentGeneration()); + s.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - s.trimHoldLists(g.getFirstUsedGeneration()); + s.reclaim_memory(g.get_oldest_used_generation()); } class MyTreeTestIterator : public MyTree::Iterator @@ -1553,9 +1553,9 @@ inc_generation(GenerationHandler &g, Tree &t) { auto &s = t.getAllocator(); s.freeze(); - s.transferHoldLists(g.getCurrentGeneration()); + s.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - s.trimHoldLists(g.getFirstUsedGeneration()); + 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 dff7de6660f..fb394df9861 100644 --- a/vespalib/src/tests/btree/btreeaggregation_test.cpp +++ b/vespalib/src/tests/btree/btreeaggregation_test.cpp @@ -272,9 +272,9 @@ void freezeTree(GenerationHandler &g, ManagerType &m) { m.freeze(); - m.transferHoldLists(g.getCurrentGeneration()); + m.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - m.trimHoldLists(g.getFirstUsedGeneration()); + m.reclaim_memory(g.get_oldest_used_generation()); } template <typename ManagerType> @@ -891,9 +891,9 @@ Test::requireThatWeCanInsertAndRemoveFromTree() } compacting_buffers->finish(); manager.freeze(); - manager.transferHoldLists(g.getCurrentGeneration()); + manager.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - manager.trimHoldLists(g.getFirstUsedGeneration()); + manager.reclaim_memory(g.get_oldest_used_generation()); } // remove entries for (size_t i = 0; i < numEntries; ++i) { @@ -1190,9 +1190,9 @@ Test::requireThatSmallNodesWorks() s.clear(root); s.clearBuilder(); s.freeze(); - s.transferHoldLists(g.getCurrentGeneration()); + s.assign_generation(g.getCurrentGeneration()); g.incGeneration(); - s.trimHoldLists(g.getFirstUsedGeneration()); + 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 01748b9edeb..0bde2786a0b 100644 --- a/vespalib/src/tests/btree/frozenbtree_test.cpp +++ b/vespalib/src/tests/btree/frozenbtree_test.cpp @@ -134,9 +134,9 @@ FrozenBTreeTest::freeTree(bool verbose) (void) verbose; _tree->clear(*_allocator); _allocator->freeze(); - _allocator->transferHoldLists(_generationHandler->getCurrentGeneration()); + _allocator->assign_generation(_generationHandler->getCurrentGeneration()); _generationHandler->incGeneration(); - _allocator->trimHoldLists(_generationHandler->getFirstUsedGeneration()); + _allocator->reclaim_memory(_generationHandler->get_oldest_used_generation()); delete _tree; _tree = NULL; delete _allocator; @@ -425,7 +425,7 @@ FrozenBTreeTest::Main() EXPECT_TRUE(_tree->getFrozenView(*_allocator).empty()); _allocator->freeze(); EXPECT_FALSE(_tree->getFrozenView(*_allocator).empty()); - _allocator->transferHoldLists(_generationHandler->getCurrentGeneration()); + _allocator->assign_generation(_generationHandler->getCurrentGeneration()); lookupFrozenRandomValues(*_tree, *_allocator, _randomValues); traverseTreeIterator(*_tree, *_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 1708b0fd948..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() { - store.transferHoldLists(generation++); - store.trimHoldLists(generation); + void reclaim_memory() { + store.assign_generation(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 1cb4f3e2307..10b96a87444 100644 --- a/vespalib/src/tests/datastore/datastore/datastore_test.cpp +++ b/vespalib/src/tests/datastore/datastore/datastore_test.cpp @@ -28,8 +28,8 @@ public: void holdElem(EntryRef ref, uint64_t len) { ParentType::holdElem(ref, len); } - void transferHoldLists(generation_t generation) { - ParentType::transferHoldLists(generation); + void assign_generation(generation_t current_gen) { + ParentType::assign_generation(current_gen); } void reclaim_entry_refs(generation_t oldest_used_gen) override { ParentType::reclaim_entry_refs(oldest_used_gen); @@ -261,29 +261,29 @@ TEST(DataStoreTest, require_that_we_can_hold_and_trim_buffers) s.switch_primary_buffer(); EXPECT_EQ(1u, s.primary_buffer_id()); s.holdBuffer(0); // hold last buffer - s.transferHoldLists(10); + s.assign_generation(10); EXPECT_EQ(1u, MyRef(s.addEntry(2)).bufferId()); s.switch_primary_buffer(); EXPECT_EQ(2u, s.primary_buffer_id()); s.holdBuffer(1); // hold last buffer - s.transferHoldLists(20); + s.assign_generation(20); EXPECT_EQ(2u, MyRef(s.addEntry(3)).bufferId()); s.switch_primary_buffer(); EXPECT_EQ(3u, s.primary_buffer_id()); s.holdBuffer(2); // hold last buffer - s.transferHoldLists(30); + s.assign_generation(30); EXPECT_EQ(3u, MyRef(s.addEntry(4)).bufferId()); s.holdBuffer(3); // hold current buffer - s.transferHoldLists(40); + s.assign_generation(40); EXPECT_TRUE(s.getBufferState(0).size() != 0); 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); @@ -304,13 +304,13 @@ TEST(DataStoreTest, require_that_we_can_hold_and_trim_elements) MyStore s; MyRef r1 = s.addEntry(1); s.holdElem(r1, 1); - s.transferHoldLists(10); + s.assign_generation(10); MyRef r2 = s.addEntry(2); s.holdElem(r2, 1); - s.transferHoldLists(20); + s.assign_generation(20); MyRef r3 = s.addEntry(3); s.holdElem(r3, 1); - s.transferHoldLists(30); + s.assign_generation(30); EXPECT_EQ(1, s.getEntry(r1)); EXPECT_EQ(2, s.getEntry(r2)); EXPECT_EQ(3, s.getEntry(r3)); @@ -358,11 +358,11 @@ TEST(DataStoreTest, require_that_we_can_use_free_lists) s.enableFreeLists(); auto r1 = s.addEntry(1); s.holdElem(r1, 1); - s.transferHoldLists(10); + s.assign_generation(10); auto r2 = s.addEntry(2); expect_successive_refs(r1, r2); s.holdElem(r2, 1); - s.transferHoldLists(20); + s.assign_generation(20); s.reclaim_entry_refs(11); auto r3 = s.addEntry(3); // reuse r1 EXPECT_EQ(r1, r3); @@ -393,7 +393,7 @@ TEST(DataStoreTest, require_that_we_can_use_free_lists_with_raw_allocator) expect_successive_handles(h1, h2); s.holdElem(h1.ref, 3); s.holdElem(h2.ref, 3); - s.transferHoldLists(10); + s.assign_generation(10); s.reclaim_entry_refs(11); auto h3 = allocator.alloc(3); // reuse h2.ref from free list @@ -429,7 +429,7 @@ TEST(DataStoreTest, require_that_memory_stats_are_calculated) s.addEntry(20); s.addEntry(30); s.holdBuffer(r.bufferId()); - s.transferHoldLists(100); + s.assign_generation(100); m._usedElems += 2; m._holdElems = m._usedElems; m._deadElems = 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; @@ -479,13 +479,13 @@ TEST(DataStoreTest, require_that_memory_usage_is_calculated) s.addEntry(30); s.addEntry(40); s.holdBuffer(r.bufferId()); - s.transferHoldLists(100); + s.assign_generation(100); vespalib::MemoryUsage m = s.getMemoryUsage(); EXPECT_EQ(MyRef::offsetSize() * sizeof(int), m.allocatedBytes()); 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) @@ -513,8 +513,8 @@ TEST(DataStoreTest, require_that_we_can_disable_elemement_hold_list) EXPECT_EQ(4 * sizeof(int), m.usedBytes()); EXPECT_EQ(2 * sizeof(int), m.deadBytes()); EXPECT_EQ(1 * sizeof(int), m.allocatedBytesOnHold()); - s.transferHoldLists(100); - s.trimHoldLists(101); + s.assign_generation(100); + s.reclaim_memory(101); } using IntGrowStore = GrowStore<int, EntryRefT<24>>; @@ -634,9 +634,9 @@ TEST(DataStoreTest, can_set_memory_allocator) s.switch_primary_buffer(); EXPECT_EQ(AllocStats(3, 0), stats); s.holdBuffer(0); - s.transferHoldLists(10); + 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); @@ -693,8 +693,8 @@ void test_free_element_to_held_buffer(bool direct, bool before_hold_buffer) ASSERT_DEATH({ s.holdElem(ref, 1); }, "isActive\\(\\)"); } } - s.transferHoldLists(100); - s.trimHoldLists(101); + s.assign_generation(100); + 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 ad10bc5c7e6..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 @@ -88,13 +88,13 @@ DataStoreFixedSizeHashTest::~DataStoreFixedSizeHashTest() void DataStoreFixedSizeHashTest::commit() { - _store.transferHoldLists(_generation_handler.getCurrentGeneration()); - _hash_map->transfer_hold_lists(_generation_handler.getCurrentGeneration()); + _store.assign_generation(_generation_handler.getCurrentGeneration()); + _hash_map->assign_generation(_generation_handler.getCurrentGeneration()); _generation_holder.assign_generation(_generation_handler.getCurrentGeneration()); _generation_handler.incGeneration(); - _store.trimHoldLists(_generation_handler.getFirstUsedGeneration()); - _hash_map->trim_hold_lists(_generation_handler.getFirstUsedGeneration()); - _generation_holder.reclaim(_generation_handler.getFirstUsedGeneration()); + _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()); } size_t 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 d6970e20e8a..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 @@ -168,11 +168,11 @@ DataStoreShardedHashTest::~DataStoreShardedHashTest() void DataStoreShardedHashTest::commit() { - _store.transferHoldLists(_generationHandler.getCurrentGeneration()); - _hash_map.transfer_hold_lists(_generationHandler.getCurrentGeneration()); + _store.assign_generation(_generationHandler.getCurrentGeneration()); + _hash_map.assign_generation(_generationHandler.getCurrentGeneration()); _generationHandler.incGeneration(); - _store.trimHoldLists(_generationHandler.getFirstUsedGeneration()); - _hash_map.trim_hold_lists(_generationHandler.getFirstUsedGeneration()); + _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 6612ef998c5..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.transferHoldLists(generation++); - store.trimHoldLists(generation); + store.assign_generation(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 d0fede5c550..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 @@ -62,9 +62,9 @@ struct UniqueStoreDictionaryTest : public ::testing::Test { } void inc_generation() { dict.freeze(); - dict.transfer_hold_lists(gen_handler.getCurrentGeneration()); + dict.assign_generation(gen_handler.getCurrentGeneration()); gen_handler.incGeneration(); - dict.trim_hold_lists(gen_handler.getFirstUsedGeneration()); + 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 0b34f587c6d..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() { - allocator.get_data_store().transferHoldLists(generation++); - allocator.get_data_store().trimHoldLists(generation); + void reclaim_memory() { + allocator.get_data_store().assign_generation(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/tests/util/generationhandler/generationhandler_test.cpp b/vespalib/src/tests/util/generationhandler/generationhandler_test.cpp index 00da752a749..0bc72f93a9d 100644 --- a/vespalib/src/tests/util/generationhandler/generationhandler_test.cpp +++ b/vespalib/src/tests/util/generationhandler/generationhandler_test.cpp @@ -26,10 +26,10 @@ GenerationHandlerTest::~GenerationHandlerTest() = default; TEST_F(GenerationHandlerTest, require_that_generation_can_be_increased) { EXPECT_EQ(0u, gh.getCurrentGeneration()); - EXPECT_EQ(0u, gh.getFirstUsedGeneration()); + EXPECT_EQ(0u, gh.get_oldest_used_generation()); gh.incGeneration(); EXPECT_EQ(1u, gh.getCurrentGeneration()); - EXPECT_EQ(1u, gh.getFirstUsedGeneration()); + EXPECT_EQ(1u, gh.get_oldest_used_generation()); } TEST_F(GenerationHandlerTest, require_that_readers_can_take_guards) @@ -87,34 +87,34 @@ TEST_F(GenerationHandlerTest, require_that_guards_can_be_copied) TEST_F(GenerationHandlerTest, require_that_the_first_used_generation_is_correct) { - EXPECT_EQ(0u, gh.getFirstUsedGeneration()); + EXPECT_EQ(0u, gh.get_oldest_used_generation()); gh.incGeneration(); - EXPECT_EQ(1u, gh.getFirstUsedGeneration()); + EXPECT_EQ(1u, gh.get_oldest_used_generation()); { GenGuard g1 = gh.takeGuard(); gh.incGeneration(); EXPECT_EQ(1u, gh.getGenerationRefCount()); - EXPECT_EQ(1u, gh.getFirstUsedGeneration()); + EXPECT_EQ(1u, gh.get_oldest_used_generation()); } - EXPECT_EQ(1u, gh.getFirstUsedGeneration()); - gh.updateFirstUsedGeneration(); // Only writer should call this + EXPECT_EQ(1u, gh.get_oldest_used_generation()); + gh.update_oldest_used_generation(); // Only writer should call this EXPECT_EQ(0u, gh.getGenerationRefCount()); - EXPECT_EQ(2u, gh.getFirstUsedGeneration()); + EXPECT_EQ(2u, gh.get_oldest_used_generation()); { GenGuard g1 = gh.takeGuard(); gh.incGeneration(); gh.incGeneration(); EXPECT_EQ(1u, gh.getGenerationRefCount()); - EXPECT_EQ(2u, gh.getFirstUsedGeneration()); + EXPECT_EQ(2u, gh.get_oldest_used_generation()); { GenGuard g2 = gh.takeGuard(); - EXPECT_EQ(2u, gh.getFirstUsedGeneration()); + EXPECT_EQ(2u, gh.get_oldest_used_generation()); } } - EXPECT_EQ(2u, gh.getFirstUsedGeneration()); - gh.updateFirstUsedGeneration(); // Only writer should call this + EXPECT_EQ(2u, gh.get_oldest_used_generation()); + gh.update_oldest_used_generation(); // Only writer should call this EXPECT_EQ(0u, gh.getGenerationRefCount()); - EXPECT_EQ(4u, gh.getFirstUsedGeneration()); + EXPECT_EQ(4u, gh.get_oldest_used_generation()); } TEST_F(GenerationHandlerTest, require_that_generation_can_grow_large) @@ -124,7 +124,7 @@ TEST_F(GenerationHandlerTest, require_that_generation_can_grow_large) EXPECT_EQ(i, gh.getCurrentGeneration()); guards.push_back(gh.takeGuard()); // take guard on current generation if (i >= 128) { - EXPECT_EQ(i - 128, gh.getFirstUsedGeneration()); + EXPECT_EQ(i - 128, gh.get_oldest_used_generation()); guards.pop_front(); EXPECT_EQ(128u, gh.getGenerationRefCount()); } diff --git a/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp b/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp index 74af25b54a8..fd2769fd8b1 100644 --- a/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp +++ b/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp @@ -238,7 +238,7 @@ Fixture::write_indirect_work(uint64_t cnt, IndirectContext& context) ReadStopper read_stopper(_stopRead); uint32_t sleep_cnt = 0; ASSERT_EQ(0, _generationHandler.getCurrentGeneration()); - auto oldest_gen = _generationHandler.getFirstUsedGeneration(); + auto oldest_gen = _generationHandler.get_oldest_used_generation(); for (uint64_t i = 0; i < cnt; ++i) { auto gen = _generationHandler.getCurrentGeneration(); // Hold data for gen, write new data for next_gen @@ -248,7 +248,7 @@ Fixture::write_indirect_work(uint64_t cnt, IndirectContext& context) *v_ptr = next_gen; context._value_ptr.store(v_ptr, std::memory_order_release); _generationHandler.incGeneration(); - auto first_used_gen = _generationHandler.getFirstUsedGeneration(); + auto first_used_gen = _generationHandler.get_oldest_used_generation(); while (oldest_gen < first_used_gen) { // Clear data that readers should no longer have access to. *context.calc_value_ptr(oldest_gen) = 0; @@ -258,8 +258,8 @@ Fixture::write_indirect_work(uint64_t cnt, IndirectContext& context) // Sleep if writer gets too much ahead of readers. std::this_thread::sleep_for(1ms); ++sleep_cnt; - _generationHandler.updateFirstUsedGeneration(); - first_used_gen = _generationHandler.getFirstUsedGeneration(); + _generationHandler.update_oldest_used_generation(); + first_used_gen = _generationHandler.get_oldest_used_generation(); } } _doneWriteWork += cnt; diff --git a/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp b/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp index c23065b7468..48fc88ec86d 100644 --- a/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp +++ b/vespalib/src/tests/util/rcuvector/rcuvector_test.cpp @@ -434,7 +434,7 @@ StressFixture::commit() auto current_gen = generation_handler.getCurrentGeneration(); g.assign_generation(current_gen); generation_handler.incGeneration(); - auto first_used_gen = generation_handler.getFirstUsedGeneration(); + auto first_used_gen = generation_handler.get_oldest_used_generation(); g.reclaim(first_used_gen); } diff --git a/vespalib/src/vespa/vespalib/btree/btree.hpp b/vespalib/src/vespa/vespalib/btree/btree.hpp index c6d8886254d..81687b6e62d 100644 --- a/vespalib/src/vespa/vespalib/btree/btree.hpp +++ b/vespalib/src/vespa/vespalib/btree/btree.hpp @@ -20,7 +20,7 @@ BTree<KeyT, DataT, AggrT, CompareT, TraitsT, AggrCalcT>::~BTree() { clear(); _alloc.freeze(); - _alloc.clearHoldLists(); + _alloc.reclaim_all_memory(); } template <typename KeyT, typename DataT, typename AggrT, typename CompareT, diff --git a/vespalib/src/vespa/vespalib/btree/btreenodeallocator.h b/vespalib/src/vespa/vespalib/btree/btreenodeallocator.h index c631ac4041a..77900edf848 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 @@ -109,9 +109,9 @@ public: * older versions of the frozen structure must leave before elements * can be unheld. */ - void transferHoldLists(generation_t generation); + void assign_generation(generation_t current_gen); - void clearHoldLists(); + void reclaim_all_memory(); static bool isValidRef(BTreeNode::Ref ref) { return NodeStore::isValidRef(ref); } diff --git a/vespalib/src/vespa/vespalib/btree/btreenodeallocator.hpp b/vespalib/src/vespa/vespalib/btree/btreenodeallocator.hpp index 8976d73379c..4968bbaf4a7 100644 --- a/vespalib/src/vespa/vespalib/btree/btreenodeallocator.hpp +++ b/vespalib/src/vespa/vespalib/btree/btreenodeallocator.hpp @@ -266,18 +266,18 @@ 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, size_t INTERNAL_SLOTS, size_t LEAF_SLOTS> void BTreeNodeAllocator<KeyT, DataT, AggrT, INTERNAL_SLOTS, LEAF_SLOTS>:: -transferHoldLists(generation_t generation) +assign_generation(generation_t current_gen) { - _nodeStore.transferHoldLists(generation); + _nodeStore.assign_generation(current_gen); } @@ -285,9 +285,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>:: -clearHoldLists() +reclaim_all_memory() { - _nodeStore.clearHoldLists(); + _nodeStore.reclaim_all_memory(); } diff --git a/vespalib/src/vespa/vespalib/btree/btreenodestore.h b/vespalib/src/vespa/vespalib/btree/btreenodestore.h index 20f80e07a6b..7b89e2d0ddb 100644 --- a/vespalib/src/vespa/vespalib/btree/btreenodestore.h +++ b/vespalib/src/vespa/vespalib/btree/btreenodestore.h @@ -162,8 +162,8 @@ public: std::unique_ptr<vespalib::datastore::CompactingBuffers> start_compact_worst(const CompactionStrategy& compaction_strategy); - void transferHoldLists(generation_t generation) { - _store.transferHoldLists(generation); + void assign_generation(generation_t current_gen) { + _store.assign_generation(current_gen); } // Inherit doc from DataStoreBase @@ -172,12 +172,12 @@ 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() { - _store.clearHoldLists(); + void reclaim_all_memory() { + _store.reclaim_all_memory(); } // Inherit doc from DataStoreBase diff --git a/vespalib/src/vespa/vespalib/btree/btreestore.h b/vespalib/src/vespa/vespalib/btree/btreestore.h index 54bc397175d..e5c55d5775d 100644 --- a/vespalib/src/vespa/vespalib/btree/btreestore.h +++ b/vespalib/src/vespa/vespalib/btree/btreestore.h @@ -332,25 +332,25 @@ 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 void - transferHoldLists(generation_t generation) + assign_generation(generation_t current_gen) { - _allocator.transferHoldLists(generation); - _store.transferHoldLists(generation); + _allocator.assign_generation(current_gen); + _store.assign_generation(current_gen); } void - clearHoldLists() + reclaim_all_memory() { - _allocator.clearHoldLists(); - _store.clearHoldLists(); + _allocator.reclaim_all_memory(); + _store.reclaim_all_memory(); } diff --git a/vespalib/src/vespa/vespalib/datastore/array_store.h b/vespalib/src/vespa/vespalib/datastore/array_store.h index db037ee12fb..e7662b9eb73 100644 --- a/vespalib/src/vespa/vespalib/datastore/array_store.h +++ b/vespalib/src/vespa/vespalib/datastore/array_store.h @@ -114,8 +114,8 @@ public: vespalib::AddressSpace addressSpaceUsage() const; // Pass on hold list management to underlying store - void transferHoldLists(generation_t generation) { _store.transferHoldLists(generation); } - void trimHoldLists(generation_t firstUsed) { _store.trimHoldLists(firstUsed); } + void assign_generation(generation_t current_gen) { _store.assign_generation(current_gen); } + 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/array_store.hpp b/vespalib/src/vespa/vespalib/datastore/array_store.hpp index 4df8505e927..b31d47fe4fe 100644 --- a/vespalib/src/vespa/vespalib/datastore/array_store.hpp +++ b/vespalib/src/vespa/vespalib/datastore/array_store.hpp @@ -57,7 +57,7 @@ ArrayStore<EntryT, RefT, TypeMapperT>::ArrayStore(const ArrayStoreConfig &cfg, s template <typename EntryT, typename RefT, typename TypeMapperT> ArrayStore<EntryT, RefT, TypeMapperT>::~ArrayStore() { - _store.clearHoldLists(); + _store.reclaim_all_memory(); _store.dropBuffers(); } diff --git a/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp b/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp index 4589fbba6fa..96160fd347b 100644 --- a/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp +++ b/vespalib/src/vespa/vespalib/datastore/datastorebase.cpp @@ -220,10 +220,10 @@ DataStoreBase::addType(BufferTypeBase *typeHandler) } void -DataStoreBase::transferHoldLists(generation_t generation) +DataStoreBase::assign_generation(generation_t current_gen) { - _genHolder.assign_generation(generation); - _entry_ref_hold_list.assign_generation(generation); + _genHolder.assign_generation(current_gen); + _entry_ref_hold_list.assign_generation(current_gen); } void @@ -235,14 +235,14 @@ 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 -DataStoreBase::clearHoldLists() +DataStoreBase::reclaim_all_memory() { _entry_ref_hold_list.assign_generation(0); reclaim_all_entry_refs(); diff --git a/vespalib/src/vespa/vespalib/datastore/datastorebase.h b/vespalib/src/vespa/vespalib/datastore/datastorebase.h index 520c13742b5..598f0872253 100644 --- a/vespalib/src/vespa/vespalib/datastore/datastorebase.h +++ b/vespalib/src/vespa/vespalib/datastore/datastorebase.h @@ -189,9 +189,9 @@ public: public: /** - * Transfer holds from hold1 to hold2 lists, assigning generation. + * Assign generation on data elements on hold lists added since the last time this function was called. */ - void transferHoldLists(generation_t generation); + void assign_generation(generation_t current_gen); private: /** @@ -201,13 +201,13 @@ 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(); + void reclaim_all_memory(); template <typename EntryType, typename RefType> EntryType *getEntry(RefType ref) { 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 402905d7aca..5338ce0c6b2 100644 --- a/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.cpp +++ b/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.cpp @@ -97,23 +97,22 @@ FixedSizeHashMap::add(const ShardedHashComparator & comp, std::function<EntryRef } void -FixedSizeHashMap::transfer_hold_lists_slow(generation_t generation) +FixedSizeHashMap::assign_generation_slow(generation_t current_gen) { auto &hold_2_list = _hold_2_list; for (uint32_t node_idx : _hold_1_list) { - hold_2_list.push_back(std::make_pair(generation, node_idx)); + hold_2_list.push_back(std::make_pair(current_gen, node_idx)); } _hold_1_list.clear(); - } 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 dd56b4951bc..de05ec1deb0 100644 --- a/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.h +++ b/vespalib/src/vespa/vespalib/datastore/fixed_size_hash_map.h @@ -56,8 +56,8 @@ private: * A reader must own an appropriate GenerationHandler::Guard to ensure * that memory is held while it can be accessed by reader. * - * The writer must update generation and call transfer_hold_lists and - * trim_hold_lists as needed to free up memory no longer needed by any + * The writer must update generation and call assign_generation and + * reclaim_memory as needed to free up memory no longer needed by any * readers. */ class FixedSizeHashMap { @@ -114,8 +114,8 @@ private: std::deque<std::pair<generation_t, uint32_t>> _hold_2_list; uint32_t _num_shards; - void transfer_hold_lists_slow(generation_t generation); - void trim_hold_lists_slow(generation_t first_used); + void assign_generation_slow(generation_t current_gen); + 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); @@ -143,15 +143,15 @@ public: return nullptr; } - void transfer_hold_lists(generation_t generation) { + void assign_generation(generation_t current_gen) { if (!_hold_1_list.empty()) { - transfer_hold_lists_slow(generation); + assign_generation_slow(current_gen); } } - 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 48abda45974..5a75a30d182 100644 --- a/vespalib/src/vespa/vespalib/datastore/i_unique_store_dictionary.h +++ b/vespalib/src/vespa/vespalib/datastore/i_unique_store_dictionary.h @@ -25,8 +25,8 @@ public: using generation_t = vespalib::GenerationHandler::generation_t; virtual ~IUniqueStoreDictionary() = default; virtual void freeze() = 0; - virtual void transfer_hold_lists(generation_t generation) = 0; - virtual void trim_hold_lists(generation_t firstUsed) = 0; + virtual void assign_generation(generation_t current_gen) = 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 86578f663a1..a28c3071646 100644 --- a/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.cpp +++ b/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.cpp @@ -107,27 +107,27 @@ ShardedHashMap::find(const EntryComparator& comp, EntryRef key_ref) const } void -ShardedHashMap::transfer_hold_lists(generation_t generation) +ShardedHashMap::assign_generation(generation_t current_gen) { for (size_t i = 0; i < num_shards; ++i) { auto map = _maps[i].load(std::memory_order_relaxed); if (map != nullptr) { - map->transfer_hold_lists(generation); + map->assign_generation(current_gen); } } - _gen_holder.assign_generation(generation); + _gen_holder.assign_generation(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 80d14d187b0..572a8790828 100644 --- a/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.h +++ b/vespalib/src/vespa/vespalib/datastore/sharded_hash_map.h @@ -28,8 +28,8 @@ struct ICompactable; * A reader must own an appropriate GenerationHandler::Guard to ensure * that memory is held while it can be accessed by reader. * - * The writer must update generation and call transfer_hold_lists and - * trim_hold_lists as needed to free up memory no longer needed by any + * The writer must update generation and call assign_generation and + * reclaim_memory as needed to free up memory no longer needed by any * readers. */ class ShardedHashMap { @@ -52,8 +52,8 @@ public: KvType* remove(const EntryComparator& comp, EntryRef key_ref); KvType* find(const EntryComparator& comp, EntryRef key_ref); const KvType* find(const EntryComparator& comp, EntryRef key_ref) const; - void transfer_hold_lists(generation_t generation); - void trim_hold_lists(generation_t first_used); + void assign_generation(generation_t current_gen); + 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 e7c374985a7..1313d57fbab 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store.h +++ b/vespalib/src/vespa/vespalib/datastore/unique_store.h @@ -70,8 +70,8 @@ public: inline const DataStoreType& get_data_store() const noexcept { return _allocator.get_data_store(); } // Pass on hold list management to underlying store - void transferHoldLists(generation_t generation); - void trimHoldLists(generation_t firstUsed); + void assign_generation(generation_t current_gen); + 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 63592f82898..b8493017020 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store.hpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store.hpp @@ -190,18 +190,18 @@ UniqueStore<EntryT, RefT, Compare, Allocator>::bufferState(EntryRef ref) const template <typename EntryT, typename RefT, typename Compare, typename Allocator> void -UniqueStore<EntryT, RefT, Compare, Allocator>::transferHoldLists(generation_t generation) +UniqueStore<EntryT, RefT, Compare, Allocator>::assign_generation(generation_t current_gen) { - _dict->transfer_hold_lists(generation); - _store.transferHoldLists(generation); + _dict->assign_generation(current_gen); + _store.assign_generation(current_gen); } 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_allocator.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store_allocator.hpp index 5d96b1e0314..8ad11b18218 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store_allocator.hpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_allocator.hpp @@ -28,7 +28,7 @@ UniqueStoreAllocator<EntryT, RefT>::UniqueStoreAllocator(std::shared_ptr<alloc:: template <typename EntryT, typename RefT> UniqueStoreAllocator<EntryT, RefT>::~UniqueStoreAllocator() { - _store.clearHoldLists(); + _store.reclaim_all_memory(); _store.dropBuffers(); } diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.h b/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.h index 7aed81c3a79..8c5f284bb14 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.h +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.h @@ -74,8 +74,8 @@ public: UniqueStoreDictionary(std::unique_ptr<EntryComparator> compare); ~UniqueStoreDictionary() override; void freeze() override; - void transfer_hold_lists(generation_t generation) override; - void trim_hold_lists(generation_t firstUsed) override; + void assign_generation(generation_t current_gen) 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 29c4b6514d7..6708b4c1448 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp @@ -41,25 +41,25 @@ UniqueStoreDictionary<BTreeDictionaryT, ParentT, HashDictionaryT>::freeze() template <typename BTreeDictionaryT, typename ParentT, typename HashDictionaryT> void -UniqueStoreDictionary<BTreeDictionaryT, ParentT, HashDictionaryT>::transfer_hold_lists(generation_t generation) +UniqueStoreDictionary<BTreeDictionaryT, ParentT, HashDictionaryT>::assign_generation(generation_t current_gen) { if constexpr (has_btree_dictionary) { - this->_btree_dict.getAllocator().transferHoldLists(generation); + this->_btree_dict.getAllocator().assign_generation(current_gen); } if constexpr (has_hash_dictionary) { - this->_hash_dict.transfer_hold_lists(generation); + this->_hash_dict.assign_generation(current_gen); } } 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); } } diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_string_allocator.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store_string_allocator.hpp index eeba2f463b9..65cab4850ba 100644 --- a/vespalib/src/vespa/vespalib/datastore/unique_store_string_allocator.hpp +++ b/vespalib/src/vespa/vespalib/datastore/unique_store_string_allocator.hpp @@ -30,7 +30,7 @@ UniqueStoreStringAllocator<RefT>::UniqueStoreStringAllocator(std::shared_ptr<all template <typename RefT> UniqueStoreStringAllocator<RefT>::~UniqueStoreStringAllocator() { - _store.clearHoldLists(); + _store.reclaim_all_memory(); _store.dropBuffers(); } diff --git a/vespalib/src/vespa/vespalib/util/generationhandler.cpp b/vespalib/src/vespa/vespalib/util/generationhandler.cpp index d1cc0271068..3562926d88d 100644 --- a/vespalib/src/vespa/vespalib/util/generationhandler.cpp +++ b/vespalib/src/vespa/vespalib/util/generationhandler.cpp @@ -111,7 +111,7 @@ GenerationHandler::Guard::operator=(Guard &&rhs) } void -GenerationHandler::updateFirstUsedGeneration() +GenerationHandler::update_oldest_used_generation() { for (;;) { if (_first == _last.load(std::memory_order_relaxed)) @@ -125,12 +125,12 @@ GenerationHandler::updateFirstUsedGeneration() toFree->_next = _free; _free = toFree; } - _firstUsedGeneration.store(_first->_generation, std::memory_order_relaxed); + _oldest_used_generation.store(_first->_generation, std::memory_order_relaxed); } GenerationHandler::GenerationHandler() : _generation(0), - _firstUsedGeneration(0), + _oldest_used_generation(0), _last(nullptr), _first(nullptr), _free(nullptr), @@ -144,7 +144,7 @@ GenerationHandler::GenerationHandler() GenerationHandler::~GenerationHandler(void) { - updateFirstUsedGeneration(); + update_oldest_used_generation(); assert(_first == _last.load(std::memory_order_relaxed)); while (_free != nullptr) { GenerationHold *toFree = _free; @@ -190,7 +190,7 @@ GenerationHandler::incGeneration() // reader set_generation(ngen); last->_generation.store(ngen, std::memory_order_relaxed); - updateFirstUsedGeneration(); + update_oldest_used_generation(); return; } GenerationHold *nhold = nullptr; @@ -207,7 +207,7 @@ GenerationHandler::incGeneration() last->_next = nhold; set_generation(ngen); _last.store(nhold, std::memory_order_release); - updateFirstUsedGeneration(); + update_oldest_used_generation(); } uint32_t @@ -215,7 +215,7 @@ GenerationHandler::getGenerationRefCount(generation_t gen) const { if (static_cast<sgeneration_t>(gen - getCurrentGeneration()) > 0) return 0u; - if (static_cast<sgeneration_t>(getFirstUsedGeneration() - gen) > 0) + if (static_cast<sgeneration_t>(get_oldest_used_generation() - gen) > 0) return 0u; for (GenerationHold *hold = _first; hold != nullptr; hold = hold->_next) { if (hold->_generation.load(std::memory_order_relaxed) == gen) diff --git a/vespalib/src/vespa/vespalib/util/generationhandler.h b/vespalib/src/vespa/vespalib/util/generationhandler.h index 9637ad0e414..6ba71b7f5fb 100644 --- a/vespalib/src/vespa/vespalib/util/generationhandler.h +++ b/vespalib/src/vespa/vespalib/util/generationhandler.h @@ -73,7 +73,7 @@ public: private: std::atomic<generation_t> _generation; - std::atomic<generation_t> _firstUsedGeneration; + std::atomic<generation_t> _oldest_used_generation; std::atomic<GenerationHold *> _last; // Points to "current generation" entry GenerationHold *_first; // Points to "firstUsedGeneration" entry GenerationHold *_free; // List of free entries @@ -101,17 +101,17 @@ public: void incGeneration(); /** - * Update first used generation. + * Update the oldest used generation. * Should be called by the writer thread. */ - void updateFirstUsedGeneration(); + void update_oldest_used_generation(); /** - * Returns the first generation guarded by a reader. It might be too low - * if writer hasn't updated first used generation after last reader left. + * Returns the oldest generation guarded by a reader. + * It might be too low if writer hasn't updated oldest used generation after last reader left. */ - generation_t getFirstUsedGeneration() const noexcept { - return _firstUsedGeneration.load(std::memory_order_relaxed); + generation_t get_oldest_used_generation() const noexcept { + return _oldest_used_generation.load(std::memory_order_relaxed); } /** |