diff options
-rw-r--r-- | searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp | 11 | ||||
-rw-r--r-- | searchlib/src/tests/attribute/benchmark/attributesearcher.h (renamed from searchlib/src/tests/attribute/attributesearcher.h) | 18 | ||||
-rw-r--r-- | searchlib/src/tests/attribute/benchmark/attributeupdater.h (renamed from searchlib/src/tests/attribute/attributeupdater.h) | 4 | ||||
-rw-r--r-- | searchlib/src/tests/attribute/runnable.h | 45 |
4 files changed, 17 insertions, 61 deletions
diff --git a/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp b/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp index e2dc6b2b2ef..5722b7c90ca 100644 --- a/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp +++ b/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp @@ -8,11 +8,12 @@ #include <vespa/searchlib/attribute/singlestringattribute.h> #include <vespa/searchlib/attribute/multistringattribute.h> #include <vespa/searchlib/attribute/attrvector.h> +#include <vespa/fastos/thread.h> #include <vespa/fastos/app.h> #include <iostream> #include <fstream> -#include "../attributesearcher.h" -#include "../attributeupdater.h" +#include "attributesearcher.h" +#include "attributeupdater.h" #include <sys/resource.h> #include <vespa/log/log.h> @@ -266,11 +267,11 @@ AttributeBenchmark::benchmarkSearch(const AttributePtr & ptr, const std::vector< for (uint32_t i = 0; i < _config._numSearchers; ++i) { if (_config._rangeSearch) { RangeSpec spec(_config._rangeStart, _config._rangeEnd, _config._rangeDelta); - searchers.push_back(new AttributeRangeSearcher(i, ptr, spec, _config._numQueries)); + searchers.push_back(new AttributeRangeSearcher(ptr, spec, _config._numQueries)); } else if (_config._prefixSearch) { - searchers.push_back(new AttributePrefixSearcher(i, ptr, prefixStrings, _config._numQueries)); + searchers.push_back(new AttributePrefixSearcher(ptr, prefixStrings, _config._numQueries)); } else { - searchers.push_back(new AttributeFindSearcher<T>(i, ptr, values, _config._numQueries)); + searchers.push_back(new AttributeFindSearcher<T>(ptr, values, _config._numQueries)); } _threadPool->NewThread(searchers.back()); } diff --git a/searchlib/src/tests/attribute/attributesearcher.h b/searchlib/src/tests/attribute/benchmark/attributesearcher.h index bd86f291f7b..f8cd614c48c 100644 --- a/searchlib/src/tests/attribute/attributesearcher.h +++ b/searchlib/src/tests/attribute/benchmark/attributesearcher.h @@ -2,7 +2,7 @@ #pragma once -#include "runnable.h" +#include <vespa/searchlib/util/runnable.h> #include <vespa/searchlib/attribute/attribute.h> #include <vespa/searchlib/attribute/attributeguard.h> #include <vespa/searchlib/queryeval/hitcollector.h> @@ -67,8 +67,8 @@ protected: AttributeSearcherStatus _status; public: - AttributeSearcher(uint32_t id, const AttributePtr & attrPtr) : - Runnable(id), _attrPtr(attrPtr), _timer(), _status() + AttributeSearcher(const AttributePtr & attrPtr) : + Runnable(), _attrPtr(attrPtr), _timer(), _status() { _status._numClients = 1; } @@ -108,9 +108,9 @@ private: std::vector<char> _query; public: - AttributeFindSearcher(uint32_t id, const AttributePtr & attrPtr, const std::vector<T> & values, + AttributeFindSearcher(const AttributePtr & attrPtr, const std::vector<T> & values, uint32_t numQueries) : - AttributeSearcher(id, attrPtr), _values(values), _query() + AttributeSearcher(attrPtr), _values(values), _query() { _status._numQueries = numQueries; } @@ -186,9 +186,9 @@ private: std::vector<char> _query; public: - AttributeRangeSearcher(uint32_t id, const AttributePtr & attrPtr, const RangeSpec & spec, + AttributeRangeSearcher(const AttributePtr & attrPtr, const RangeSpec & spec, uint32_t numQueries) : - AttributeSearcher(id, attrPtr), _spec(spec), _query() + AttributeSearcher(attrPtr), _spec(spec), _query() { _status._numQueries = numQueries; } @@ -228,9 +228,9 @@ private: std::vector<char> _query; public: - AttributePrefixSearcher(uint32_t id, const AttributePtr & attrPtr, + AttributePrefixSearcher(const AttributePtr & attrPtr, const std::vector<vespalib::string> & values, uint32_t numQueries) : - AttributeSearcher(id, attrPtr), _values(values), _query() + AttributeSearcher(attrPtr), _values(values), _query() { _status._numQueries = numQueries; } diff --git a/searchlib/src/tests/attribute/attributeupdater.h b/searchlib/src/tests/attribute/benchmark/attributeupdater.h index 3f41b79f331..13360e58b2d 100644 --- a/searchlib/src/tests/attribute/attributeupdater.h +++ b/searchlib/src/tests/attribute/benchmark/attributeupdater.h @@ -3,7 +3,7 @@ #pragma once #include <vespa/searchlib/util/randomgenerator.h> -#include "runnable.h" +#include <vespa/searchlib/util/runnable.h> #include <vespa/searchlib/attribute/attribute.h> #define VALIDATOR_STR(str) #str @@ -169,7 +169,7 @@ AttributeUpdaterThread<Vector, T, BT>::AttributeUpdaterThread(const AttributePtr RandomGenerator & rndGen, bool validate, uint32_t commitFreq, uint32_t minValueCount, uint32_t maxValueCount) : AttributeUpdater<Vector, T, BT>(attrPtr, values, rndGen, validate, commitFreq, minValueCount, maxValueCount), - Runnable(0) + Runnable() {} template <typename Vector, typename T, typename BT> AttributeUpdaterThread<Vector, T, BT>::~AttributeUpdaterThread() { } diff --git a/searchlib/src/tests/attribute/runnable.h b/searchlib/src/tests/attribute/runnable.h deleted file mode 100644 index fb0a7cb1825..00000000000 --- a/searchlib/src/tests/attribute/runnable.h +++ /dev/null @@ -1,45 +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 <mutex> -#include <condition_variable> -#include <vespa/fastos/thread.h> - -namespace search { - -class Runnable : public FastOS_Runnable -{ -protected: - uint32_t _id; - std::mutex _lock; - std::condition_variable _cond; - bool _done; - bool _stopped; - -public: - Runnable(uint32_t id) : - _id(id), _lock(), _cond(), _done(false), _stopped(false) - { } - void Run(FastOS_ThreadInterface *, void *) override { - doRun(); - - std::lock_guard<std::mutex> guard(_lock); - _stopped = true; - _cond.notify_all(); - } - virtual void doRun() = 0; - void stop() { - std::lock_guard<std::mutex> guard(_lock); - _done = true; - } - void join() { - std::unique_lock<std::mutex> guard(_lock); - while (!_stopped) { - _cond.wait(guard); - } - } -}; - -} // search - |