diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-02-27 16:43:55 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2020-02-27 16:49:17 +0000 |
commit | 752ced912014457c04d2c3670fd7d8b9eda49fa7 (patch) | |
tree | 404a21f60b4df37a1d4e718096eed971bf7522bc /searchcore | |
parent | dda41637e506d6f0fdf88f875350adab2743bd1d (diff) |
Add getStats and setTaskLimit to interface to make it easy to swap implementation.
Also make do with ISequenceHandlerInterface.
Diffstat (limited to 'searchcore')
16 files changed, 122 insertions, 120 deletions
diff --git a/searchcore/src/tests/proton/attribute/exclusive_attribute_read_accessor/exclusive_attribute_read_accessor_test.cpp b/searchcore/src/tests/proton/attribute/exclusive_attribute_read_accessor/exclusive_attribute_read_accessor_test.cpp index 420e18db5af..d2eba28bc9b 100644 --- a/searchcore/src/tests/proton/attribute/exclusive_attribute_read_accessor/exclusive_attribute_read_accessor_test.cpp +++ b/searchcore/src/tests/proton/attribute/exclusive_attribute_read_accessor/exclusive_attribute_read_accessor_test.cpp @@ -24,13 +24,13 @@ createAttribute() struct Fixture { AttributeVector::SP attribute; - SequencedTaskExecutor writer; + std::unique_ptr<ISequencedTaskExecutor> writer; ExclusiveAttributeReadAccessor accessor; Fixture() : attribute(createAttribute()), - writer(1), - accessor(attribute, writer) + writer(SequencedTaskExecutor::create(1)), + accessor(attribute, *writer) {} }; @@ -38,7 +38,7 @@ TEST_F("require that attribute write thread is blocked while guard is held", Fix { ReadGuard::UP guard = f.accessor.takeGuard(); Gate gate; - f.writer.execute(f.writer.getExecutorId(f.attribute->getNamePrefix()), [&gate]() { gate.countDown(); }); + f.writer->execute(f.writer->getExecutorId(f.attribute->getNamePrefix()), [&gate]() { gate.countDown(); }); bool reachedZero = gate.await(100); EXPECT_FALSE(reachedZero); EXPECT_EQUAL(1u, gate.getCount()); diff --git a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp index f380ce03152..6a6b05be7f0 100644 --- a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp @@ -692,15 +692,15 @@ struct FixtureBase FixtureBase::FixtureBase(vespalib::duration visibilityDelay) : _tracer(), sc(), - iw(new MyIndexWriter(_tracer)), - sa(new MySummaryAdapter(*sc._builder->getDocumentTypeRepo())), - aw(new MyAttributeWriter(_tracer)), + iw(std::make_shared<MyIndexWriter>(_tracer)), + sa(std::make_shared<MySummaryAdapter>(*sc._builder->getDocumentTypeRepo())), + aw(std::make_shared<MyAttributeWriter>(_tracer)), miw(static_cast<MyIndexWriter&>(*iw)), msa(static_cast<MySummaryAdapter&>(*sa)), maw(static_cast<MyAttributeWriter&>(*aw)), _docIdLimit(0u), - _dmscReal(new DocumentMetaStoreContext(std::make_shared<BucketDBOwner>())), - _dmsc(new test::DocumentMetaStoreContextObserver(*_dmscReal)), + _dmscReal(std::make_shared<DocumentMetaStoreContext>(std::make_shared<BucketDBOwner>())), + _dmsc(std::make_shared<test::DocumentMetaStoreContextObserver>(*_dmscReal)), pc(sc._builder->getDocumentType().getName(), "fileconfig_test"), _sharedExecutor(1, 0x10000), _writeServiceReal(_sharedExecutor), diff --git a/searchcore/src/tests/proton/documentmetastore/lidreusedelayer/CMakeLists.txt b/searchcore/src/tests/proton/documentmetastore/lidreusedelayer/CMakeLists.txt index 0d226268d1a..49f929e0127 100644 --- a/searchcore/src/tests/proton/documentmetastore/lidreusedelayer/CMakeLists.txt +++ b/searchcore/src/tests/proton/documentmetastore/lidreusedelayer/CMakeLists.txt @@ -5,5 +5,6 @@ vespa_add_executable(searchcore_lidreusedelayer_test_app TEST DEPENDS searchcore_server searchcore_documentmetastore + searchcore_test ) vespa_add_test(NAME searchcore_lidreusedelayer_test_app COMMAND searchcore_lidreusedelayer_test_app) diff --git a/searchcore/src/tests/proton/documentmetastore/lidreusedelayer/lidreusedelayer_test.cpp b/searchcore/src/tests/proton/documentmetastore/lidreusedelayer/lidreusedelayer_test.cpp index d305751f7c2..25668f56753 100644 --- a/searchcore/src/tests/proton/documentmetastore/lidreusedelayer/lidreusedelayer_test.cpp +++ b/searchcore/src/tests/proton/documentmetastore/lidreusedelayer/lidreusedelayer_test.cpp @@ -1,6 +1,5 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/log/log.h> -LOG_SETUP("lidreusedelayer_test"); + #include <vespa/vespalib/testkit/testapp.h> #include <vespa/searchcore/proton/documentmetastore/i_store.h> #include <vespa/searchcore/proton/documentmetastore/lidreusedelayer.h> @@ -9,12 +8,14 @@ LOG_SETUP("lidreusedelayer_test"); #include <vespa/searchcore/proton/test/threading_service_observer.h> #include <vespa/vespalib/util/lambdatask.h> +#include <vespa/log/log.h> +LOG_SETUP("lidreusedelayer_test"); + using vespalib::makeLambdaTask; namespace proton { -namespace -{ +namespace { bool assertThreadObserver(uint32_t masterExecuteCnt, @@ -55,69 +56,52 @@ public: { } - virtual ~MyMetaStore() { } + ~MyMetaStore() override = default; - virtual Result inspectExisting(const GlobalId &) const override - { + Result inspectExisting(const GlobalId &) const override { return Result(); } - virtual Result inspect(const GlobalId &) override - { + Result inspect(const GlobalId &) override { return Result(); } - virtual Result put(const GlobalId &, const BucketId &, const Timestamp &, - uint32_t, DocId) override - { + Result put(const GlobalId &, const BucketId &, const Timestamp &, uint32_t, DocId) override { return Result(); } - virtual bool updateMetaData(DocId, const BucketId &, - const Timestamp &) override - { + bool updateMetaData(DocId, const BucketId &, const Timestamp &) override { return true; } - virtual bool remove(DocId) override - { + bool remove(DocId) override { return true; } - virtual void removeComplete(DocId) override - { + void removeComplete(DocId) override { ++_removeCompleteCount; ++_removeCompleteLids; } - virtual void move(DocId, DocId) override - { + void move(DocId, DocId) override { } - virtual bool validLid(DocId) const override - { + bool validLid(DocId) const override { return true; } - virtual void removeBatch(const std::vector<DocId> &, - const DocId) override - { - } + void removeBatch(const std::vector<DocId> &, const DocId) override {} - virtual void - removeBatchComplete(const std::vector<DocId> &lidsToRemove) override - { + void removeBatchComplete(const std::vector<DocId> &lidsToRemove) override{ ++_removeBatchCompleteCount; _removeCompleteLids += lidsToRemove.size(); } - virtual const RawDocumentMetaData &getRawMetaData(DocId) const override - { + const RawDocumentMetaData &getRawMetaData(DocId) const override { LOG_ABORT("should not be reached"); } - virtual bool getFreeListActive() const override - { + bool getFreeListActive() const override { return _freeListActive; } diff --git a/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp b/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp index ca45108b698..991cb2e519d 100644 --- a/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp +++ b/searchcore/src/tests/proton/feed_and_search/feed_and_search.cpp @@ -149,9 +149,9 @@ void Test::testSearch(Searchable &source, void Test::requireThatMemoryIndexCanBeDumpedAndSearched() { Schema schema = getSchema(); vespalib::ThreadStackExecutor sharedExecutor(2, 0x10000); - search::SequencedTaskExecutor indexFieldInverter(2); - search::SequencedTaskExecutor indexFieldWriter(2); - MemoryIndex memory_index(schema, MockFieldLengthInspector(), indexFieldInverter, indexFieldWriter); + auto indexFieldInverter = search::SequencedTaskExecutor::create(2); + auto indexFieldWriter = search::SequencedTaskExecutor::create(2); + MemoryIndex memory_index(schema, MockFieldLengthInspector(), *indexFieldInverter, *indexFieldWriter); DocBuilder doc_builder(schema); Document::UP doc = buildDocument(doc_builder, doc_id1, word1); @@ -160,7 +160,7 @@ void Test::requireThatMemoryIndexCanBeDumpedAndSearched() { doc = buildDocument(doc_builder, doc_id2, word2); memory_index.insertDocument(doc_id2, *doc.get()); memory_index.commit(std::shared_ptr<search::IDestructorCallback>()); - indexFieldWriter.sync(); + indexFieldWriter->sync(); testSearch(memory_index, word1, doc_id1); testSearch(memory_index, word2, doc_id2); diff --git a/searchcore/src/tests/proton/index/indexmanager_test.cpp b/searchcore/src/tests/proton/index/indexmanager_test.cpp index 7542ef24c52..264cf6d8cfa 100644 --- a/searchcore/src/tests/proton/index/indexmanager_test.cpp +++ b/searchcore/src/tests/proton/index/indexmanager_test.cpp @@ -379,10 +379,9 @@ TEST_F(IndexManagerTest, require_that_flush_stats_are_calculated) { Schema schema(getSchema()); FieldIndexCollection fic(schema, MockFieldLengthInspector()); - SequencedTaskExecutor invertThreads(2); - SequencedTaskExecutor pushThreads(2); - search::memoryindex::DocumentInverter inverter(schema, invertThreads, - pushThreads, fic); + auto invertThreads = SequencedTaskExecutor::create(2); + auto pushThreads = SequencedTaskExecutor::create(2); + search::memoryindex::DocumentInverter inverter(schema, *invertThreads, *pushThreads, fic); uint64_t fixed_index_size = fic.getMemoryUsage().allocatedBytes(); uint64_t index_size = fic.getMemoryUsage().allocatedBytes() - fixed_index_size; @@ -395,9 +394,9 @@ TEST_F(IndexManagerTest, require_that_flush_stats_are_calculated) Document::UP doc = addDocument(docid); inverter.invertDocument(docid, *doc); - invertThreads.sync(); + invertThreads->sync(); inverter.pushDocuments(std::shared_ptr<search::IDestructorCallback>()); - pushThreads.sync(); + pushThreads->sync(); index_size = fic.getMemoryUsage().allocatedBytes() - fixed_index_size; /// Must account for both docid 0 being reserved and the extra after. @@ -414,9 +413,9 @@ TEST_F(IndexManagerTest, require_that_flush_stats_are_calculated) inverter.invertDocument(docid + 10, *doc); doc = addDocument(docid + 100); inverter.invertDocument(docid + 100, *doc); - invertThreads.sync(); + invertThreads->sync(); inverter.pushDocuments(std::shared_ptr<search::IDestructorCallback>()); - pushThreads.sync(); + pushThreads->sync(); index_size = fic.getMemoryUsage().allocatedBytes() - fixed_index_size; /// Must account for both docid 0 being reserved and the extra after. selector_size = (docid + 100 + 1) * sizeof(Source); diff --git a/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp b/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp index b77d9b3f5ab..02e9f3e8687 100644 --- a/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp +++ b/searchcore/src/tests/proton/reference/document_db_reference_resolver/document_db_reference_resolver_test.cpp @@ -42,7 +42,7 @@ const ReferenceAttribute *getReferenceAttribute(const IGidToLidChangeListener &l struct MyGidToLidMapperFactory : public IGidToLidMapperFactory { using SP = std::shared_ptr<MyGidToLidMapperFactory>; - virtual std::unique_ptr<IGidToLidMapper> getMapper() const override { + std::unique_ptr<IGidToLidMapper> getMapper() const override { return std::unique_ptr<IGidToLidMapper>(); } }; @@ -60,14 +60,14 @@ struct MyDocumentDBReference : public MockDocumentDBReference { MyDocumentDBReference(MyGidToLidMapperFactory::SP factory_, std::shared_ptr<MockGidToLidChangeHandler> gidToLidChangeHandler) - : factory(factory_), + : factory(std::move(factory_)), _gidToLidChangeHandler(std::move(gidToLidChangeHandler)) { } - virtual IGidToLidMapperFactory::SP getGidToLidMapperFactory() override { + IGidToLidMapperFactory::SP getGidToLidMapperFactory() override { return factory; } - virtual std::shared_ptr<search::attribute::ReadableAttributeVector> getAttribute(vespalib::stringref name) override { + std::shared_ptr<search::attribute::ReadableAttributeVector> getAttribute(vespalib::stringref name) override { auto itr = attributes.find(name); if (itr != attributes.end()) { return itr->second; @@ -78,7 +78,7 @@ struct MyDocumentDBReference : public MockDocumentDBReference { void addIntAttribute(vespalib::stringref name) { attributes[name] = AttributeFactory::createAttribute(name, Config(BasicType::INT32)); } - virtual std::unique_ptr<GidToLidChangeRegistrator> makeGidToLidChangeRegistrator(const vespalib::string &docTypeName) override { + std::unique_ptr<GidToLidChangeRegistrator> makeGidToLidChangeRegistrator(const vespalib::string &docTypeName) override { return std::make_unique<GidToLidChangeRegistrator>(_gidToLidChangeHandler, docTypeName); } @@ -93,12 +93,12 @@ struct MyDocumentDBReference : public MockDocumentDBReference { struct MyReferenceRegistry : public IDocumentDBReferenceRegistry { using ReferenceMap = std::map<vespalib::string, IDocumentDBReference::SP>; ReferenceMap map; - virtual IDocumentDBReference::SP get(vespalib::stringref name) const override { + IDocumentDBReference::SP get(vespalib::stringref name) const override { auto itr = map.find(name); ASSERT_TRUE(itr != map.end()); return itr->second; } - virtual IDocumentDBReference::SP tryGet(vespalib::stringref name) const override { + IDocumentDBReference::SP tryGet(vespalib::stringref name) const override { auto itr = map.find(name); if (itr != map.end()) { return itr->second; @@ -106,10 +106,10 @@ struct MyReferenceRegistry : public IDocumentDBReferenceRegistry { return IDocumentDBReference::SP(); } } - virtual void add(vespalib::stringref name, IDocumentDBReference::SP reference) override { + void add(vespalib::stringref name, IDocumentDBReference::SP reference) override { map[name] = reference; } - virtual void remove(vespalib::stringref) override {} + void remove(vespalib::stringref) override {} }; struct MyAttributeManager : public MockAttributeManager { @@ -121,7 +121,7 @@ struct MyAttributeManager : public MockAttributeManager { } const ReferenceAttribute *getReferenceAttribute(const vespalib::string &name) const { AttributeGuard::UP guard = getAttribute(name); - const ReferenceAttribute *result = dynamic_cast<const ReferenceAttribute *>(guard->get()); + auto *result = dynamic_cast<const ReferenceAttribute *>(guard->get()); ASSERT_TRUE(result != nullptr); return result; } @@ -155,8 +155,7 @@ struct DocumentModel { } }; -DocumentModel::~DocumentModel() { -} +DocumentModel::~DocumentModel() = default; void set(const vespalib::string &name, @@ -182,7 +181,7 @@ createImportedFieldsConfig() const ImportedAttributeVector & asImportedAttribute(const IAttributeVector &attr) { - const ImportedAttributeVector *result = dynamic_cast<const ImportedAttributeVector *>(&attr); + auto *result = dynamic_cast<const ImportedAttributeVector *>(&attr); ASSERT_TRUE(result != nullptr); return *result; } @@ -199,7 +198,7 @@ struct Fixture { MyAttributeManager oldAttrMgr; DocumentModel docModel; ImportedFieldsConfig importedFieldsCfg; - SequencedTaskExecutor _attributeFieldWriter; + std::unique_ptr<ISequencedTaskExecutor> _attributeFieldWriter; Fixture() : factory(std::make_shared<MyGidToLidMapperFactory>()), _gidToLidChangeListenerRefCount(), @@ -211,7 +210,7 @@ struct Fixture { attrMgr(), docModel(), importedFieldsCfg(createImportedFieldsConfig()), - _attributeFieldWriter(1) + _attributeFieldWriter(SequencedTaskExecutor::create(1)) { registry.add("parent", parentReference); @@ -231,7 +230,7 @@ struct Fixture { oldAttrMgr.addReferenceAttribute("parent3_ref"); } ImportedAttributesRepo::UP resolve(vespalib::duration visibilityDelay, bool useReferences) { - DocumentDBReferenceResolver resolver(registry, docModel.childDocType, importedFieldsCfg, docModel.childDocType, _gidToLidChangeListenerRefCount, _attributeFieldWriter, useReferences); + DocumentDBReferenceResolver resolver(registry, docModel.childDocType, importedFieldsCfg, docModel.childDocType, _gidToLidChangeListenerRefCount, *_attributeFieldWriter, useReferences); return resolver.resolve(attrMgr, oldAttrMgr, std::shared_ptr<search::IDocumentMetaStoreContext>(), visibilityDelay); } ImportedAttributesRepo::UP resolve(vespalib::duration visibilityDelay) { @@ -244,7 +243,7 @@ struct Fixture { return resolve(vespalib::duration::zero()); } void teardown() { - DocumentDBReferenceResolver resolver(registry, docModel.childDocType, importedFieldsCfg, docModel.childDocType, _gidToLidChangeListenerRefCount, _attributeFieldWriter, false); + DocumentDBReferenceResolver resolver(registry, docModel.childDocType, importedFieldsCfg, docModel.childDocType, _gidToLidChangeListenerRefCount, *_attributeFieldWriter, false); resolver.teardown(attrMgr); } const IGidToLidMapperFactory *getMapperFactoryPtr(const vespalib::string &attrName) { @@ -254,7 +253,7 @@ struct Fixture { const vespalib::string &referenceField, const vespalib::string &targetField, bool useSearchCache, - ImportedAttributeVector::SP attr) { + const ImportedAttributeVector::SP & attr) { ASSERT_TRUE(attr.get()); EXPECT_EQUAL(name, attr->getName()); EXPECT_EQUAL(attrMgr.getReferenceAttribute(referenceField), attr->getReferenceAttribute().get()); diff --git a/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp b/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp index 159ce17ef45..a023ff175d6 100644 --- a/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp +++ b/searchcore/src/tests/proton/reference/gid_to_lid_change_listener/gid_to_lid_change_listener_test.cpp @@ -49,13 +49,13 @@ struct MyGidToLidMapperFactory : public MockGidToLidMapperFactory struct Fixture { std::shared_ptr<ReferenceAttribute> _attr; - search::SequencedTaskExecutor _writer; + std::unique_ptr<search::ISequencedTaskExecutor> _writer; MonitoredRefCount _refCount; std::unique_ptr<GidToLidChangeListener> _listener; Fixture() : _attr(std::make_shared<ReferenceAttribute>("test", Config(BasicType::REFERENCE))), - _writer(1), + _writer(search::SequencedTaskExecutor::create(1)), _refCount(), _listener() { @@ -91,7 +91,7 @@ struct Fixture } void allocListener() { - _listener = std::make_unique<GidToLidChangeListener>(_writer, _attr, _refCount, "test", "testdoc"); + _listener = std::make_unique<GidToLidChangeListener>(*_writer, _attr, _refCount, "test", "testdoc"); } void notifyPutDone(const GlobalId &gid, uint32_t referencedDoc) { diff --git a/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.cpp b/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.cpp index af8e16f657b..6ca385711b0 100644 --- a/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.cpp @@ -1,11 +1,10 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "executor_thread_service.h" -#include <vespa/vespalib/util/closuretask.h> +#include <vespa/vespalib/util/lambdatask.h> #include <vespa/fastos/thread.h> -using vespalib::makeClosure; -using vespalib::makeTask; +using vespalib::makeLambdaTask; using vespalib::Executor; using vespalib::Gate; using vespalib::Runnable; @@ -32,7 +31,7 @@ std::unique_ptr<internal::ThreadId> getThreadId(ThreadStackExecutorBase &executor) { std::unique_ptr<internal::ThreadId> id = std::make_unique<internal::ThreadId>(); - executor.execute(makeTask(makeClosure(&sampleThreadId, &id->_id))); + executor.execute(makeLambdaTask([threadId=&id->_id] { sampleThreadId(threadId);})); executor.sync(); return id; } @@ -52,7 +51,7 @@ ExecutorThreadService::ExecutorThreadService(ThreadStackExecutorBase &executor) { } -ExecutorThreadService::~ExecutorThreadService() {} +ExecutorThreadService::~ExecutorThreadService() = default; void ExecutorThreadService::run(Runnable &runnable) @@ -61,7 +60,7 @@ ExecutorThreadService::run(Runnable &runnable) runnable.run(); } else { Gate gate; - _executor.execute(makeTask(makeClosure(&runRunnable, &runnable, &gate))); + _executor.execute(makeLambdaTask([runnablePtr=&runnable, gatePtr=&gate] { runRunnable(runnablePtr, gatePtr); })); gate.await(); } } @@ -73,4 +72,12 @@ ExecutorThreadService::isCurrentThread() const return FastOS_Thread::CompareThreadIds(_threadId->_id, currentThreadId); } +vespalib::ThreadExecutor::Stats ExecutorThreadService::getStats() { + return _executor.getStats(); +} + +void ExecutorThreadService::setTaskLimit(uint32_t taskLimit) { + _executor.setTaskLimit(taskLimit); +} + } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.h b/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.h index 521565358d9..ccdfb6b72cd 100644 --- a/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.h +++ b/searchcore/src/vespa/searchcore/proton/server/executor_thread_service.h @@ -21,9 +21,8 @@ public: ExecutorThreadService(vespalib::ThreadStackExecutorBase &executor); ~ExecutorThreadService(); - /** - * Implements IThreadService - */ + Stats getStats() override; + vespalib::Executor::Task::UP execute(vespalib::Executor::Task::UP task) override { return _executor.execute(std::move(task)); } @@ -34,6 +33,8 @@ public: } bool isCurrentThread() const override; size_t getNumThreads() const override { return _executor.getNumThreads(); } + + void setTaskLimit(uint32_t taskLimit) override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/server/executorthreadingservice.cpp b/searchcore/src/vespa/searchcore/proton/server/executorthreadingservice.cpp index 262363f4250..058197f0271 100644 --- a/searchcore/src/vespa/searchcore/proton/server/executorthreadingservice.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/executorthreadingservice.cpp @@ -19,9 +19,9 @@ ExecutorThreadingService::ExecutorThreadingService(vespalib::ThreadStackExecutor _masterService(_masterExecutor), _indexService(_indexExecutor), _summaryService(_summaryExecutor), - _indexFieldInverter(std::make_unique<SequencedTaskExecutor>(threads, taskLimit)), - _indexFieldWriter(std::make_unique<SequencedTaskExecutor>(threads, taskLimit)), - _attributeFieldWriter(std::make_unique<SequencedTaskExecutor>(threads, taskLimit)) + _indexFieldInverter(SequencedTaskExecutor::create(threads, taskLimit)), + _indexFieldWriter(SequencedTaskExecutor::create(threads, taskLimit)), + _attributeFieldWriter(SequencedTaskExecutor::create(threads, taskLimit)) { } diff --git a/searchcore/src/vespa/searchcore/proton/server/executorthreadingservice.h b/searchcore/src/vespa/searchcore/proton/server/executorthreadingservice.h index 9ab6eba39e1..7bbe1cb162a 100644 --- a/searchcore/src/vespa/searchcore/proton/server/executorthreadingservice.h +++ b/searchcore/src/vespa/searchcore/proton/server/executorthreadingservice.h @@ -6,7 +6,6 @@ #include <vespa/vespalib/util/blockingthreadstackexecutor.h> #include <vespa/vespalib/util/threadstackexecutor.h> -namespace search { class SequencedTaskExecutor; } namespace proton { class ExecutorThreadingServiceStats; @@ -18,16 +17,16 @@ class ExecutorThreadingServiceStats; class ExecutorThreadingService : public searchcorespi::index::IThreadingService { private: - vespalib::ThreadStackExecutorBase & _sharedExecutor; - vespalib::ThreadStackExecutor _masterExecutor; - vespalib::BlockingThreadStackExecutor _indexExecutor; - vespalib::BlockingThreadStackExecutor _summaryExecutor; - ExecutorThreadService _masterService; - ExecutorThreadService _indexService; - ExecutorThreadService _summaryService; - std::unique_ptr<search::SequencedTaskExecutor> _indexFieldInverter; - std::unique_ptr<search::SequencedTaskExecutor> _indexFieldWriter; - std::unique_ptr<search::SequencedTaskExecutor> _attributeFieldWriter; + vespalib::ThreadStackExecutorBase & _sharedExecutor; + vespalib::ThreadStackExecutor _masterExecutor; + vespalib::BlockingThreadStackExecutor _indexExecutor; + vespalib::BlockingThreadStackExecutor _summaryExecutor; + ExecutorThreadService _masterService; + ExecutorThreadService _indexService; + ExecutorThreadService _summaryService; + std::unique_ptr<search::ISequencedTaskExecutor> _indexFieldInverter; + std::unique_ptr<search::ISequencedTaskExecutor> _indexFieldWriter; + std::unique_ptr<search::ISequencedTaskExecutor> _attributeFieldWriter; public: /** diff --git a/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt index ad5ae54f6e1..488ac1041f1 100644 --- a/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt +++ b/searchcore/src/vespa/searchcore/proton/test/CMakeLists.txt @@ -8,6 +8,7 @@ vespa_add_library(searchcore_test STATIC documentdb_config_builder.cpp dummy_feed_view.cpp userdocumentsbuilder.cpp + threading_service_observer.cpp DEPENDS searchcore_fconfig ) diff --git a/searchcore/src/vespa/searchcore/proton/test/thread_service_observer.h b/searchcore/src/vespa/searchcore/proton/test/thread_service_observer.h index c8d0f8968c9..766bdeeefb0 100644 --- a/searchcore/src/vespa/searchcore/proton/test/thread_service_observer.h +++ b/searchcore/src/vespa/searchcore/proton/test/thread_service_observer.h @@ -20,9 +20,6 @@ public: uint32_t getExecuteCnt() const { return _executeCnt; } - /** - * Implements IThreadService - */ vespalib::Executor::Task::UP execute(vespalib::Executor::Task::UP task) override { ++_executeCnt; return _service.execute(std::move(task)); @@ -39,6 +36,14 @@ public: } size_t getNumThreads() const override { return _service.getNumThreads(); } + Stats getStats() override { + return _service.getStats(); + } + + void setTaskLimit(uint32_t taskLimit) override { + _service.setTaskLimit(taskLimit); + } + }; } diff --git a/searchcore/src/vespa/searchcore/proton/test/threading_service_observer.cpp b/searchcore/src/vespa/searchcore/proton/test/threading_service_observer.cpp new file mode 100644 index 00000000000..30a6334d764 --- /dev/null +++ b/searchcore/src/vespa/searchcore/proton/test/threading_service_observer.cpp @@ -0,0 +1,22 @@ +// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "threading_service_observer.h" + +namespace proton::test { + +ThreadingServiceObserver::ThreadingServiceObserver(searchcorespi::index::IThreadingService &service) + : _service(service), + _master(_service.master()), + _index(service.index()), + _summary(service.summary()), + _shared(service.shared()), + _indexFieldInverter(_service.indexFieldInverter()), + _indexFieldWriter(_service.indexFieldWriter()), + _attributeFieldWriter(_service.attributeFieldWriter()) +{ +} + +ThreadingServiceObserver::~ThreadingServiceObserver() = default; + +} + diff --git a/searchcore/src/vespa/searchcore/proton/test/threading_service_observer.h b/searchcore/src/vespa/searchcore/proton/test/threading_service_observer.h index e1a4433ed4b..7ac9c0c68f2 100644 --- a/searchcore/src/vespa/searchcore/proton/test/threading_service_observer.h +++ b/searchcore/src/vespa/searchcore/proton/test/threading_service_observer.h @@ -21,18 +21,8 @@ private: search::SequencedTaskExecutorObserver _attributeFieldWriter; public: - ThreadingServiceObserver(searchcorespi::index::IThreadingService &service) - : _service(service), - _master(_service.master()), - _index(service.index()), - _summary(service.summary()), - _shared(service.shared()), - _indexFieldInverter(_service.indexFieldInverter()), - _indexFieldWriter(_service.indexFieldWriter()), - _attributeFieldWriter(_service.attributeFieldWriter()) - { - } - ~ThreadingServiceObserver() override { } + ThreadingServiceObserver(searchcorespi::index::IThreadingService &service); + ~ThreadingServiceObserver() override; const ThreadServiceObserver &masterObserver() const { return _master; } @@ -53,16 +43,10 @@ public: return _attributeFieldWriter; } - /** - * Implements vespalib::Syncable - */ vespalib::Syncable &sync() override { return _service.sync(); } - /** - * Implements IThreadingService - */ searchcorespi::index::IThreadService &master() override { return _master; } |