diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-12-13 15:26:41 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-12-13 15:26:41 +0100 |
commit | d3c1c98b5e67cf8f9bb9f3efdef3161f63c19ffc (patch) | |
tree | 05aea3ca495d6acf87ee3817d6f2957a57c39339 /searchlib | |
parent | 3783a9b21f8ab7ca3700903d9780a9f7374cf0c5 (diff) | |
parent | 540b84751e90d60c13c4da3e1e15d47b720c327e (diff) |
Merge with master
Diffstat (limited to 'searchlib')
24 files changed, 112 insertions, 121 deletions
diff --git a/searchlib/pom.xml b/searchlib/pom.xml index 8cb4ed8b0e3..cc955195a5f 100644 --- a/searchlib/pom.xml +++ b/searchlib/pom.xml @@ -6,6 +6,7 @@ <groupId>com.yahoo.vespa</groupId> <artifactId>parent</artifactId> <version>6-SNAPSHOT</version> + <relativePath>../parent/pom.xml</relativePath> </parent> <artifactId>searchlib</artifactId> <packaging>container-plugin</packaging> diff --git a/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp b/searchlib/src/tests/attribute/benchmark/attributebenchmark.cpp index 8eef498d85c..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> @@ -21,8 +22,6 @@ LOG_SETUP("attributebenchmark"); #include <vespa/searchlib/attribute/attributevector.hpp> -using vespalib::Monitor; -using vespalib::MonitorGuard; using std::shared_ptr; typedef std::vector<uint32_t> NumVector; @@ -268,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 b95d7d3843f..00000000000 --- a/searchlib/src/tests/attribute/runnable.h +++ /dev/null @@ -1,43 +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/sync.h> -#include <vespa/fastos/thread.h> - -namespace search { - -class Runnable : public FastOS_Runnable -{ -protected: - uint32_t _id; - vespalib::Monitor _cond; - bool _done; - bool _stopped; - -public: - Runnable(uint32_t id) : - _id(id), _cond(), _done(false), _stopped(false) - { } - void Run(FastOS_ThreadInterface *, void *) override { - doRun(); - - vespalib::MonitorGuard guard(_cond); - _stopped = true; - guard.broadcast(); - } - virtual void doRun() = 0; - void stop() { - vespalib::MonitorGuard guard(_cond); - _done = true; - } - void join() { - vespalib::MonitorGuard guard(_cond); - while (!_stopped) { - guard.wait(); - } - } -}; - -} // search - diff --git a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp index 8fc47725a1d..d041dde52a5 100644 --- a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp +++ b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp @@ -363,10 +363,10 @@ Fixture::testEmptyTensor() Tensor::UP emptyTensor = tensorAttr.getEmptyTensor(); if (_denseTensors) { vespalib::string expSpec = expEmptyDenseTensorSpec(); - EXPECT_EQUAL(emptyTensor->getType(), ValueType::from_spec(expSpec)); + EXPECT_EQUAL(emptyTensor->type(), ValueType::from_spec(expSpec)); } else { - EXPECT_EQUAL(emptyTensor->getType(), tensorAttr.getConfig().tensorType()); - EXPECT_EQUAL(emptyTensor->getType(), ValueType::from_spec(_typeSpec)); + EXPECT_EQUAL(emptyTensor->type(), tensorAttr.getConfig().tensorType()); + EXPECT_EQUAL(emptyTensor->type(), ValueType::from_spec(_typeSpec)); } } diff --git a/searchlib/src/tests/features/constant/constant_test.cpp b/searchlib/src/tests/features/constant/constant_test.cpp index 4a88fde58ce..f9d1736ba9e 100644 --- a/searchlib/src/tests/features/constant/constant_test.cpp +++ b/searchlib/src/tests/features/constant/constant_test.cpp @@ -76,7 +76,7 @@ struct ExecFixture const TensorDimensions &dimensions) { Tensor::UP tensor = createTensor(cells, dimensions); - ValueType type(tensor->getType()); + ValueType type(tensor->type()); test.getIndexEnv().addConstantValue(name, std::move(type), std::move(tensor)); diff --git a/searchlib/src/tests/transactionlog/translogclient_test.cpp b/searchlib/src/tests/transactionlog/translogclient_test.cpp index 9f83db9b23a..861023b79b7 100644 --- a/searchlib/src/tests/transactionlog/translogclient_test.cpp +++ b/searchlib/src/tests/transactionlog/translogclient_test.cpp @@ -43,12 +43,12 @@ private: void checkFilledDomainTest(const TransLogClient::Session::UP &s1, size_t numEntries); bool visitDomainTest(TransLogClient & tls, TransLogClient::Session * s1, const vespalib::string & name); bool partialUpdateTest(); - bool test1(); + bool testVisitOverGeneratedDomain(); bool testRemove(); void createAndFillDomain(const vespalib::string & name, DomainPart::Crc crcMethod, size_t preExistingDomains); void verifyDomain(const vespalib::string & name); void testCrcVersions(); - bool test2(); + bool testVisitOverPreExistingDomain(); void testMany(); void testErase(); void testSync(); @@ -480,7 +480,13 @@ bool Test::visitDomainTest(TransLogClient & tls, TransLogClient::Session * s1, c return retval; } -bool Test::test1() +double +getMaxSessionRunTime(TransLogServer &tls, const vespalib::string &domain) +{ + return tls.getDomainStats()[domain].maxSessionRunTime.count(); +} + +bool Test::testVisitOverGeneratedDomain() { DummyFileHeaderContext fileHeaderContext; TransLogServer tlss("test7", 18377, ".", fileHeaderContext, 0x10000); @@ -490,7 +496,11 @@ bool Test::test1() createDomainTest(tls, name); TransLogClient::Session::UP s1 = openDomainTest(tls, name); fillDomainTest(s1.get(), name); + EXPECT_EQUAL(0, getMaxSessionRunTime(tlss, "test1")); visitDomainTest(tls, s1.get(), name); + double maxSessionRunTime = getMaxSessionRunTime(tlss, "test1"); + LOG(info, "testVisitOverGeneratedDomain(): maxSessionRunTime=%f", maxSessionRunTime); + EXPECT_GREATER(maxSessionRunTime, 0); return true; } @@ -539,8 +549,9 @@ bool Test::testRemove() return true; } -bool Test::test2() +bool Test::testVisitOverPreExistingDomain() { + // Depends on Test::testVisitOverGeneratedDomain() DummyFileHeaderContext fileHeaderContext; TransLogServer tlss("test7", 18377, ".", fileHeaderContext, 0x10000); TransLogClient tls("tcp/localhost:18377"); @@ -868,8 +879,8 @@ int Test::Main() if (_argc > 0) { DummyFileHeaderContext::setCreator(_argv[0]); } - test1(); - test2(); + testVisitOverGeneratedDomain(); + testVisitOverPreExistingDomain(); testMany(); testErase(); partialUpdateTest(); diff --git a/searchlib/src/vespa/searchlib/attribute/attributecontext.cpp b/searchlib/src/vespa/searchlib/attribute/attributecontext.cpp index 770d5c653a3..0a3fe963aae 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributecontext.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributecontext.cpp @@ -43,19 +43,19 @@ AttributeContext::~AttributeContext() { } const IAttributeVector * AttributeContext::getAttribute(const string & name) const { - vespalib::LockGuard guard(_cacheLock); + std::lock_guard<std::mutex> guard(_cacheLock); return getAttribute(_attributes, name, false); } const IAttributeVector * AttributeContext::getAttributeStableEnum(const string & name) const { - vespalib::LockGuard guard(_cacheLock); + std::lock_guard<std::mutex> guard(_cacheLock); return getAttribute(_enumAttributes, name, true); } void AttributeContext::releaseEnumGuards() { - vespalib::LockGuard guard(_cacheLock); + std::lock_guard<std::mutex> guard(_cacheLock); _enumAttributes.clear(); } diff --git a/searchlib/src/vespa/searchlib/attribute/attributecontext.h b/searchlib/src/vespa/searchlib/attribute/attributecontext.h index b7373f343ec..80abe84f8ef 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributecontext.h +++ b/searchlib/src/vespa/searchlib/attribute/attributecontext.h @@ -3,9 +3,9 @@ #pragma once #include <vespa/searchcommon/attribute/iattributecontext.h> -#include <vespa/vespalib/util/sync.h> #include <vespa/vespalib/stllike/hash_map.h> #include "iattributemanager.h" +#include <mutex> namespace search { @@ -21,7 +21,7 @@ private: const search::IAttributeManager & _manager; mutable AttributeMap _attributes; mutable AttributeMap _enumAttributes; - mutable vespalib::Lock _cacheLock; + mutable std::mutex _cacheLock; const attribute::IAttributeVector * getAttribute(AttributeMap & map, const string & name, bool stableEnum) const; diff --git a/searchlib/src/vespa/searchlib/attribute/attributemanager.cpp b/searchlib/src/vespa/searchlib/attribute/attributemanager.cpp index 0122516b767..f10f3491ac0 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributemanager.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributemanager.cpp @@ -12,14 +12,14 @@ #include <vespa/log/log.h> LOG_SETUP(".searchlib.attributemanager"); -using vespalib::LockGuard; using vespalib::string; using vespalib::IllegalStateException; using search::attribute::IAttributeContext; namespace { -vespalib::Monitor baseDirMonitor; +std::mutex baseDirLock; +std::condition_variable baseDirCond; typedef std::set<string> BaseDirSet; BaseDirSet baseDirSet; @@ -27,7 +27,7 @@ static void waitBaseDir(const string &baseDir) { if (baseDir.empty()) { return; } - vespalib::MonitorGuard guard(baseDirMonitor); + std::unique_lock<std::mutex> guard(baseDirLock); bool waited = false; BaseDirSet::iterator it = baseDirSet.find(baseDir); @@ -36,7 +36,7 @@ waitBaseDir(const string &baseDir) waited = true; LOG(debug, "AttributeManager: Waiting for basedir %s to be available", baseDir.c_str()); } - guard.wait(); + baseDirCond.wait(guard); it = baseDirSet.find(baseDir); } @@ -52,7 +52,7 @@ dropBaseDir(const string &baseDir) { if (baseDir.empty()) return; - vespalib::MonitorGuard guard(baseDirMonitor); + std::lock_guard<std::mutex> guard(baseDirLock); BaseDirSet::iterator it = baseDirSet.find(baseDir); if (it == baseDirSet.end()) { @@ -60,7 +60,7 @@ dropBaseDir(const string &baseDir) } else { baseDirSet.erase(it); } - guard.broadcast(); + baseDirCond.notify_all(); } } @@ -147,7 +147,7 @@ AttributeManager::findAndLoadAttribute(const string & name) const if (found != _attributes.end()) { AttributeVector & vec = *found->second; if ( ! vec.isLoaded() ) { - vespalib::LockGuard loadGuard(_loadLock); + std::lock_guard<std::mutex> loadGuard(_loadLock); if ( ! vec.isLoaded() ) { vec.load(); } else { diff --git a/searchlib/src/vespa/searchlib/attribute/attributemanager.h b/searchlib/src/vespa/searchlib/attribute/attributemanager.h index f69d4cb9295..3b23881e3bc 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributemanager.h +++ b/searchlib/src/vespa/searchlib/attribute/attributemanager.h @@ -7,7 +7,7 @@ #include <vespa/searchlib/common/indexmetainfo.h> #include <vespa/searchcommon/attribute/config.h> #include <vespa/vespalib/stllike/hash_map.h> -#include <vespa/vespalib/util/sync.h> +#include <mutex> namespace search { @@ -56,7 +56,7 @@ public: protected: typedef vespalib::hash_map<string, VectorHolder> AttributeMap; AttributeMap _attributes; - vespalib::Lock _loadLock; + mutable std::mutex _loadLock; private: const VectorHolder * findAndLoadAttribute(const string & name) const; string createBaseFileName(const string & name, bool useSnapshot) const; diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h index 13ba3f801b7..b514a5830ba 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.h +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h @@ -19,8 +19,7 @@ #include <vespa/searchlib/queryeval/searchiterator.h> #include <vespa/vespalib/objects/identifiable.h> #include <vespa/vespalib/stllike/asciistream.h> -#include <vespa/vespalib/util/rwlock.h> -#include <vespa/vespalib/util/sync.h> +#include <vespa/fastos/time.h> #include <cmath> #include <mutex> #include <shared_mutex> diff --git a/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp b/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp index 04909da8ea7..a063ed347a4 100644 --- a/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp +++ b/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp @@ -29,7 +29,7 @@ BitVectorCache::computeCountVector(KeySet & keys, CountVector & v) const std::vector<CondensedBitVector::KeySet> keySets; ChunkV chunks; { - vespalib::LockGuard guard(_lock); + std::lock_guard<std::mutex> guard(_lock); keySets.resize(_chunks.size()); Key2Index::const_iterator end(_keys.end()); for (Key k : keys) { @@ -61,7 +61,7 @@ BitVectorCache::KeySet BitVectorCache::lookupCachedSet(const KeyAndCountSet & keys) { KeySet cached(keys.size()*3); - vespalib::LockGuard guard(_lock); + std::lock_guard<std::mutex> guard(_lock); _lookupCount++; if (_lookupCount == 2000) { _needPopulation = true; @@ -101,7 +101,7 @@ BitVectorCache::getSorted(Key2Index & keys) } bool -BitVectorCache::hasCostChanged(const vespalib::LockGuard & guard) +BitVectorCache::hasCostChanged(const std::lock_guard<std::mutex> & guard) { (void) guard; if ( ! _chunks.empty()) { @@ -163,17 +163,17 @@ BitVectorCache::populate(Key2Index & newKeys, CondensedBitVector & chunk, const void BitVectorCache::populate(uint32_t sz, const PopulateInterface & lookup) { - vespalib::LockGuard guard1(_lock); + std::unique_lock<std::mutex> guard(_lock); if (! _needPopulation) { return; } Key2Index newKeys(_keys); - guard1.unlock(); + guard.unlock(); CondensedBitVector::UP chunk(CondensedBitVector::create(sz, _genHolder)); populate(newKeys, *chunk, lookup); - vespalib::LockGuard guard2(_lock); + guard.lock(); _chunks.push_back(std::move(chunk)); _keys.swap(newKeys); _needPopulation = false; @@ -182,7 +182,7 @@ BitVectorCache::populate(uint32_t sz, const PopulateInterface & lookup) void BitVectorCache::set(Key key, uint32_t index, bool v) { - vespalib::LockGuard guard(_lock); + std::lock_guard<std::mutex> guard(_lock); auto found = _keys.find(key); if (found != _keys.end()) { const KeyMeta & m(found->second); @@ -202,7 +202,7 @@ BitVectorCache::get(Key key, uint32_t index) const void BitVectorCache::removeIndex(uint32_t index) { - vespalib::LockGuard guard(_lock); + std::lock_guard<std::mutex> guard(_lock); for (auto & chunk : _chunks) { chunk->clearIndex(index); } diff --git a/searchlib/src/vespa/searchlib/common/bitvectorcache.h b/searchlib/src/vespa/searchlib/common/bitvectorcache.h index 0d27701e1e1..c1415d9130f 100644 --- a/searchlib/src/vespa/searchlib/common/bitvectorcache.h +++ b/searchlib/src/vespa/searchlib/common/bitvectorcache.h @@ -2,9 +2,9 @@ #pragma once #include "condensedbitvectors.h" -#include <vespa/vespalib/util/sync.h> #include <vespa/vespalib/stllike/hash_set.h> #include <vespa/fastos/dynamiclibrary.h> +#include <mutex> namespace search { @@ -74,11 +74,11 @@ private: VESPA_DLL_LOCAL static SortedKeyMeta getSorted(Key2Index & keys); VESPA_DLL_LOCAL static void populate(Key2Index & newKeys, CondensedBitVector & chunk, const PopulateInterface & lookup); - VESPA_DLL_LOCAL bool hasCostChanged(const vespalib::LockGuard &); + VESPA_DLL_LOCAL bool hasCostChanged(const std::lock_guard<std::mutex> &); uint64_t _lookupCount; bool _needPopulation; - vespalib::Lock _lock; + mutable std::mutex _lock; Key2Index _keys; ChunkV _chunks; GenerationHolder &_genHolder; diff --git a/searchlib/src/vespa/searchlib/common/gatecallback.cpp b/searchlib/src/vespa/searchlib/common/gatecallback.cpp index a853909be71..29346d7ad9c 100644 --- a/searchlib/src/vespa/searchlib/common/gatecallback.cpp +++ b/searchlib/src/vespa/searchlib/common/gatecallback.cpp @@ -1,7 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "gatecallback.h" -#include <vespa/vespalib/util/sync.h> +#include <vespa/vespalib/util/gate.h> namespace search { diff --git a/searchlib/src/vespa/searchlib/common/sortspec.cpp b/searchlib/src/vespa/searchlib/common/sortspec.cpp index f43596f9c7f..694443b00ba 100644 --- a/searchlib/src/vespa/searchlib/common/sortspec.cpp +++ b/searchlib/src/vespa/searchlib/common/sortspec.cpp @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "sortspec.h" #include <vespa/vespalib/util/stringfmt.h> -#include <vespa/vespalib/util/sync.h> #include <vespa/fastlib/text/normwordfolder.h> #include <vespa/vespalib/text/utf8.h> diff --git a/searchlib/src/vespa/searchlib/features/queryfeature.cpp b/searchlib/src/vespa/searchlib/features/queryfeature.cpp index 271861d472c..3e52546e841 100644 --- a/searchlib/src/vespa/searchlib/features/queryfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/queryfeature.cpp @@ -122,7 +122,7 @@ createTensorExecutor(const search::fef::IQueryEnvironment &env, const vespalib::string &value = prop.get(); vespalib::nbostream stream(value.data(), value.size()); vespalib::tensor::Tensor::UP tensor = vespalib::tensor::TypedBinaryFormat::deserialize(stream); - if (tensor->getType() != valueType) { + if (tensor->type() != valueType) { vespalib::tensor::TensorMapper mapper(valueType); vespalib::tensor::Tensor::UP mappedTensor = mapper.map(*tensor); tensor = std::move(mappedTensor); diff --git a/searchlib/src/vespa/searchlib/transactionlog/domain.cpp b/searchlib/src/vespa/searchlib/transactionlog/domain.cpp index 74ca3e6527d..03785258f28 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/domain.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/domain.cpp @@ -36,6 +36,7 @@ Domain::Domain(const string &domainName, const string & baseDir, Executor & comm _lock(), _sessionLock(), _sessions(), + _maxSessionRunTime(), _baseDir(baseDir), _fileHeaderContext(fileHeaderContext), _markedDeleted(false) @@ -105,7 +106,7 @@ DomainInfo Domain::getDomainInfo() const { LockGuard guard(_lock); - DomainInfo info(SerialNumRange(begin(guard), end(guard)), size(guard), byteSize(guard)); + DomainInfo info(SerialNumRange(begin(guard), end(guard)), size(guard), byteSize(guard), _maxSessionRunTime); for (const auto &entry: _parts) { const DomainPart &part = *entry.second; info.parts.emplace_back(PartInfo(part.range(), part.size(), part.byteSize(), part.fileName())); @@ -332,6 +333,7 @@ int Domain::startSession(int sessionId) LockGuard guard(_sessionLock); SessionList::iterator found = _sessions.find(sessionId); if (found != _sessions.end()) { + found->second->setStartTime(std::chrono::steady_clock::now()); if ( execute(Session::createTask(found->second)).get() == nullptr ) { retval = 0; } else { @@ -345,10 +347,12 @@ int Domain::closeSession(int sessionId) { _commitExecutor.sync(); int retval(-1); + DurationSeconds sessionRunTime(0); { LockGuard guard(_sessionLock); SessionList::iterator found = _sessions.find(sessionId); if (found != _sessions.end()) { + sessionRunTime = (std::chrono::steady_clock::now() - found->second->getStartTime()); retval = 1; _sessionExecutor.sync(); } @@ -364,6 +368,12 @@ int Domain::closeSession(int sessionId) retval = 0; } } + { + LockGuard guard(_lock); + if (sessionRunTime > _maxSessionRunTime) { + _maxSessionRunTime = sessionRunTime; + } + } return retval; } diff --git a/searchlib/src/vespa/searchlib/transactionlog/domain.h b/searchlib/src/vespa/searchlib/transactionlog/domain.h index ab7ded91e5b..c1ff9157a6f 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/domain.h +++ b/searchlib/src/vespa/searchlib/transactionlog/domain.h @@ -4,6 +4,7 @@ #include "domainpart.h" #include "session.h" #include <vespa/vespalib/util/threadexecutor.h> +#include <chrono> namespace search::transactionlog { @@ -20,14 +21,16 @@ struct PartInfo { }; struct DomainInfo { + using DurationSeconds = std::chrono::duration<double>; SerialNumRange range; size_t numEntries; size_t byteSize; + DurationSeconds maxSessionRunTime; std::vector<PartInfo> parts; - DomainInfo(SerialNumRange range_in, size_t numEntries_in, size_t byteSize_in) - : range(range_in), numEntries(numEntries_in), byteSize(byteSize_in), parts() {} + DomainInfo(SerialNumRange range_in, size_t numEntries_in, size_t byteSize_in, DurationSeconds maxSessionRunTime_in) + : range(range_in), numEntries(numEntries_in), byteSize(byteSize_in), maxSessionRunTime(maxSessionRunTime_in), parts() {} DomainInfo() - : range(), numEntries(0), byteSize(0), parts() {} + : range(), numEntries(0), byteSize(0), maxSessionRunTime(), parts() {} }; typedef std::map<vespalib::string, DomainInfo> DomainStats; @@ -74,6 +77,7 @@ public: return _sessionExecutor.execute(std::move(task)); } uint64_t size() const; + private: SerialNum begin(const vespalib::LockGuard & guard) const; SerialNum end(const vespalib::LockGuard & guard) const; @@ -89,6 +93,7 @@ private: using SessionList = std::map<int, Session::SP>; using DomainPartList = std::map<int64_t, DomainPart::SP>; + using DurationSeconds = std::chrono::duration<double>; DomainPart::Crc _defaultCrcType; Executor & _commitExecutor; @@ -102,6 +107,7 @@ private: vespalib::Lock _lock; vespalib::Lock _sessionLock; SessionList _sessions; + DurationSeconds _maxSessionRunTime; vespalib::string _baseDir; const common::FileHeaderContext &_fileHeaderContext; bool _markedDeleted; diff --git a/searchlib/src/vespa/searchlib/transactionlog/session.cpp b/searchlib/src/vespa/searchlib/transactionlog/session.cpp index 3ea656be9a2..6f0ab998e26 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/session.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/session.cpp @@ -197,7 +197,9 @@ Session::Session(int sId, const SerialNumRange & r, const Domain::SP & d, _inSync(false), _ok(true), _finished(false), - _packetQ() + _packetQ(), + _startTime(), + _lock() { _connection->AddRef(); } diff --git a/searchlib/src/vespa/searchlib/transactionlog/session.h b/searchlib/src/vespa/searchlib/transactionlog/session.h index ac6f496e151..c42d6839dfa 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/session.h +++ b/searchlib/src/vespa/searchlib/transactionlog/session.h @@ -5,6 +5,7 @@ #include <vespa/vespalib/util/executor.h> #include <vespa/vespalib/util/sync.h> #include <vespa/fnet/frt/invoker.h> +#include <chrono> #include <deque> class FastOS_FileInterface; @@ -18,7 +19,8 @@ using DomainSP = std::shared_ptr<Domain>; class Session : public FRT_IRequestWait { private: - typedef vespalib::Executor::Task Task; + using Task = vespalib::Executor::Task; + using time_point = std::chrono::time_point<std::chrono::steady_clock>; public: typedef std::shared_ptr<Session> SP; @@ -33,6 +35,8 @@ public: bool finished() const; static void enQ(const SP & session, SerialNum serial, const Packet & packet); static Task::UP createTask(const Session::SP & session); + void setStartTime(time_point startTime) { _startTime = startTime; } + time_point getStartTime() const { return _startTime; } private: struct QPacket { QPacket() : _serial(0), _packet() {} @@ -79,6 +83,7 @@ private: bool _ok; bool _finished; std::deque<QPacket> _packetQ; + time_point _startTime; vespalib::Lock _lock; }; diff --git a/searchlib/src/vespa/searchlib/uca/ucaconverter.cpp b/searchlib/src/vespa/searchlib/uca/ucaconverter.cpp index db16d165cec..47d66a94d9e 100644 --- a/searchlib/src/vespa/searchlib/uca/ucaconverter.cpp +++ b/searchlib/src/vespa/searchlib/uca/ucaconverter.cpp @@ -2,8 +2,8 @@ #include "ucaconverter.h" #include <vespa/vespalib/util/stringfmt.h> -#include <vespa/vespalib/util/sync.h> #include <vespa/vespalib/text/utf8.h> +#include <mutex> #include <vespa/log/log.h> LOG_SETUP(".search.common.sortspec"); @@ -14,7 +14,7 @@ using vespalib::ConstBufferRef; using vespalib::make_string; namespace { - vespalib::Lock _GlobalDirtyICUThreadSafeLock; +std::mutex _GlobalDirtyICUThreadSafeLock; } BlobConverter::UP @@ -30,7 +30,7 @@ UcaConverter::UcaConverter(vespalib::stringref locale, vespalib::stringref stren UErrorCode status = U_ZERO_ERROR; Collator *coll(NULL); { - vespalib::LockGuard guard(_GlobalDirtyICUThreadSafeLock); + std::lock_guard<std::mutex> guard(_GlobalDirtyICUThreadSafeLock); coll = Collator::createInstance(icu::Locale(locale.c_str()), status); } if(U_SUCCESS(status)) { diff --git a/searchlib/src/vespa/searchlib/util/runnable.h b/searchlib/src/vespa/searchlib/util/runnable.h index a8dc8e56856..a95d4d68368 100644 --- a/searchlib/src/vespa/searchlib/util/runnable.h +++ b/searchlib/src/vespa/searchlib/util/runnable.h @@ -2,37 +2,39 @@ #pragma once -#include <vespa/vespalib/util/sync.h> +#include <mutex> +#include <condition_variable> namespace search { class Runnable : public FastOS_Runnable { protected: - vespalib::Monitor _cond; - bool _done; - bool _stopped; + std::mutex _lock; + std::condition_variable _cond; + bool _done; + bool _stopped; public: Runnable() : - _cond(), _done(false), _stopped(false) + _lock(), _cond(), _done(false), _stopped(false) { } - void Run(FastOS_ThreadInterface *, void *) override{ + void Run(FastOS_ThreadInterface *, void *) override { doRun(); - vespalib::MonitorGuard guard(_cond); + std::lock_guard<std::mutex> guard(_lock); _stopped = true; - guard.broadcast(); + _cond.notify_all(); } virtual void doRun() = 0; void stop() { - vespalib::MonitorGuard guard(_cond); + std::lock_guard<std::mutex> guard(_lock); _done = true; } void join() { - vespalib::MonitorGuard guard(_cond); + std::unique_lock<std::mutex> guard(_lock); while (!_stopped) { - guard.wait(); + _cond.wait(guard); } } }; |