diff options
author | Geir Storli <geirst@yahooinc.com> | 2022-10-11 13:45:49 +0000 |
---|---|---|
committer | Geir Storli <geirst@yahooinc.com> | 2022-10-12 13:36:56 +0000 |
commit | a8d556bec71a3e207625420a74ad7109ab60100f (patch) | |
tree | 8ea283bc94e94ecaff55f7ab6139d6e4579dca16 | |
parent | f329a9d5e0a323b0485dcae52d90987b675808bc (diff) |
Rename first used generation -> oldest used generation.
30 files changed, 111 insertions, 113 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/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/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..0635b86121a 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 @@ -145,8 +145,8 @@ DocumentWeightOrFilterSearchTest::inc_generation() _postings.freeze(); _postings.transferHoldLists(_gens.getCurrentGeneration()); _gens.incGeneration(); - _gens.updateFirstUsedGeneration(); - _postings.trimHoldLists(_gens.getFirstUsedGeneration()); + _gens.update_oldest_used_generation(); + _postings.trimHoldLists(_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..b957c31c7dc 100644 --- a/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp +++ b/searchlib/src/tests/attribute/enum_comparator/enum_comparator_test.cpp @@ -149,7 +149,7 @@ TEST("requireThatComparatorWithTreeIsWorking") m.freeze(); m.transferHoldLists(g.getCurrentGeneration()); g.incGeneration(); - m.trimHoldLists(g.getFirstUsedGeneration()); + m.trimHoldLists(g.get_oldest_used_generation()); } TEST("requireThatFoldedLessIsWorking") 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/posting_store/posting_store_test.cpp b/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp index 36babec6a89..a2d04488003 100644 --- a/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp +++ b/searchlib/src/tests/attribute/posting_store/posting_store_test.cpp @@ -67,8 +67,8 @@ protected: _value_store.transfer_hold_lists(_gen_handler.getCurrentGeneration()); _store.transferHoldLists(_gen_handler.getCurrentGeneration()); _gen_handler.incGeneration(); - _value_store.trim_hold_lists(_gen_handler.getFirstUsedGeneration()); - _store.trimHoldLists(_gen_handler.getFirstUsedGeneration()); + _value_store.trim_hold_lists(_gen_handler.get_oldest_used_generation()); + _store.trimHoldLists(_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..9e3ea72045f 100644 --- a/searchlib/src/tests/attribute/postinglist/postinglist.cpp +++ b/searchlib/src/tests/attribute/postinglist/postinglist.cpp @@ -263,8 +263,8 @@ AttributePostingListTest::freeTree(bool verbose) _intPostings->clearBuilder(); _intPostings->transferHoldLists(_handler.getCurrentGeneration()); _handler.incGeneration(); - _intNodeAlloc->trimHoldLists(_handler.getFirstUsedGeneration()); - _intPostings->trimHoldLists(_handler.getFirstUsedGeneration()); + _intNodeAlloc->trimHoldLists(_handler.get_oldest_used_generation()); + _intPostings->trimHoldLists(_handler.get_oldest_used_generation()); LOG(info, "freeTree after unhold: %" PRIu64 " (%" PRIu64 " held)", static_cast<uint64_t>(_intNodeAlloc->getMemoryUsage().allocatedBytes()), @@ -615,7 +615,7 @@ AttributePostingListTest::doCompactEnumStore(Tree &tree, generation_t generation = _handler.getCurrentGeneration(); valueHandle.transferHoldLists(generation); _handler.incGeneration(); - valueHandle.trimHoldLists(_handler.getFirstUsedGeneration()); + valueHandle.trimHoldLists(_handler.get_oldest_used_generation()); LOG(info, "doCompactEnumStore done"); @@ -672,8 +672,8 @@ removeOldGenerations(Tree &tree, { (void) tree; (void) valueHandle; - postingsAlloc.trimHoldLists(_handler.getFirstUsedGeneration()); - postings.trimHoldLists(_handler.getFirstUsedGeneration()); + postingsAlloc.trimHoldLists(_handler.get_oldest_used_generation()); + postings.trimHoldLists(_handler.get_oldest_used_generation()); } int 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..1ebef22bab7 100644 --- a/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp +++ b/searchlib/src/tests/tensor/hnsw_index/hnsw_index_test.cpp @@ -101,8 +101,8 @@ public: void commit() { index->transfer_hold_lists(gen_handler.getCurrentGeneration()); gen_handler.incGeneration(); - gen_handler.updateFirstUsedGeneration(); - index->trim_hold_lists(gen_handler.getFirstUsedGeneration()); + gen_handler.update_oldest_used_generation(); + index->trim_hold_lists(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..69a454e92cb 100644 --- a/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp +++ b/searchlib/src/tests/tensor/hnsw_index/stress_hnsw_mt.cpp @@ -269,8 +269,8 @@ public: void commit(uint32_t docid) { index->transfer_hold_lists(gen_handler.getCurrentGeneration()); gen_handler.incGeneration(); - gen_handler.updateFirstUsedGeneration(); - index->trim_hold_lists(gen_handler.getFirstUsedGeneration()); + gen_handler.update_oldest_used_generation(); + index->trim_hold_lists(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/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/field_index.h b/searchlib/src/vespa/searchlib/memoryindex/field_index.h index fb02ed880b4..bd087c8eae1 100644 --- a/searchlib/src/vespa/searchlib/memoryindex/field_index.h +++ b/searchlib/src/vespa/searchlib/memoryindex/field_index.h @@ -54,7 +54,7 @@ private: void trimHoldLists() { GenerationHandler::generation_t usedGen = - _generationHandler.getFirstUsedGeneration(); + _generationHandler.get_oldest_used_generation(); _postingListStore.trimHoldLists(usedGen); _dict.getAllocator().trimHoldLists(usedGen); _featureStore.trimHoldLists(usedGen); diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp index 6e86d70fe52..e13d746df49 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakememtreeocc.cpp @@ -184,7 +184,7 @@ FakeMemTreeOccMgr::incGeneration() void FakeMemTreeOccMgr::trimHoldLists() { - _allocator.trimHoldLists(_generationHandler.getFirstUsedGeneration()); + _allocator.trimHoldLists(_generationHandler.get_oldest_used_generation()); } 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..f3a16f5826e 100644 --- a/storage/src/vespa/storage/bucketdb/generic_btree_bucket_database.hpp +++ b/storage/src/vespa/storage/bucketdb/generic_btree_bucket_database.hpp @@ -43,7 +43,7 @@ void GenericBTreeBucketDatabase<DataStoreTraitsT>::commit_tree_changes() { _generation_handler.incGeneration(); - auto used_gen = _generation_handler.getFirstUsedGeneration(); + auto used_gen = _generation_handler.get_oldest_used_generation(); _store.trimHoldLists(used_gen); _tree.getAllocator().trimHoldLists(used_gen); } 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..2c9455701f7 100644 --- a/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp +++ b/vespalib/src/tests/btree/btree-stress/btree_stress_test.cpp @@ -279,7 +279,7 @@ Fixture<Params>::commit() _values.transfer_hold_lists(current_gen); allocator.transferHoldLists(_generationHandler.getCurrentGeneration()); _generationHandler.incGeneration(); - auto first_used_gen = _generationHandler.getFirstUsedGeneration(); + auto first_used_gen = _generationHandler.get_oldest_used_generation(); allocator.trimHoldLists(first_used_gen); _keys.trim_hold_lists(first_used_gen); _values.trim_hold_lists(first_used_gen); 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..5196d08aa1b 100644 --- a/vespalib/src/tests/btree/btree_store/btree_store_test.cpp +++ b/vespalib/src/tests/btree/btree_store/btree_store_test.cpp @@ -33,7 +33,7 @@ protected: _store.freeze(); _store.transferHoldLists(_gen_handler.getCurrentGeneration()); _gen_handler.incGeneration(); - _store.trimHoldLists(_gen_handler.getFirstUsedGeneration()); + _store.trimHoldLists(_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..8aeef40c957 100644 --- a/vespalib/src/tests/btree/btree_test.cpp +++ b/vespalib/src/tests/btree/btree_test.cpp @@ -165,7 +165,7 @@ cleanup(GenerationHandler & g, ManagerType & m) m.freeze(); m.transferHoldLists(g.getCurrentGeneration()); g.incGeneration(); - m.trimHoldLists(g.getFirstUsedGeneration()); + m.trimHoldLists(g.get_oldest_used_generation()); } template <typename ManagerType, typename NodeType> @@ -876,7 +876,7 @@ TEST_F(BTreeTest, require_that_we_can_insert_and_remove_from_tree) manager.freeze(); manager.transferHoldLists(g.getCurrentGeneration()); g.incGeneration(); - manager.trimHoldLists(g.getFirstUsedGeneration()); + manager.trimHoldLists(g.get_oldest_used_generation()); } // remove entries for (size_t i = 0; i < numEntries; ++i) { @@ -1108,7 +1108,7 @@ TEST_F(BTreeTest, require_that_memory_usage_is_calculated) // trim hold lists tm.transferHoldLists(gh.getCurrentGeneration()); gh.incGeneration(); - tm.trimHoldLists(gh.getFirstUsedGeneration()); + tm.trimHoldLists(gh.get_oldest_used_generation()); mu = vespalib::MemoryUsage(); mu.incAllocatedBytes(adjustAllocatedBytes(initialInternalNodes, sizeof(INode))); mu.incAllocatedBytes(adjustAllocatedBytes(initialLeafNodes, sizeof(LNode))); @@ -1284,7 +1284,7 @@ TEST_F(BTreeTest, require_that_small_nodes_works) s.freeze(); s.transferHoldLists(g.getCurrentGeneration()); g.incGeneration(); - s.trimHoldLists(g.getFirstUsedGeneration()); + s.trimHoldLists(g.get_oldest_used_generation()); } namespace { @@ -1418,7 +1418,7 @@ TEST_F(BTreeTest, require_that_apply_works) s.freeze(); s.transferHoldLists(g.getCurrentGeneration()); g.incGeneration(); - s.trimHoldLists(g.getFirstUsedGeneration()); + s.trimHoldLists(g.get_oldest_used_generation()); } class MyTreeTestIterator : public MyTree::Iterator @@ -1555,7 +1555,7 @@ inc_generation(GenerationHandler &g, Tree &t) s.freeze(); s.transferHoldLists(g.getCurrentGeneration()); g.incGeneration(); - s.trimHoldLists(g.getFirstUsedGeneration()); + s.trimHoldLists(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..fbe8e4c8424 100644 --- a/vespalib/src/tests/btree/btreeaggregation_test.cpp +++ b/vespalib/src/tests/btree/btreeaggregation_test.cpp @@ -274,7 +274,7 @@ freezeTree(GenerationHandler &g, ManagerType &m) m.freeze(); m.transferHoldLists(g.getCurrentGeneration()); g.incGeneration(); - m.trimHoldLists(g.getFirstUsedGeneration()); + m.trimHoldLists(g.get_oldest_used_generation()); } template <typename ManagerType> @@ -893,7 +893,7 @@ Test::requireThatWeCanInsertAndRemoveFromTree() manager.freeze(); manager.transferHoldLists(g.getCurrentGeneration()); g.incGeneration(); - manager.trimHoldLists(g.getFirstUsedGeneration()); + manager.trimHoldLists(g.get_oldest_used_generation()); } // remove entries for (size_t i = 0; i < numEntries; ++i) { @@ -1192,7 +1192,7 @@ Test::requireThatSmallNodesWorks() s.freeze(); s.transferHoldLists(g.getCurrentGeneration()); g.incGeneration(); - s.trimHoldLists(g.getFirstUsedGeneration()); + s.trimHoldLists(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..e031b759f62 100644 --- a/vespalib/src/tests/btree/frozenbtree_test.cpp +++ b/vespalib/src/tests/btree/frozenbtree_test.cpp @@ -136,7 +136,7 @@ FrozenBTreeTest::freeTree(bool verbose) _allocator->freeze(); _allocator->transferHoldLists(_generationHandler->getCurrentGeneration()); _generationHandler->incGeneration(); - _allocator->trimHoldLists(_generationHandler->getFirstUsedGeneration()); + _allocator->trimHoldLists(_generationHandler->get_oldest_used_generation()); delete _tree; _tree = NULL; delete _allocator; 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..6abfaced867 100644 --- a/vespalib/src/tests/datastore/fixed_size_hash_map/fixed_size_hash_map_test.cpp +++ b/vespalib/src/tests/datastore/fixed_size_hash_map/fixed_size_hash_map_test.cpp @@ -92,9 +92,9 @@ DataStoreFixedSizeHashTest::commit() _hash_map->transfer_hold_lists(_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.trimHoldLists(_generation_handler.get_oldest_used_generation()); + _hash_map->trim_hold_lists(_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..67357d780bc 100644 --- a/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp +++ b/vespalib/src/tests/datastore/sharded_hash_map/sharded_hash_map_test.cpp @@ -171,8 +171,8 @@ DataStoreShardedHashTest::commit() _store.transferHoldLists(_generationHandler.getCurrentGeneration()); _hash_map.transfer_hold_lists(_generationHandler.getCurrentGeneration()); _generationHandler.incGeneration(); - _store.trimHoldLists(_generationHandler.getFirstUsedGeneration()); - _hash_map.trim_hold_lists(_generationHandler.getFirstUsedGeneration()); + _store.trimHoldLists(_generationHandler.get_oldest_used_generation()); + _hash_map.trim_hold_lists(_generationHandler.get_oldest_used_generation()); } void 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..5948303c335 100644 --- a/vespalib/src/tests/datastore/unique_store_dictionary/unique_store_dictionary_test.cpp +++ b/vespalib/src/tests/datastore/unique_store_dictionary/unique_store_dictionary_test.cpp @@ -64,7 +64,7 @@ struct UniqueStoreDictionaryTest : public ::testing::Test { dict.freeze(); dict.transfer_hold_lists(gen_handler.getCurrentGeneration()); gen_handler.incGeneration(); - dict.trim_hold_lists(gen_handler.getFirstUsedGeneration()); + dict.trim_hold_lists(gen_handler.get_oldest_used_generation()); } void take_snapshot() { dict.freeze(); 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/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); } /** |