diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-12-04 07:23:36 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-04 07:23:36 -0800 |
commit | d3c4029c7e91362b50e4fcb2e4eaa9d8c851d6d5 (patch) | |
tree | 9fed2a925c667bd793f2aad282d2b963fc62ce63 /searchcore | |
parent | d3002ae703705198940203f48ba915d14bb948c4 (diff) | |
parent | 887fe94ff98ae308f7dcb39ad3f6e299b15d2bab (diff) |
Merge pull request #11479 from vespa-engine/balder/do-not-let-external-softtimeout-factor-affect-auto-tuning-rebased-2
Wrap soft and hard doom in an CombinedDoom.
Diffstat (limited to 'searchcore')
14 files changed, 90 insertions, 95 deletions
diff --git a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp index b519e6a8dc7..839228b79b8 100644 --- a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp @@ -24,6 +24,7 @@ #include <vespa/searchlib/attribute/attributefactory.h> #include <vespa/document/update/documentupdate.h> #include <vespa/searchlib/index/docbuilder.h> +#include <vespa/vespalib/util/time.h> #include <vespa/log/log.h> LOG_SETUP("feedview_test"); @@ -524,7 +525,7 @@ struct FixtureBase CommitTimeTracker _commitTimeTracker; SerialNum serial; std::shared_ptr<MyGidToLidChangeHandler> _gidToLidChangeHandler; - FixtureBase(TimeStamp visibilityDelay); + FixtureBase(vespalib::duration visibilityDelay); virtual ~FixtureBase(); @@ -689,7 +690,7 @@ struct FixtureBase }; -FixtureBase::FixtureBase(TimeStamp visibilityDelay) +FixtureBase::FixtureBase(vespalib::duration visibilityDelay) : _tracer(), sc(), iw(new MyIndexWriter(_tracer)), @@ -706,12 +707,12 @@ FixtureBase::FixtureBase(TimeStamp visibilityDelay) _writeServiceReal(_sharedExecutor), _writeService(_writeServiceReal), _lidReuseDelayer(_writeService, _dmsc->get()), - _commitTimeTracker(visibilityDelay), + _commitTimeTracker(vespalib::count_ns(visibilityDelay)), serial(0), _gidToLidChangeHandler(std::make_shared<MyGidToLidChangeHandler>()) { _dmsc->constructFreeList(); - _lidReuseDelayer.setImmediateCommit(visibilityDelay == 0); + _lidReuseDelayer.setImmediateCommit(visibilityDelay == vespalib::duration::zero()); } FixtureBase::~FixtureBase() { @@ -728,7 +729,7 @@ FixtureBase::populateBeforeCompactLidSpace() struct SearchableFeedViewFixture : public FixtureBase { SearchableFeedView fv; - SearchableFeedViewFixture(TimeStamp visibilityDelay = 0) : + SearchableFeedViewFixture(vespalib::duration visibilityDelay = 0ms) : FixtureBase(visibilityDelay), fv(StoreOnlyFeedView::Context(sa, sc._schema, @@ -750,7 +751,7 @@ struct SearchableFeedViewFixture : public FixtureBase struct FastAccessFeedViewFixture : public FixtureBase { FastAccessFeedView fv; - FastAccessFeedViewFixture(TimeStamp visibilityDelay = 0) : + FastAccessFeedViewFixture(vespalib::duration visibilityDelay = vespalib::duration::zero()) : FixtureBase(visibilityDelay), fv(StoreOnlyFeedView::Context(sa, sc._schema, @@ -1206,8 +1207,8 @@ TEST_F("require that commit is called if visibility delay is 0", "ack(Result(0, ))"); } -const TimeStamp LONG_DELAY(TimeStamp::Seconds(60.0)); -const TimeStamp SHORT_DELAY(TimeStamp::Seconds(0.5)); +const vespalib::duration LONG_DELAY = 60s; +const vespalib::duration SHORT_DELAY = 500ms; TEST_F("require that commit is not called when inside a commit interval", SearchableFeedViewFixture(LONG_DELAY)) @@ -1232,13 +1233,13 @@ TEST_F("require that commit is not called when inside a commit interval", TEST_F("require that commit is called when crossing a commit interval", SearchableFeedViewFixture(SHORT_DELAY)) { - FastOS_Thread::Sleep(SHORT_DELAY.ms() + 100); + std::this_thread::sleep_for(SHORT_DELAY + 100ms); DocumentContext dc = f.doc1(); f.putAndWait(dc); EXPECT_EQUAL(1u, f.miw._commitCount); EXPECT_EQUAL(1u, f.maw._commitCount); EXPECT_EQUAL(2u, f._docIdLimit.get()); - FastOS_Thread::Sleep(SHORT_DELAY.ms() + 100); + std::this_thread::sleep_for(SHORT_DELAY + 100ms); f.removeAndWait(dc); EXPECT_EQUAL(2u, f.miw._commitCount); EXPECT_EQUAL(2u, f.maw._commitCount); @@ -1257,13 +1258,13 @@ TEST_F("require that commit is not implicitly called after handover to maintenan SearchableFeedViewFixture(SHORT_DELAY)) { f._commitTimeTracker.setReplayDone(); - FastOS_Thread::Sleep(SHORT_DELAY.ms() + 100); + std::this_thread::sleep_for(SHORT_DELAY + 100ms); DocumentContext dc = f.doc1(); f.putAndWait(dc); EXPECT_EQUAL(0u, f.miw._commitCount); EXPECT_EQUAL(0u, f.maw._commitCount); EXPECT_EQUAL(0u, f._docIdLimit.get()); - FastOS_Thread::Sleep(SHORT_DELAY.ms() + 100); + std::this_thread::sleep_for(SHORT_DELAY + 100ms); f.removeAndWait(dc); EXPECT_EQUAL(0u, f.miw._commitCount); EXPECT_EQUAL(0u, f.maw._commitCount); diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp index c732da58dd7..fdd53d629ad 100644 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp +++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp @@ -34,6 +34,7 @@ #include <vespa/vespalib/util/closuretask.h> #include <vespa/vespalib/util/gate.h> #include <vespa/vespalib/util/threadstackexecutor.h> +#include <vespa/fastos/thread.h> #include <unistd.h> #include <vespa/log/log.h> @@ -785,9 +786,7 @@ MyExecutor::MyExecutor() } -MyExecutor::~MyExecutor() -{ -} +MyExecutor::~MyExecutor() = default; bool diff --git a/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp b/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp index be70bacb4b1..3152b737ea7 100644 --- a/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp +++ b/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp @@ -26,12 +26,12 @@ public: class RequestContextTest : public ::testing::Test { private: - vespalib::Clock _clock; - vespalib::Doom _doom; - MyAttributeContext _attr_ctx; - Properties _props; - RequestContext _request_ctx; - Value::UP _query_tensor; + vespalib::Clock _clock; + vespalib::Doom _doom; + MyAttributeContext _attr_ctx; + Properties _props; + RequestContext _request_ctx; + Value::UP _query_tensor; void insert_tensor_in_properties(const vespalib::string& tensor_name, const Value& tensor_value) { vespalib::nbostream stream; @@ -42,7 +42,7 @@ private: public: RequestContextTest() : _clock(), - _doom(_clock, fastos::SteadyTimeStamp()), + _doom(_clock, fastos::SteadyTimeStamp::ZERO, fastos::SteadyTimeStamp::ZERO, false), _attr_ctx(), _props(), _request_ctx(_doom, _attr_ctx, _props), diff --git a/searchcore/src/vespa/searchcore/proton/matching/fakesearchcontext.h b/searchcore/src/vespa/searchcore/proton/matching/fakesearchcontext.h index fe9c20112f4..5a4ccc892b3 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/fakesearchcontext.h +++ b/searchcore/src/vespa/searchcore/proton/matching/fakesearchcontext.h @@ -6,6 +6,7 @@ #include <vespa/searchcorespi/index/fakeindexsearchable.h> #include <vespa/searchcorespi/index/indexcollection.h> #include <vespa/searchlib/attribute/fixedsourceselector.h> +#include <vespa/vespalib/util/doom.h> #include <algorithm> #include <map> #include <vector> diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp index afdae5eec2e..a0381af29a8 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp @@ -71,15 +71,14 @@ LazyValue get_score_feature(const RankProgram &rankProgram) { //----------------------------------------------------------------------------- -MatchThread::Context::Context(double rankDropLimit, MatchTools &tools, HitCollector &hits, - uint32_t num_threads) +MatchThread::Context::Context(double rankDropLimit, MatchTools &tools, HitCollector &hits, uint32_t num_threads) : matches(0), _matches_limit(tools.match_limiter().sample_hits_per_thread(num_threads)), _score_feature(get_score_feature(tools.rank_program())), _ranking(tools.rank_program()), _rankDropLimit(rankDropLimit), _hits(hits), - _softDoom(tools.getSoftDoom()) + _doom(tools.getDoom()) { } @@ -307,7 +306,7 @@ MatchThread::findMatches(MatchTools &tools) auto kept_hits = communicator.selectBest(sorted_hit_seq); select_best_timer.done(); DocumentScorer scorer(tools.rank_program(), tools.search()); - if (tools.getHardDoom().doom()) { + if (tools.getDoom().hard_doom()) { kept_hits.clear(); } uint32_t reRanked = hits.reRank(scorer, std::move(kept_hits)); @@ -330,16 +329,16 @@ MatchThread::findMatches(MatchTools &tools) } void -MatchThread::processResult(const Doom & hardDoom, +MatchThread::processResult(const Doom & doom, search::ResultSet::UP result, ResultProcessor::Context &context) { - if (hardDoom.doom()) return; + if (doom.hard_doom()) return; bool hasGrouping = (context.grouping.get() != 0); if (context.sort->hasSortData() || hasGrouping) { result->mergeWithBitOverflow(fallback_rank_value()); } - if (hardDoom.doom()) return; + if (doom.hard_doom()) return; size_t totalHits = result->getNumHits(); const search::RankedHit *hits = result->getArray(); size_t numHits = result->getArrayUsed(); @@ -347,20 +346,20 @@ MatchThread::processResult(const Doom & hardDoom, if (bits != nullptr && hits != nullptr) { bits->andNotWithT(search::RankedHitIterator(hits, numHits)); } - if (hardDoom.doom()) return; + if (doom.hard_doom()) return; if (hasGrouping) { search::grouping::GroupingManager man(*context.grouping); man.groupUnordered(hits, numHits, bits); } - if (hardDoom.doom()) return; + if (doom.hard_doom()) return; size_t sortLimit = hasGrouping ? numHits : context.result->maxSize(); result->sort(*context.sort->sorter, sortLimit); - if (hardDoom.doom()) return; + if (doom.hard_doom()) return; if (hasGrouping) { search::grouping::GroupingManager man(*context.grouping); man.groupInRelevanceOrder(hits, numHits); } - if (hardDoom.doom()) return; + if (doom.hard_doom()) return; PartialResult &pr = *context.result; pr.totalHits(totalHits); size_t maxHits = std::min(numHits, pr.maxSize()); @@ -432,19 +431,19 @@ MatchThread::run() MatchTools::UP matchTools = matchToolsFactory.createMatchTools(); search::ResultSet::UP result = findMatches(*matchTools); match_time_s = match_time.elapsed().sec(); - resultContext = resultProcessor.createThreadContext(matchTools->getHardDoom(), thread_id, _distributionKey); + resultContext = resultProcessor.createThreadContext(matchTools->getDoom(), thread_id, _distributionKey); { trace->addEvent(5, "Wait for result processing token"); WaitTimer get_token_timer(wait_time_s); QueryLimiter::Token::UP processToken( - matchTools->getQueryLimiter().getToken(matchTools->getHardDoom(), + matchTools->getQueryLimiter().getToken(matchTools->getDoom(), scheduler.total_size(thread_id), result->getNumHits(), resultContext->sort->hasSortData(), resultContext->grouping.get() != 0)); get_token_timer.done(); trace->addEvent(5, "Start result processing"); - processResult(matchTools->getHardDoom(), std::move(result), *resultContext); + processResult(matchTools->getDoom(), std::move(result), *resultContext); } total_time_s = total_time.elapsed().sec(); thread_stats.active_time(total_time_s - wait_time_s).wait_time(wait_time_s); diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.h b/searchcore/src/vespa/searchcore/proton/matching/match_thread.h index dca77f35019..7ecbfef634e 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.h +++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.h @@ -73,16 +73,16 @@ private: void addHit(uint32_t docId) { _hits.addHit(docId, search::zero_rank_value); } bool isBelowLimit() const { return matches < _matches_limit; } bool isAtLimit() const { return matches == _matches_limit; } - bool atSoftDoom() const { return _softDoom.doom(); } - fastos::TimeStamp timeLeft() const { return _softDoom.left(); } - uint32_t matches; + bool atSoftDoom() const { return _doom.soft_doom(); } + fastos::TimeStamp timeLeft() const { return _doom.soft_left(); } + uint32_t matches; private: - uint32_t _matches_limit; - LazyValue _score_feature; - RankProgram &_ranking; - double _rankDropLimit; - HitCollector &_hits; - const Doom &_softDoom; + uint32_t _matches_limit; + LazyValue _score_feature; + RankProgram &_ranking; + double _rankDropLimit; + HitCollector &_hits; + const Doom &_doom; }; double estimate_match_frequency(uint32_t matches, uint32_t searchedSoFar) __attribute__((noinline)); @@ -106,7 +106,7 @@ private: search::ResultSet::UP findMatches(MatchTools &tools); - void processResult(const Doom & hardDoom, search::ResultSet::UP result, ResultProcessor::Context &context); + void processResult(const Doom & doom, search::ResultSet::UP result, ResultProcessor::Context &context); bool isFirstThread() const { return thread_id == 0; } diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp index 67c1fb25b64..05b70cfb8bf 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp @@ -89,8 +89,7 @@ MatchTools::setup(search::fef::RankProgram::UP rank_program, double termwise_lim } MatchTools::MatchTools(QueryLimiter & queryLimiter, - const vespalib::Doom & softDoom, - const vespalib::Doom & hardDoom, + const vespalib::Doom & doom, const Query &query, MaybeMatchPhaseLimiter & match_limiter_in, const QueryEnvironment & queryEnv, @@ -98,8 +97,7 @@ MatchTools::MatchTools(QueryLimiter & queryLimiter, const RankSetup & rankSetup, const Properties & featureOverrides) : _queryLimiter(queryLimiter), - _softDoom(softDoom), - _hardDoom(hardDoom), + _doom(doom), _query(query), _match_limiter(match_limiter_in), _queryEnv(queryEnv), @@ -149,8 +147,7 @@ MatchTools::setup_dump() MatchToolsFactory:: MatchToolsFactory(QueryLimiter & queryLimiter, - const vespalib::Doom & softDoom, - const vespalib::Doom & hardDoom, + const vespalib::Doom & doom, ISearchContext & searchContext, IAttributeContext & attributeContext, vespalib::stringref queryStack, @@ -162,8 +159,7 @@ MatchToolsFactory(QueryLimiter & queryLimiter, const Properties & rankProperties, const Properties & featureOverrides) : _queryLimiter(queryLimiter), - _requestContext(softDoom, attributeContext, rankProperties), - _hardDoom(hardDoom), + _requestContext(doom, attributeContext, rankProperties), _query(), _match_limiter(), _queryEnv(indexEnv, attributeContext, rankProperties, searchContext.getIndexes()), @@ -204,7 +200,7 @@ MatchTools::UP MatchToolsFactory::createMatchTools() const { assert(_valid); - return std::make_unique<MatchTools>(_queryLimiter, _requestContext.getSoftDoom(), _hardDoom, _query, + return std::make_unique<MatchTools>(_queryLimiter, _requestContext.getDoom(), _query, *_match_limiter, _queryEnv, _mdl, _rankSetup, _featureOverrides); } diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.h b/searchcore/src/vespa/searchcore/proton/matching/match_tools.h index 777652c6b89..5cf2919198a 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.h +++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.h @@ -28,8 +28,7 @@ class MatchTools private: using IRequestContext = search::queryeval::IRequestContext; QueryLimiter &_queryLimiter; - const vespalib::Doom &_softDoom; - const vespalib::Doom &_hardDoom; + const vespalib::Doom &_doom; const Query &_query; MaybeMatchPhaseLimiter &_match_limiter; const QueryEnvironment &_queryEnv; @@ -46,8 +45,7 @@ public: MatchTools(const MatchTools &) = delete; MatchTools & operator = (const MatchTools &) = delete; MatchTools(QueryLimiter & queryLimiter, - const vespalib::Doom & softDoom, - const vespalib::Doom & hardDoom, + const vespalib::Doom & doom, const Query &query, MaybeMatchPhaseLimiter &match_limiter_in, const QueryEnvironment &queryEnv, @@ -55,8 +53,7 @@ public: const search::fef::RankSetup &rankSetup, const search::fef::Properties &featureOverrides); ~MatchTools(); - const vespalib::Doom &getSoftDoom() const { return _softDoom; } - const vespalib::Doom &getHardDoom() const { return _hardDoom; } + const vespalib::Doom &getDoom() const { return _doom; } QueryLimiter & getQueryLimiter() { return _queryLimiter; } MaybeMatchPhaseLimiter &match_limiter() { return _match_limiter; } bool has_second_phase_rank() const; @@ -87,13 +84,12 @@ private: vespalib::string _operation; }; -class MatchToolsFactory : public vespalib::noncopyable +class MatchToolsFactory { private: using IAttributeFunctor = search::attribute::IAttributeFunctor; QueryLimiter & _queryLimiter; RequestContext _requestContext; - const vespalib::Doom _hardDoom; Query _query; MaybeMatchPhaseLimiter::UP _match_limiter; QueryEnvironment _queryEnv; @@ -111,7 +107,6 @@ public: MatchToolsFactory(QueryLimiter & queryLimiter, const vespalib::Doom & softDoom, - const vespalib::Doom & hardDoom, ISearchContext &searchContext, search::attribute::IAttributeContext &attributeContext, vespalib::stringref queryStack, @@ -135,6 +130,7 @@ public: std::unique_ptr<AttributeOperationTask> createOnSummaryTask() const; const Query & query() const { return _query; } + const RequestContext & getRequestContext() const { return _requestContext; } }; } diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp index 2764bfb96df..426bb353826 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp @@ -128,19 +128,22 @@ Matcher::create_match_tools_factory(const search::engine::Request &request, ISea { const Properties & rankProperties = request.propertiesMap.rankProperties(); bool softTimeoutEnabled = Enabled::lookup(rankProperties, _rankSetup->getSoftTimeoutEnabled()); + bool hasFactorOverride = Factor::isPresent(rankProperties); double factor = softTimeoutEnabled - ? Factor::lookup(rankProperties, _stats.softDoomFactor()) + ? ( hasFactorOverride + ? Factor::lookup(rankProperties, _stats.softDoomFactor()) + : _stats.softDoomFactor()) : 0.95; int64_t safeLeft = request.getTimeLeft() * factor; fastos::SteadyTimeStamp safeDoom(_clock.getTimeNSAssumeRunning() + safeLeft); if (softTimeoutEnabled) { - LOG(debug, "Soft-timeout computed factor=%1.3f, used factor=%1.3f, softTimeout=%" PRId64, - _stats.softDoomFactor(), factor, safeLeft); + LOG(debug, "Soft-timeout computed factor=%1.3f, used factor=%1.3f, userSupplied=%d, softTimeout=%" PRId64, + _stats.softDoomFactor(), factor, hasFactorOverride, safeLeft); } - return std::make_unique<MatchToolsFactory>(_queryLimiter, vespalib::Doom(_clock, safeDoom), - vespalib::Doom(_clock, request.getTimeOfDoom()), searchContext, - attrContext, request.getStackRef(), request.location, _viewResolver, - metaStore, _indexEnv, *_rankSetup, rankProperties, feature_overrides); + vespalib::Doom doom(_clock, safeDoom, request.getTimeOfDoom(), hasFactorOverride); + return std::make_unique<MatchToolsFactory>(_queryLimiter, doom, searchContext, attrContext, request.getStackRef(), + request.location, _viewResolver, metaStore, _indexEnv, *_rankSetup, + rankProperties, feature_overrides); } SearchReply::UP @@ -187,6 +190,7 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl SearchReply::UP reply = std::make_unique<SearchReply>(); size_t covered = 0; uint32_t numActiveLids = 0; + bool isDoomExplicit = false; { // we want to measure full set-up and tear-down time as part of // collateral time GroupingContext groupingContext(_clock, request.getTimeOfDoom(), @@ -212,6 +216,7 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl } MatchToolsFactory::UP mtf = create_match_tools_factory(request, searchContext, attrContext, metaStore, *feature_overrides); + isDoomExplicit = mtf->getRequestContext().getDoom().isExplicitSoftDoom(); traceQuery(6, request.trace(), mtf->query()); if (!mtf->valid()) { return reply; @@ -288,19 +293,21 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl _stats.add(my_stats); if (my_stats.softDoomed()) { double old = _stats.softDoomFactor(); - fastos::TimeStamp softLimit = (1.0 - _rankSetup->getSoftTimeoutTailCost()) * request.getTimeout(); + fastos::TimeStamp overtimeLimit = (1.0 - _rankSetup->getSoftTimeoutTailCost()) * request.getTimeout(); fastos::TimeStamp adjustedDuration = duration - my_stats.doomOvertime(); if (adjustedDuration < 0) { adjustedDuration = 0; } - bool allowedSoftTimeoutFactorAdjustment = (std::chrono::duration_cast<std::chrono::seconds>(my_clock::now() - _startTime).count() > SECONDS_BEFORE_ALLOWING_SOFT_TIMEOUT_FACTOR_ADJUSTMENT); + bool allowedSoftTimeoutFactorAdjustment = (std::chrono::duration_cast<std::chrono::seconds>(my_clock::now() - _startTime).count() > SECONDS_BEFORE_ALLOWING_SOFT_TIMEOUT_FACTOR_ADJUSTMENT) + && ! isDoomExplicit; if (allowedSoftTimeoutFactorAdjustment) { - _stats.updatesoftDoomFactor(request.getTimeout(), softLimit, adjustedDuration); + _stats.updatesoftDoomFactor(request.getTimeout(), overtimeLimit, adjustedDuration); } - LOG(info, "Triggered softtimeout factor adjustment. Coverage = %lu of %u documents. request=%1.3f, doomOvertime=%1.3f, limit=%1.3f and duration=%1.3f, rankprofile=%s" + LOG(info, "Triggered softtimeout %s. Coverage = %lu of %u documents. request=%1.3f, doomOvertime=%1.3f, overtime_limit=%1.3f and duration=%1.3f, rankprofile=%s" ", factor %sadjusted from %1.3f to %1.3f", + isDoomExplicit ? "with query override" : "factor adjustment", covered, numActiveLids, - request.getTimeout().sec(), my_stats.doomOvertime().sec(), softLimit.sec(), duration.sec(), + request.getTimeout().sec(), my_stats.doomOvertime().sec(), overtimeLimit.sec(), duration.sec(), request.ranking.c_str(), (allowedSoftTimeoutFactorAdjustment ? "" : "NOT "), old, _stats.softDoomFactor()); } } diff --git a/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp b/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp index 0d985496d41..5053cc5fdbe 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp @@ -2,8 +2,7 @@ #include "querylimiter.h" #include <chrono> -namespace proton { -namespace matching { +namespace proton:: matching { QueryLimiter::LimitedToken::LimitedToken(const Doom & doom, QueryLimiter & limiter) : _limiter(limiter) @@ -20,8 +19,8 @@ void QueryLimiter::grabToken(const Doom & doom) { std::unique_lock<std::mutex> guard(_lock); - while ((_maxThreads > 0) && (_activeThreads >= _maxThreads) && !doom.doom()) { - int left = doom.left().ms(); + while ((_maxThreads > 0) && (_activeThreads >= _maxThreads) && !doom.hard_doom()) { + int left = doom.hard_left().ms(); if (left > 0) { _cond.wait_for(guard, std::chrono::milliseconds(left)); } @@ -62,13 +61,12 @@ QueryLimiter::getToken(const Doom & doom, uint32_t numDocs, uint32_t numHits, bo if (hasSorting || hasGrouping) { if (numHits > _minHits) { if (numDocs * _coverage < numHits) { - return Token::UP(new LimitedToken(doom, *this)); + return std::make_unique<LimitedToken>(doom, *this); } } } } - return Token::UP(new NoLimitToken()); + return std::make_unique<NoLimitToken>(); } } -} diff --git a/searchcore/src/vespa/searchcore/proton/matching/querylimiter.h b/searchcore/src/vespa/searchcore/proton/matching/querylimiter.h index fbe8526b051..45783959957 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/querylimiter.h +++ b/searchcore/src/vespa/searchcore/proton/matching/querylimiter.h @@ -7,8 +7,7 @@ #include <mutex> #include <condition_variable> -namespace proton { -namespace matching { +namespace proton::matching { class QueryLimiter { @@ -46,6 +45,4 @@ private: volatile uint32_t _minHits; }; -} // namespace matching -} // namespace proton - +} diff --git a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp index 918e4a14649..c30854c051f 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.cpp @@ -14,9 +14,9 @@ namespace proton { using search::attribute::IAttributeVector; -RequestContext::RequestContext(const Doom & softDoom, IAttributeContext & attributeContext, +RequestContext::RequestContext(const Doom & doom, IAttributeContext & attributeContext, const search::fef::Properties& rank_properties) - : _softDoom(softDoom), + : _doom(doom), _attributeContext(attributeContext), _rank_properties(rank_properties) { diff --git a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h index 0352e28eea2..31d3d573a20 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h +++ b/searchcore/src/vespa/searchcore/proton/matching/requestcontext.h @@ -5,6 +5,7 @@ #include <vespa/eval/tensor/tensor.h> #include <vespa/searchlib/queryeval/irequestcontext.h> #include <vespa/searchcommon/attribute/iattributecontext.h> +#include <vespa/vespalib/util/doom.h> namespace search::fef { class Properties; } @@ -20,7 +21,7 @@ public: RequestContext(const Doom & softDoom, IAttributeContext & attributeContext, const search::fef::Properties& rank_properties); - const Doom & getSoftDoom() const override { return _softDoom; } + const Doom & getDoom() const override { return _doom; } const search::attribute::IAttributeVector *getAttribute(const vespalib::string &name) const override; void asyncForAttribute(const vespalib::string &name, std::unique_ptr<IAttributeFunctor> func) const override; @@ -31,9 +32,9 @@ public: private: - const Doom _softDoom; - IAttributeContext & _attributeContext; - const search::fef::Properties& _rank_properties; + const Doom _doom; + IAttributeContext & _attributeContext; + const search::fef::Properties & _rank_properties; }; } diff --git a/searchcore/src/vespa/searchcore/proton/matching/result_processor.cpp b/searchcore/src/vespa/searchcore/proton/matching/result_processor.cpp index 445aab310d9..41052978997 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/result_processor.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/result_processor.cpp @@ -85,7 +85,7 @@ ResultProcessor::prepareThreadContextCreation(size_t num_threads) if (num_threads > 1) { _wasMerged = true; } - if (_groupingSession.get() != 0) { + if (_groupingSession) { _groupingSession->prepareThreadContextCreation(num_threads); } } |