diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2017-09-26 15:08:21 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2017-09-26 15:08:21 +0200 |
commit | fc1b0fd518fe5e37757690ce05e26fb4025d0059 (patch) | |
tree | eedbcdf9253fd5a6e5cba2b9aa8712457e232e5a /searchlib | |
parent | 6796195b37f351f843eea4992d2d45b7ba4eb771 (diff) |
Use multiple threads for mbus invoke
Diffstat (limited to 'searchlib')
6 files changed, 20 insertions, 54 deletions
diff --git a/searchlib/src/apps/tests/btreestress_test.cpp b/searchlib/src/apps/tests/btreestress_test.cpp index 94f2db165d3..ca92ad4865b 100644 --- a/searchlib/src/apps/tests/btreestress_test.cpp +++ b/searchlib/src/apps/tests/btreestress_test.cpp @@ -1,10 +1,6 @@ // 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("btreestress_test"); + #include <vespa/vespalib/testkit/test_kit.h> -#include <string> -#include <set> -#include <iostream> #include <vespa/searchlib/btree/btreeroot.h> #include <vespa/searchlib/btree/btreebuilder.h> #include <vespa/searchlib/btree/btreenodeallocator.h> @@ -22,16 +18,17 @@ LOG_SETUP("btreestress_test"); #include <vespa/searchlib/btree/btreestore.hpp> #include <vespa/searchlib/btree/btreeaggregator.hpp> - #include <vespa/vespalib/util/threadstackexecutor.h> -#include <vespa/searchlib/common/lambdatask.h> -#include <vespa/searchlib/util/rand48.h> +#include <vespa/vespalib/util/lambdatask.h> + +#include <vespa/log/log.h> +LOG_SETUP("btreestress_test"); using MyTree = search::btree::BTree<uint32_t, uint32_t>; using MyTreeIterator = typename MyTree::Iterator; using MyTreeConstIterator = typename MyTree::ConstIterator; using GenerationHandler = vespalib::GenerationHandler; -using search::makeLambdaTask; +using vespalib::makeLambdaTask; struct Fixture { diff --git a/searchlib/src/apps/tests/memoryindexstress_test.cpp b/searchlib/src/apps/tests/memoryindexstress_test.cpp index 837952061c8..edb9160a1fb 100644 --- a/searchlib/src/apps/tests/memoryindexstress_test.cpp +++ b/searchlib/src/apps/tests/memoryindexstress_test.cpp @@ -16,9 +16,6 @@ #include <vespa/searchlib/common/scheduletaskcallback.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/document/repo/configbuilder.h> -#include <vespa/document/datatype/annotationtype.h> -#include <vespa/document/annotation/annotation.h> -#include <vespa/document/annotation/span.h> #include <vespa/document/annotation/spanlist.h> #include <vespa/document/annotation/spantree.h> #include <vespa/searchlib/util/rand48.h> @@ -37,7 +34,7 @@ using document::SpanList; using document::StringFieldValue; using search::ScheduleTaskCallback; using search::index::schema::DataType; -using search::makeLambdaTask; +using vespalib::makeLambdaTask; using search::query::Node; using search::query::SimplePhrase; using search::query::SimpleStringTerm; diff --git a/searchlib/src/tests/memoryindex/memoryindex/memoryindex_test.cpp b/searchlib/src/tests/memoryindex/memoryindex/memoryindex_test.cpp index cfbb0847cd5..77a687796b3 100644 --- a/searchlib/src/tests/memoryindex/memoryindex/memoryindex_test.cpp +++ b/searchlib/src/tests/memoryindex/memoryindex/memoryindex_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("memoryindex_test"); + #include <vespa/vespalib/testkit/testapp.h> #include <vespa/searchlib/memoryindex/memoryindex.h> @@ -19,11 +18,14 @@ LOG_SETUP("memoryindex_test"); #include <vespa/searchlib/common/scheduletaskcallback.h> #include <vespa/vespalib/util/threadstackexecutor.h> +#include <vespa/log/log.h> +LOG_SETUP("memoryindex_test"); + using document::Document; using document::FieldValue; using search::ScheduleTaskCallback; using search::index::schema::DataType; -using search::makeLambdaTask; +using vespalib::makeLambdaTask; using search::query::Node; using search::query::SimplePhrase; using search::query::SimpleStringTerm; diff --git a/searchlib/src/vespa/searchlib/common/isequencedtaskexecutor.h b/searchlib/src/vespa/searchlib/common/isequencedtaskexecutor.h index 6984f696117..9b825f1c47e 100644 --- a/searchlib/src/vespa/searchlib/common/isequencedtaskexecutor.h +++ b/searchlib/src/vespa/searchlib/common/isequencedtaskexecutor.h @@ -3,10 +3,9 @@ #include <vespa/vespalib/util/executor.h> #include <vespa/vespalib/stllike/hash_fun.h> -#include "lambdatask.h" +#include <vespa/vespalib/util/lambdatask.h> -namespace search -{ +namespace search { /** * Interface class to run multiple tasks in parallel, but tasks with same @@ -50,7 +49,7 @@ public: */ template <class FunctionType> void executeLambda(uint32_t executorId, FunctionType &&function) { - executeTask(executorId, makeLambdaTask(std::forward<FunctionType>(function))); + executeTask(executorId, vespalib::makeLambdaTask(std::forward<FunctionType>(function))); } /** * Wait for all scheduled tasks to complete. @@ -69,7 +68,7 @@ public: template <class FunctionType> void execute(uint64_t componentId, FunctionType &&function) { uint32_t executorId = getExecutorId(componentId); - executeTask(executorId, makeLambdaTask(std::forward<FunctionType>(function))); + executeTask(executorId, vespalib::makeLambdaTask(std::forward<FunctionType>(function))); } /** @@ -84,7 +83,7 @@ public: template <class FunctionType> void execute(vespalib::stringref componentId, FunctionType &&function) { uint32_t executorId = getExecutorId(componentId); - executeTask(executorId, makeLambdaTask(std::forward<FunctionType>(function))); + executeTask(executorId, vespalib::makeLambdaTask(std::forward<FunctionType>(function))); } }; diff --git a/searchlib/src/vespa/searchlib/common/lambdatask.h b/searchlib/src/vespa/searchlib/common/lambdatask.h deleted file mode 100644 index 01b57694d11..00000000000 --- a/searchlib/src/vespa/searchlib/common/lambdatask.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -#include <vespa/vespalib/util/executor.h> - -namespace search { - -template <class FunctionType> -class LambdaTask : public vespalib::Executor::Task { - FunctionType _func; - -public: - LambdaTask(const FunctionType &func) : _func(func) {} - LambdaTask(FunctionType &&func) : _func(std::move(func)) {} - LambdaTask(const LambdaTask &) = delete; - LambdaTask & operator = (const LambdaTask &) = delete; - ~LambdaTask() {} - void run() override { _func(); } -}; - -template <class FunctionType> -vespalib::Executor::Task::UP -makeLambdaTask(FunctionType &&function) -{ - return std::make_unique<LambdaTask<std::decay_t<FunctionType>>> - (std::forward<FunctionType>(function)); -} - -} // namespace search diff --git a/searchlib/src/vespa/searchlib/docstore/filechunk.cpp b/searchlib/src/vespa/searchlib/docstore/filechunk.cpp index 4fac42c1421..93a85eda0aa 100644 --- a/searchlib/src/vespa/searchlib/docstore/filechunk.cpp +++ b/searchlib/src/vespa/searchlib/docstore/filechunk.cpp @@ -5,7 +5,7 @@ #include "summaryexceptions.h" #include "randreaders.h" #include <vespa/searchlib/util/filekit.h> -#include <vespa/searchlib/common/lambdatask.h> +#include <vespa/vespalib/util/lambdatask.h> #include <vespa/vespalib/data/fileheader.h> #include <vespa/vespalib/data/databuffer.h> #include <vespa/vespalib/stllike/asciistream.h> @@ -345,14 +345,14 @@ FileChunk::appendTo(vespalib::ThreadExecutor & executor, const IGetLid & db, IWr for (size_t chunkId(0); chunkId < numChunks; chunkId++) { std::promise<Chunk::UP> promisedChunk; std::future<Chunk::UP> futureChunk = promisedChunk.get_future(); - executor.execute(makeLambdaTask([promise = std::move(promisedChunk), chunkId, this]() mutable { + executor.execute(vespalib::makeLambdaTask([promise = std::move(promisedChunk), chunkId, this]() mutable { const ChunkInfo & cInfo(_chunkInfo[chunkId]); vespalib::DataBuffer whole(0ul, ALIGNMENT); FileRandRead::FSP keepAlive(_file->read(cInfo.getOffset(), whole, cInfo.getSize())); promise.set_value(std::make_unique<Chunk>(chunkId, whole.getData(), whole.getDataLen())); })); - singleExecutor.execute(makeLambdaTask([args = &fixedParams, chunk = std::move(futureChunk)]() mutable { + singleExecutor.execute(vespalib::makeLambdaTask([args = &fixedParams, chunk = std::move(futureChunk)]() mutable { appendChunks(args, chunk.get()); })); } |