diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-11-15 18:22:49 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-11-15 18:22:49 +0000 |
commit | 00894143c792c8e63ec3c161f8733fef86c501e1 (patch) | |
tree | 4a9dd166098dc990affd07a403afdc1b9b499cd9 /searchcore | |
parent | ec90577f70dab04c7d20132559ce77adfc80a1c8 (diff) |
Add typesafe SteadyTimeStamp.
Diffstat (limited to 'searchcore')
26 files changed, 93 insertions, 89 deletions
diff --git a/searchcore/src/tests/grouping/grouping.cpp b/searchcore/src/tests/grouping/grouping.cpp index 3f166ee9723..79dba576bbd 100644 --- a/searchcore/src/tests/grouping/grouping.cpp +++ b/searchcore/src/tests/grouping/grouping.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/vespalib/testkit/test_kit.h> #include <vespa/searchlib/aggregation/grouping.h> #include <vespa/searchlib/aggregation/sumaggregationresult.h> #include <vespa/searchcommon/attribute/iattributevector.h> @@ -12,7 +11,7 @@ #include <vespa/searchcore/proton/matching/sessionmanager.h> #include <vespa/searchlib/test/mock_attribute_context.h> #include <iostream> - +#include <vespa/vespalib/testkit/test_kit.h> #include <vespa/log/log.h> LOG_SETUP("grouping_test"); @@ -23,7 +22,14 @@ using namespace search::grouping; using namespace search; using search::attribute::test::MockAttributeContext; using proton::matching::SessionManager; +using fastos::SteadyTimeStamp; +namespace fastos { + std::ostream & + operator<<(std::ostream &os, SteadyTimeStamp ts) { + return os << ts.toString(); + } +} //----------------------------------------------------------------------------- @@ -112,8 +118,8 @@ private: struct DoomFixture { vespalib::Clock clock; - fastos::TimeStamp timeOfDoom; - DoomFixture() : clock(), timeOfDoom(fastos::TimeStamp::FUTURE) {} + fastos::SteadyTimeStamp timeOfDoom; + DoomFixture() : clock(), timeOfDoom(fastos::SteadyTimeStamp::FUTURE) {} }; //----------------------------------------------------------------------------- @@ -383,6 +389,7 @@ TEST_F("testSessionManager", DoomFixture()) { GroupingSession::UP s1(new GroupingSession(id1, initContext, world.attributeContext)); GroupingSession::UP s2(new GroupingSession(id2, initContext, world.attributeContext)); GroupingSession::UP s3(new GroupingSession(id3, initContext, world.attributeContext)); + ASSERT_EQUAL(f1.timeOfDoom, s1->getTimeOfDoom()); mgr.insert(std::move(s1)); s1 = mgr.pickGrouping(id1); @@ -395,9 +402,9 @@ TEST_F("testSessionManager", DoomFixture()) { s1 = mgr.pickGrouping(id1); s2 = mgr.pickGrouping(id2); s3 = mgr.pickGrouping(id3); - ASSERT_TRUE(s1.get() == NULL); - ASSERT_TRUE(s2.get() != NULL); - ASSERT_TRUE(s3.get() != NULL); + ASSERT_FALSE(s1); + ASSERT_TRUE(s2); + ASSERT_TRUE(s3); EXPECT_EQUAL(id2, s2->getSessionId()); EXPECT_EQUAL(id3, s3->getSessionId()); SessionManager::Stats stats = mgr.getGroupingStats(); @@ -472,24 +479,24 @@ TEST_F("test session timeout", DoomFixture()) { SessionId id1("foo"); SessionId id2("bar"); - GroupingContext initContext1(f1.clock, 10); - GroupingContext initContext2(f1.clock, 20); + GroupingContext initContext1(f1.clock, SteadyTimeStamp(10)); + GroupingContext initContext2(f1.clock, SteadyTimeStamp(20)); GroupingSession::UP s1(new GroupingSession(id1, initContext1, world.attributeContext)); GroupingSession::UP s2(new GroupingSession(id2, initContext2, world.attributeContext)); mgr.insert(std::move(s1)); mgr.insert(std::move(s2)); - mgr.pruneTimedOutSessions(5); + mgr.pruneTimedOutSessions(SteadyTimeStamp(5)); SessionManager::Stats stats(mgr.getGroupingStats()); ASSERT_EQUAL(2u, stats.numCached); - mgr.pruneTimedOutSessions(10); + mgr.pruneTimedOutSessions(SteadyTimeStamp(10)); stats = mgr.getGroupingStats(); ASSERT_EQUAL(2u, stats.numCached); - mgr.pruneTimedOutSessions(11); + mgr.pruneTimedOutSessions(SteadyTimeStamp(11)); stats = mgr.getGroupingStats(); ASSERT_EQUAL(1u, stats.numCached); - mgr.pruneTimedOutSessions(21); + mgr.pruneTimedOutSessions(SteadyTimeStamp(21)); stats = mgr.getGroupingStats(); ASSERT_EQUAL(0u, stats.numCached); } diff --git a/searchcore/src/tests/proton/common/cachedselect_test.cpp b/searchcore/src/tests/proton/common/cachedselect_test.cpp index bb4d7063183..aa2106923e3 100644 --- a/searchcore/src/tests/proton/common/cachedselect_test.cpp +++ b/searchcore/src/tests/proton/common/cachedselect_test.cpp @@ -618,7 +618,6 @@ TEST_F("Test performance when using attributes", TestFixture) const uint32_t loopcnt = 30000; LOG(info, "Starting minibm loop, %u ierations of 4 docs each", loopcnt); fastos::StopWatch sw; - sw.start(); for (i = 0; i < loopcnt; ++i) { ctx._docId = 1u; if (sel->contains(ctx) != Result::False) diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp index a4f2aeb767d..e6df649af93 100644 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp +++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp @@ -199,7 +199,7 @@ struct MySessionCachePruner : public ISessionCachePruner { bool isInvoked; MySessionCachePruner() : isInvoked(false) { } - void pruneTimedOutSessions(fastos::TimeStamp current) override { + void pruneTimedOutSessions(fastos::SteadyTimeStamp current) override { (void) current; isInvoked = true; } diff --git a/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp b/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp index 63eff02408c..478cf0b2f98 100644 --- a/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp +++ b/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp @@ -289,7 +289,7 @@ TEST("require that the match phase limiter is able to pre-limit the query") { MaybeMatchPhaseLimiter &limiter = yes_limiter; EXPECT_TRUE(limiter.is_enabled()); EXPECT_EQUAL(12u, limiter.sample_hits_per_thread(10)); - RelativeTime clock(std::make_unique<CountingClock>(fastos::TimeStamp::fromSec(1500000000), 1700000L)); + RelativeTime clock(std::make_unique<CountingClock>(fastos::TimeStamp::fromSec(10000000), 1700000L)); Trace trace(clock, 7); trace.start(4); SearchIterator::UP search = limiter.maybe_limit(prepare(new MockSearch("search")), 0.1, 100000, trace.maybeCreateCursor(7, "limit")); @@ -315,7 +315,7 @@ TEST("require that the match phase limiter is able to pre-limit the query") { trace.done(); verify( "{" - " start_time_utc: '2017-07-14 02:40:00.000 UTC'," + " start_time_relative: '1970-04-26 17:46:40.000 UTC'," " traces: [" " {" " timestamp_ms: 1.7," diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp index 05ca9e758ab..883aa8f5aa5 100644 --- a/searchcore/src/tests/proton/matching/matching_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_test.cpp @@ -60,6 +60,13 @@ using vespalib::nbostream; using vespalib::eval::TensorSpec; using vespalib::tensor::DefaultTensorEngine; +namespace fastos { + std::ostream & + operator<<(std::ostream &os, SteadyTimeStamp ts) { + return os << ts.toString(); + } +} + void inject_match_phase_limiting(Properties &setup, const vespalib::string &attribute, size_t max_hits, bool descending) { Properties cfg; @@ -767,7 +774,7 @@ TEST("require that getSummaryFeatures prefers cached query setup") { ASSERT_EQUAL(0u, fs->numDocs()); // "spread" has no hits // Empty cache - auto pruneTime = fastos::ClockSystem::now() + + auto pruneTime = fastos::ClockSteady::now() + fastos::TimeStamp::MINUTE * 10; world.sessionManager->pruneTimedOutSessions(pruneTime); diff --git a/searchcore/src/tests/proton/matching/sessionmanager_test.cpp b/searchcore/src/tests/proton/matching/sessionmanager_test.cpp index 78fe216cb9e..5998b165b51 100644 --- a/searchcore/src/tests/proton/matching/sessionmanager_test.cpp +++ b/searchcore/src/tests/proton/matching/sessionmanager_test.cpp @@ -18,6 +18,7 @@ using vespalib::string; using namespace proton; using namespace proton::matching; using vespalib::StateExplorer; +using fastos::SteadyTimeStamp; namespace { @@ -34,8 +35,8 @@ void checkStats(SessionManager::Stats stats, uint32_t numInsert, TEST("require that SessionManager handles SearchSessions.") { string session_id("foo"); - fastos::TimeStamp start(100); - fastos::TimeStamp doom(1000); + SteadyTimeStamp start(100); + SteadyTimeStamp doom(1000); MatchToolsFactory::UP mtf; SearchSession::OwnershipBundle owned_objects; auto session = std::make_shared<SearchSession>(session_id, start, doom, std::move(mtf), std::move(owned_objects)); @@ -49,9 +50,9 @@ TEST("require that SessionManager handles SearchSessions.") { TEST_DO(checkStats(session_manager.getSearchStats(), 0, 1, 0, 1, 0)); session_manager.insert(std::move(session)); TEST_DO(checkStats(session_manager.getSearchStats(), 1, 0, 0, 1, 0)); - session_manager.pruneTimedOutSessions(500); + session_manager.pruneTimedOutSessions(SteadyTimeStamp(500)); TEST_DO(checkStats(session_manager.getSearchStats(), 0, 0, 0, 1, 0)); - session_manager.pruneTimedOutSessions(2000); + session_manager.pruneTimedOutSessions(SteadyTimeStamp(2000)); TEST_DO(checkStats(session_manager.getSearchStats(), 0, 0, 0, 0, 1)); session = session_manager.pickSearch(session_id); @@ -59,8 +60,8 @@ TEST("require that SessionManager handles SearchSessions.") { } TEST("require that SessionManager can be explored") { - fastos::TimeStamp start(100); - fastos::TimeStamp doom(1000); + SteadyTimeStamp start(100); + SteadyTimeStamp doom(1000); SessionManager session_manager(10); session_manager.insert(std::make_shared<SearchSession>("foo", start, doom, MatchToolsFactory::UP(), SearchSession::OwnershipBundle())); diff --git a/searchcore/src/vespa/searchcore/grouping/groupingcontext.cpp b/searchcore/src/vespa/searchcore/grouping/groupingcontext.cpp index 38309284e54..3869ffe8a6a 100644 --- a/searchcore/src/vespa/searchcore/grouping/groupingcontext.cpp +++ b/searchcore/src/vespa/searchcore/grouping/groupingcontext.cpp @@ -50,7 +50,7 @@ GroupingContext::setDistributionKey(uint32_t distributionKey) } } -GroupingContext::GroupingContext(const vespalib::Clock & clock, fastos::TimeStamp timeOfDoom, const char *groupSpec, uint32_t groupSpecLen) : +GroupingContext::GroupingContext(const vespalib::Clock & clock, fastos::SteadyTimeStamp timeOfDoom, const char *groupSpec, uint32_t groupSpecLen) : _clock(clock), _timeOfDoom(timeOfDoom), _os(), @@ -59,7 +59,7 @@ GroupingContext::GroupingContext(const vespalib::Clock & clock, fastos::TimeStam deserialize(groupSpec, groupSpecLen); } -GroupingContext::GroupingContext(const vespalib::Clock & clock, fastos::TimeStamp timeOfDoom) : +GroupingContext::GroupingContext(const vespalib::Clock & clock, fastos::SteadyTimeStamp timeOfDoom) : _clock(clock), _timeOfDoom(timeOfDoom), _os(), diff --git a/searchcore/src/vespa/searchcore/grouping/groupingcontext.h b/searchcore/src/vespa/searchcore/grouping/groupingcontext.h index 92a9dc06fff..eb6afca5f59 100644 --- a/searchcore/src/vespa/searchcore/grouping/groupingcontext.h +++ b/searchcore/src/vespa/searchcore/grouping/groupingcontext.h @@ -22,7 +22,7 @@ public: private: const vespalib::Clock & _clock; - fastos::TimeStamp _timeOfDoom; + fastos::SteadyTimeStamp _timeOfDoom; vespalib::nbostream _os; GroupingList _groupingList; public: @@ -40,14 +40,14 @@ public: * @param groupSpec The grouping specification to use for initialization. * @param groupSpecLen The length of the grouping specification, in bytes. **/ - GroupingContext(const vespalib::Clock & clock, fastos::TimeStamp timeOfDoom, const char *groupSpec, uint32_t groupSpecLen); + GroupingContext(const vespalib::Clock & clock, fastos::SteadyTimeStamp timeOfDoom, const char *groupSpec, uint32_t groupSpecLen); /** * Create a new grouping context from a byte buffer. * @param groupSpec The grouping specification to use for initialization. * @param groupSpecLen The length of the grouping specification, in bytes. **/ - GroupingContext(const vespalib::Clock & clock, fastos::TimeStamp timeOfDoom); + GroupingContext(const vespalib::Clock & clock, fastos::SteadyTimeStamp timeOfDoom); /** * Shallow copy of references @@ -105,7 +105,7 @@ public: /** * Obtain the time of doom. */ - fastos::TimeStamp getTimeOfDoom() const { return _timeOfDoom; } + fastos::SteadyTimeStamp getTimeOfDoom() const { return _timeOfDoom; } /** * Figure out if ranking is necessary for any of the grouping requests here. * @return true if ranking is required. diff --git a/searchcore/src/vespa/searchcore/grouping/groupingsession.h b/searchcore/src/vespa/searchcore/grouping/groupingsession.h index 95a5332b417..055fd41f0e1 100644 --- a/searchcore/src/vespa/searchcore/grouping/groupingsession.h +++ b/searchcore/src/vespa/searchcore/grouping/groupingsession.h @@ -30,7 +30,7 @@ private: std::unique_ptr<GroupingContext> _mgrContext; std::unique_ptr<GroupingManager> _groupingManager; GroupingMap _groupingMap; - fastos::TimeStamp _timeOfDoom; + fastos::SteadyTimeStamp _timeOfDoom; public: typedef std::unique_ptr<GroupingSession> UP; @@ -108,7 +108,7 @@ public: /** * Get this sessions timeout. */ - fastos::TimeStamp getTimeOfDoom() const { return _timeOfDoom; } + fastos::SteadyTimeStamp getTimeOfDoom() const { return _timeOfDoom; } }; } diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp index 39ea1b66f63..c3063521a99 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp @@ -176,7 +176,6 @@ AttributeInitializer::loadAttribute(const AttributeVectorSP &attr, { assert(attr->hasLoadData()); fastos::StopWatch stopWatch; - stopWatch.start(); EventLogger::loadAttributeStart(_documentSubDbName, attr->getName()); if (!attr->load()) { LOG(warning, "Could not load attribute vector '%s' from disk. Returning empty attribute vector", diff --git a/searchcore/src/vespa/searchcore/proton/docsummary/summarymanagerinitializer.cpp b/searchcore/src/vespa/searchcore/proton/docsummary/summarymanagerinitializer.cpp index a1a94a27c08..5cdfbf03c07 100644 --- a/searchcore/src/vespa/searchcore/proton/docsummary/summarymanagerinitializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/docsummary/summarymanagerinitializer.cpp @@ -39,7 +39,6 @@ SummaryManagerInitializer::run() { vespalib::mkdir(_baseDir, false); fastos::StopWatch stopWatch; - stopWatch.start(); EventLogger::loadDocumentStoreStart(_subDbName); *_result = std::make_shared<SummaryManager> (_summaryExecutor, _storeCfg, _grow, _baseDir, _docTypeName, diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp index 56da585dd9b..eed333a11d8 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp @@ -23,11 +23,12 @@ DocumentMetaStoreInitializer(const vespalib::string baseDir, : _baseDir(baseDir), _subDbName(subDbName), _docTypeName(docTypeName), - _dms(dms) + _dms(std::move(dms)) { } namespace { -vespalib::string failedMsg(const char * msg) { +vespalib::string +failedMsg(const char * msg) { return make_string("Failed to load document meta store for document type '%s' from disk", msg); } } @@ -44,7 +45,6 @@ DocumentMetaStoreInitializer::run() _dms->setBaseFileName(attrFileName); assert(_dms->hasLoadData()); fastos::StopWatch stopWatch; - stopWatch.start(); EventLogger::loadDocumentMetaStoreStart(_subDbName); if (!_dms->load()) { throw IllegalStateException(failedMsg(_docTypeName.c_str())); diff --git a/searchcore/src/vespa/searchcore/proton/matching/fakesearchcontext.cpp b/searchcore/src/vespa/searchcore/proton/matching/fakesearchcontext.cpp index 36129640c0e..c7a75bff9ca 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/fakesearchcontext.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/fakesearchcontext.cpp @@ -2,12 +2,11 @@ #include "fakesearchcontext.h" -namespace proton { -namespace matching { +namespace proton::matching { FakeSearchContext::FakeSearchContext(size_t initialNumDocs) : _clock(), - _doom(_clock, -1), + _doom(_clock, fastos::SteadyTimeStamp::ZERO), _selector(new search::FixedSourceSelector(0, "fs", initialNumDocs)), _indexes(new IndexCollection(_selector)), _attrSearchable(), @@ -16,7 +15,6 @@ FakeSearchContext::FakeSearchContext(size_t initialNumDocs) _attrSearchable.is_attr(true); } -FakeSearchContext::~FakeSearchContext() {} +FakeSearchContext::~FakeSearchContext() = default; -} // namespace matching -} // namespace proton +} diff --git a/searchcore/src/vespa/searchcore/proton/matching/isessioncachepruner.h b/searchcore/src/vespa/searchcore/proton/matching/isessioncachepruner.h index 749b3a5fef0..2d38ec13cda 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/isessioncachepruner.h +++ b/searchcore/src/vespa/searchcore/proton/matching/isessioncachepruner.h @@ -9,7 +9,7 @@ namespace proton::matching { struct ISessionCachePruner { virtual ~ISessionCachePruner() {} - virtual void pruneTimedOutSessions(fastos::TimeStamp currentTime) = 0; + virtual void pruneTimedOutSessions(fastos::SteadyTimeStamp currentTime) = 0; }; } diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp index 7ebe05e7b96..20cd739020e 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp @@ -36,7 +36,7 @@ struct TimedMatchLoopCommunicator : IMatchLoopCommunicator { } Hits selectBest(SortedHitSequence sortedHits) override { auto result = communicator.selectBest(sortedHits); - rerank_time.start(); + rerank_time = fastos::StopWatch(); return result; } RangePair rangeCover(const RangePair &ranges) override { @@ -70,7 +70,6 @@ MatchMaster::match(search::engine::Trace & trace, uint32_t numSearchPartitions) { fastos::StopWatch query_latency_time; - query_latency_time.start(); vespalib::DualMergeDirector mergeDirector(threadBundle.size()); MatchLoopCommunicator communicator(threadBundle.size(), params.heapSize, mtf.createDiversifier(params.heapSize)); TimedMatchLoopCommunicator timedCommunicator(communicator); diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp index f0a860157ad..71ff9696050 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp @@ -39,9 +39,7 @@ struct WaitTimer { fastos::StopWatch wait_time; WaitTimer(double &wait_time_s_in) : wait_time_s(wait_time_s_in), wait_time() - { - wait_time.start(); - } + { } void done() { wait_time.stop(); wait_time_s += wait_time.elapsed().sec(); @@ -433,8 +431,6 @@ MatchThread::run() { fastos::StopWatch total_time; fastos::StopWatch match_time; - total_time.start(); - match_time.start(); trace->addEvent(4, "Start MatchThread::run"); MatchTools::UP matchTools = matchToolsFactory.createMatchTools(); search::ResultSet::UP result = findMatches(*matchTools); diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp index 0e00220428b..7c581d7b01d 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp @@ -130,10 +130,10 @@ Matcher::create_match_tools_factory(const search::engine::Request &request, ISea ? Factor::lookup(rankProperties, _stats.softDoomFactor()) : 0.95; int64_t safeLeft = request.getTimeLeft() * factor; - fastos::TimeStamp safeDoom(_clock.getTimeNSAssumeRunning().val() + safeLeft); + fastos::SteadyTimeStamp safeDoom(_clock.getTimeNSAssumeRunning() + safeLeft); if (softTimeoutEnabled) { - LOG(debug, "Soft-timeout computed factor=%1.3f, used factor=%1.3f, softTimeout=%" PRId64 " softDoom=%" PRId64 " hardDoom=%" PRId64, - _stats.softDoomFactor(), factor, safeLeft, safeDoom.ns(), request.getTimeOfDoom().ns()); + LOG(debug, "Soft-timeout computed factor=%1.3f, used factor=%1.3f, softTimeout=%" PRId64, + _stats.softDoomFactor(), factor, safeLeft); } return std::make_unique<MatchToolsFactory>(_queryLimiter, vespalib::Doom(_clock, safeDoom), vespalib::Doom(_clock, request.getTimeOfDoom()), searchContext, @@ -181,7 +181,6 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl const search::IDocumentMetaStore &metaStore, SearchSession::OwnershipBundle &&owned_objects) { fastos::StopWatch total_matching_time; - total_matching_time.start(); MatchingStats my_stats; SearchReply::UP reply = std::make_unique<SearchReply>(); size_t covered = 0; diff --git a/searchcore/src/vespa/searchcore/proton/matching/search_session.cpp b/searchcore/src/vespa/searchcore/proton/matching/search_session.cpp index 36576997950..055325b851f 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/search_session.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/search_session.cpp @@ -5,7 +5,7 @@ namespace proton::matching { -SearchSession::SearchSession(const SessionId &id, fastos::TimeStamp create_time, fastos::TimeStamp time_of_doom, +SearchSession::SearchSession(const SessionId &id, fastos::SteadyTimeStamp create_time, fastos::SteadyTimeStamp time_of_doom, std::unique_ptr<MatchToolsFactory> match_tools_factory, OwnershipBundle &&owned_objects) : _session_id(id), diff --git a/searchcore/src/vespa/searchcore/proton/matching/search_session.h b/searchcore/src/vespa/searchcore/proton/matching/search_session.h index f8b500f2d7b..5f9436cce72 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/search_session.h +++ b/searchcore/src/vespa/searchcore/proton/matching/search_session.h @@ -34,16 +34,16 @@ public: private: typedef vespalib::string SessionId; - SessionId _session_id; - fastos::TimeStamp _create_time; - fastos::TimeStamp _time_of_doom; - OwnershipBundle _owned_objects; + SessionId _session_id; + fastos::SteadyTimeStamp _create_time; + fastos::SteadyTimeStamp _time_of_doom; + OwnershipBundle _owned_objects; std::unique_ptr<MatchToolsFactory> _match_tools_factory; public: typedef std::shared_ptr<SearchSession> SP; - SearchSession(const SessionId &id, fastos::TimeStamp create_time, fastos::TimeStamp time_of_doom, + SearchSession(const SessionId &id, fastos::SteadyTimeStamp create_time, fastos::SteadyTimeStamp time_of_doom, std::unique_ptr<MatchToolsFactory> match_tools_factory, OwnershipBundle &&owned_objects); ~SearchSession(); @@ -54,12 +54,12 @@ public: /** * Gets this session's create time. */ - fastos::TimeStamp getCreateTime() const { return _create_time; } + fastos::SteadyTimeStamp getCreateTime() const { return _create_time; } /** * Gets this session's timeout. */ - fastos::TimeStamp getTimeOfDoom() const { return _time_of_doom; } + fastos::SteadyTimeStamp getTimeOfDoom() const { return _time_of_doom; } MatchToolsFactory &getMatchToolsFactory() { return *_match_tools_factory; } }; diff --git a/searchcore/src/vespa/searchcore/proton/matching/session_manager_explorer.cpp b/searchcore/src/vespa/searchcore/proton/matching/session_manager_explorer.cpp index bcc59dd9742..152411f9b70 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/session_manager_explorer.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/session_manager_explorer.cpp @@ -30,8 +30,8 @@ public: for (const auto &session: sessions) { Cursor &entry = array.addObject(); entry.setString("id", session.id); - entry.setString("created", session.created.toString()); - entry.setString("doom", session.doom.toString()); + entry.setString("created", session.created.toUTC().toString()); + entry.setString("doom", session.doom.toUTC().toString()); } } } @@ -54,9 +54,9 @@ std::unique_ptr<StateExplorer> SessionManagerExplorer::get_child(vespalib::stringref name) const { if (name == SEARCH) { - return std::unique_ptr<StateExplorer>(new SearchSessionExplorer(_manager)); + return std::make_unique<SearchSessionExplorer>(_manager); } - return std::unique_ptr<StateExplorer>(nullptr); + return std::unique_ptr<StateExplorer>(); } } diff --git a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp index afaf61cab5d..02c08a1c401 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp @@ -50,11 +50,11 @@ struct SessionCache : SessionCacheBase { } return ret; } - void pruneTimedOutSessions(fastos::TimeStamp currentTime) { + void pruneTimedOutSessions(fastos::SteadyTimeStamp currentTime) { std::vector<EntryUP> toDestruct = stealTimedOutSessions(currentTime); toDestruct.clear(); } - std::vector<EntryUP> stealTimedOutSessions(fastos::TimeStamp currentTime) { + std::vector<EntryUP> stealTimedOutSessions(fastos::SteadyTimeStamp currentTime) { std::vector<EntryUP> toDestruct; std::lock_guard<std::mutex> guard(_lock); toDestruct.reserve(_cache.size()); @@ -103,11 +103,11 @@ struct SessionMap : SessionCacheBase { } return EntrySP(); } - void pruneTimedOutSessions(fastos::TimeStamp currentTime) { + void pruneTimedOutSessions(fastos::SteadyTimeStamp currentTime) { std::vector<EntrySP> toDestruct = stealTimedOutSessions(currentTime); toDestruct.clear(); } - std::vector<EntrySP> stealTimedOutSessions(fastos::TimeStamp currentTime) { + std::vector<EntrySP> stealTimedOutSessions(fastos::SteadyTimeStamp currentTime) { std::vector<EntrySP> toDestruct; std::vector<SessionId> keys; std::lock_guard<std::mutex> guard(_lock); @@ -210,13 +210,13 @@ SessionManager::getSortedSearchSessionInfo() const return sessions; } -void SessionManager::pruneTimedOutSessions(fastos::TimeStamp currentTime) { +void SessionManager::pruneTimedOutSessions(fastos::SteadyTimeStamp currentTime) { _grouping_cache->pruneTimedOutSessions(currentTime); _search_map->pruneTimedOutSessions(currentTime); } void SessionManager::close() { - pruneTimedOutSessions(fastos::TimeStamp::FUTURE); + pruneTimedOutSessions(fastos::SteadyTimeStamp::FUTURE); assert(_grouping_cache->empty()); assert(_search_map->empty()); } diff --git a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.h b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.h index 3e3c795784c..dc981c939b4 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.h +++ b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.h @@ -33,11 +33,11 @@ public: struct SearchSessionInfo { vespalib::string id; - fastos::TimeStamp created; - fastos::TimeStamp doom; + fastos::SteadyTimeStamp created; + fastos::SteadyTimeStamp doom; SearchSessionInfo(const vespalib::string &id_in, - fastos::TimeStamp created_in, - fastos::TimeStamp doom_in) + fastos::SteadyTimeStamp created_in, + fastos::SteadyTimeStamp doom_in) : id(id_in), created(created_in), doom(doom_in) {} }; @@ -50,7 +50,7 @@ public: typedef std::shared_ptr<SessionManager> SP; SessionManager(uint32_t maxSizeGrouping); - ~SessionManager(); + ~SessionManager() override; void insert(search::grouping::GroupingSession::UP session); search::grouping::GroupingSession::UP pickGrouping(const SessionId &id); @@ -62,7 +62,7 @@ public: size_t getNumSearchSessions() const; std::vector<SearchSessionInfo> getSortedSearchSessionInfo() const; - void pruneTimedOutSessions(fastos::TimeStamp currentTime) override; + void pruneTimedOutSessions(fastos::SteadyTimeStamp currentTime) override; void close(); }; diff --git a/searchcore/src/vespa/searchcore/proton/reprocessing/reprocess_documents_task.cpp b/searchcore/src/vespa/searchcore/proton/reprocessing/reprocess_documents_task.cpp index eb3bec35118..d81926ae5ac 100644 --- a/searchcore/src/vespa/searchcore/proton/reprocessing/reprocess_documents_task.cpp +++ b/searchcore/src/vespa/searchcore/proton/reprocessing/reprocess_documents_task.cpp @@ -33,7 +33,7 @@ ReprocessDocumentsTask::run() { if (_handler.hasProcessors()) { EventLogger::reprocessDocumentsStart(_subDbName,_visitorCost); - _stopWatch.start(); + _stopWatch = fastos::StopWatch(); search::IDocumentStore &docstore = _sm->getBackingStore(); if (_handler.hasRewriters()) { docstore.accept(_handler.getRewriteVisitor(),*this,*_docTypeRepo); diff --git a/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.cpp b/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.cpp index 13b545e47a6..7c27728bc22 100644 --- a/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.cpp @@ -16,8 +16,7 @@ PruneSessionCacheJob::PruneSessionCacheJob(ISessionCachePruner &pruner, double j bool PruneSessionCacheJob::run() { - fastos::TimeStamp now = fastos::ClockSteady::now(); - _pruner.pruneTimedOutSessions(now); + _pruner.pruneTimedOutSessions(fastos::ClockSteady::now()); return true; } diff --git a/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp b/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp index 84edd2b7512..e5b5bc0e559 100644 --- a/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp @@ -13,6 +13,7 @@ LOG_SETUP(".proton.server.rtchooks"); using namespace vespalib; using vespalib::compression::CompressionConfig; +using fastos::SteadyTimeStamp; using fastos::TimeStamp; namespace { @@ -37,7 +38,7 @@ namespace proton { void RPCHooksBase::checkState(std::unique_ptr<StateArg> arg) { - TimeStamp now(fastos::ClockSteady::now()); + SteadyTimeStamp now(fastos::ClockSteady::now()); if (now < arg->_dueTime) { std::unique_lock<std::mutex> guard(_stateLock); if (_stateCond.wait_for(guard, std::chrono::milliseconds(std::min(INT64_C(1000), (arg->_dueTime - now)/TimeStamp::MS))) == std::cv_status::no_timeout) { @@ -284,7 +285,7 @@ RPCHooksBase::rpc_GetState(FRT_RPCRequest *req) if (sharedSession->getGen() < 0 || sharedSession->getNumDocs() != numDocs) { // NB Should use something else to define generation. reportState(*sharedSession, req); } else { - TimeStamp dueTime(fastos::ClockSteady::now() + TimeStamp(timeoutMS * TimeStamp::MS)); + SteadyTimeStamp dueTime(fastos::ClockSteady::now() + TimeStamp(timeoutMS * TimeStamp::MS)); auto stateArg = std::make_unique<StateArg>(sharedSession, req, dueTime); if (_executor.execute(makeTask(makeClosure(this, &RPCHooksBase::checkState, std::move(stateArg))))) { reportState(*sharedSession, req); @@ -349,7 +350,7 @@ RPCHooksBase::rpc_getIncrementalState(FRT_RPCRequest *req) if (sharedSession->getGen() < 0 || sharedSession->getNumDocs() != numDocs) { // NB Should use something else to define generation. reportState(*sharedSession, req); } else { - TimeStamp dueTime(fastos::ClockSteady::now() + TimeStamp(timeoutMS * TimeStamp::MS)); + SteadyTimeStamp dueTime(fastos::ClockSteady::now() + TimeStamp(timeoutMS * TimeStamp::MS)); auto stateArg = std::make_unique<StateArg>(sharedSession, req, dueTime); if (_executor.execute(makeTask(makeClosure(this, &RPCHooksBase::checkState, std::move(stateArg))))) { reportState(*sharedSession, req); diff --git a/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.h b/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.h index c694647491b..21c3283d790 100644 --- a/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.h +++ b/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.h @@ -49,14 +49,14 @@ private: }; struct StateArg { - StateArg(Session::SP session, FRT_RPCRequest * req, fastos::TimeStamp dueTime) : + StateArg(Session::SP session, FRT_RPCRequest * req, fastos::SteadyTimeStamp dueTime) : _session(std::move(session)), _req(req), _dueTime(dueTime) { } - Session::SP _session; - FRT_RPCRequest * _req; - fastos::TimeStamp _dueTime; + Session::SP _session; + FRT_RPCRequest * _req; + fastos::SteadyTimeStamp _dueTime; }; Proton & _proton; |