diff options
50 files changed, 251 insertions, 209 deletions
diff --git a/fastos/src/vespa/fastos/timestamp.cpp b/fastos/src/vespa/fastos/timestamp.cpp index e35f0c968de..d5c7f623fde 100644 --- a/fastos/src/vespa/fastos/timestamp.cpp +++ b/fastos/src/vespa/fastos/timestamp.cpp @@ -50,26 +50,34 @@ time() { namespace { -TimeStamp +SteadyTimeStamp steady_now() { - return duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count(); + return SteadyTimeStamp(duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count()); } } -TimeStamp +SteadyTimeStamp ClockSteady::now() { return steady_now(); } -StopWatch & -StopWatch::start() { - _startTime = steady_now(); - _stopTime = _startTime; - return *this; +const SteadyTimeStamp SteadyTimeStamp::ZERO; +const SteadyTimeStamp SteadyTimeStamp::FUTURE(TimeStamp::FUTURE); + +TimeStamp +SteadyTimeStamp::toUTC() const { + TimeStamp nowUtc = ClockSystem::now(); + SteadyTimeStamp nowSteady = ClockSteady::now(); + return nowUtc - (nowSteady - *this); } +StopWatch::StopWatch() + : _startTime(steady_now()), + _stopTime(_startTime) +{ } + StopWatch & StopWatch::stop() { _stopTime = steady_now(); diff --git a/fastos/src/vespa/fastos/timestamp.h b/fastos/src/vespa/fastos/timestamp.h index 73f289cae9b..2eb895c01f9 100644 --- a/fastos/src/vespa/fastos/timestamp.h +++ b/fastos/src/vespa/fastos/timestamp.h @@ -36,24 +36,55 @@ public: TimeStamp(long long v) : _time(v) { } TimeStamp(unsigned long long v) : _time(v) { } TimeStamp(Seconds v) : _time(v.val()) { } - TimeT val() const { return _time; } - operator TimeT () const { return val(); } - TimeStamp & operator += (const TimeStamp & b) { _time += b._time; return *this; } - TimeStamp & operator -= (const TimeStamp & b) { _time -= b._time; return *this; } - TimeT time() const { return val()/NANO; } - TimeT ms() const { return val()/1000000; } - TimeT us() const { return val()/1000; } - TimeT ns() const { return val(); } - double sec() const { return val()/1000000000.0; } - std::string toString() const { return asString(sec()); } + TimeT val() const { return _time; } + operator TimeT () const { return val(); } + TimeStamp & operator += (TimeStamp b) { _time += b._time; return *this; } + TimeStamp & operator -= (TimeStamp b) { _time -= b._time; return *this; } + TimeT time() const { return val()/NANO; } + TimeT ms() const { return val()/1000000; } + TimeT us() const { return val()/1000; } + TimeT ns() const { return val(); } + double sec() const { return val()/1000000000.0; } + std::string toString() const { return asString(sec()); } static std::string asString(double timeInSeconds); static TimeStamp fromSec(double sec) { return Seconds(sec); } private: TimeT _time; }; -inline TimeStamp operator +(const TimeStamp & a, const TimeStamp & b) { return TimeStamp(a.val() + b.val()); } -inline TimeStamp operator -(const TimeStamp & a, const TimeStamp & b) { return TimeStamp(a.val() - b.val()); } +inline TimeStamp operator +(TimeStamp a, TimeStamp b) { return TimeStamp(a.val() + b.val()); } +inline TimeStamp operator -(TimeStamp a, TimeStamp b) { return TimeStamp(a.val() - b.val()); } + +class SteadyTimeStamp { +public: + static const SteadyTimeStamp ZERO; + static const SteadyTimeStamp FUTURE; + SteadyTimeStamp() : _timeStamp() { } + explicit SteadyTimeStamp(TimeStamp timeStamp) : _timeStamp(timeStamp) { } + + friend TimeStamp operator -(SteadyTimeStamp a, SteadyTimeStamp b) { + return a._timeStamp - b._timeStamp; + } + friend SteadyTimeStamp operator +(SteadyTimeStamp a, TimeStamp b) { + return SteadyTimeStamp(a._timeStamp + b); + } + friend bool operator != (SteadyTimeStamp a, SteadyTimeStamp b) { + return a._timeStamp != b._timeStamp; + } + friend bool operator == (SteadyTimeStamp a, SteadyTimeStamp b) { + return a._timeStamp == b._timeStamp; + } + friend bool operator < (SteadyTimeStamp a, SteadyTimeStamp b) { + return a._timeStamp < b._timeStamp; + } + friend bool operator > (SteadyTimeStamp a, SteadyTimeStamp b) { + return a._timeStamp > b._timeStamp; + } + TimeStamp toUTC() const; + std::string toString() const { return _timeStamp.toString(); }; +private: + TimeStamp _timeStamp; +}; class ClockSystem { @@ -64,15 +95,14 @@ public: class ClockSteady { public: - static TimeStamp now(); + static SteadyTimeStamp now(); }; class StopWatch { public: - StopWatch() : _startTime(), _stopTime() { } + StopWatch(); - StopWatch & start(); StopWatch & stop(); TimeStamp elapsed() const { @@ -80,8 +110,8 @@ public: return (diff > 0) ? diff : TimeStamp(0); } private: - TimeStamp _startTime; - TimeStamp _stopTime; + SteadyTimeStamp _startTime; + SteadyTimeStamp _stopTime; }; time_t time(); 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; diff --git a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp index fab0c603189..a49518a6d50 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp +++ b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp @@ -81,7 +81,7 @@ WarmupIndexCollection::toString() const WarmupIndexCollection::~WarmupIndexCollection() { - if (_warmupEndTime != 0) { + if (_warmupEndTime != fastos::SteadyTimeStamp::ZERO) { LOG(info, "Warmup aborted due to new state change or application shutdown"); } _executor.sync(); @@ -114,13 +114,13 @@ WarmupIndexCollection::getSourceId(uint32_t i) const void WarmupIndexCollection::fireWarmup(Task::UP task) { - fastos::TimeStamp now(fastos::ClockSteady::now()); + fastos::SteadyTimeStamp now(fastos::ClockSteady::now()); if (now < _warmupEndTime) { _executor.execute(std::move(task)); } else { std::unique_lock<std::mutex> guard(_lock); - if (_warmupEndTime != 0) { - _warmupEndTime = 0; + if (_warmupEndTime != fastos::SteadyTimeStamp::ZERO) { + _warmupEndTime = fastos::SteadyTimeStamp::ZERO; guard.unlock(); LOG(info, "Done warming up. Posting WarmupDoneTask"); _warmupDone.warmupDone(shared_from_this()); @@ -155,7 +155,7 @@ WarmupIndexCollection::createBlueprint(const IRequestContext & requestContext, const FieldSpecList &fields, const Node &term) { - if ( _warmupEndTime == 0) { + if ( _warmupEndTime == fastos::SteadyTimeStamp::ZERO) { // warmup done return _next->createBlueprint(requestContext, fields, term); } @@ -224,7 +224,7 @@ WarmupIndexCollection::getSearchableSP(uint32_t i) const void WarmupIndexCollection::WarmupTask::run() { - if (_warmup._warmupEndTime != 0) { + if (_warmup._warmupEndTime != fastos::SteadyTimeStamp::ZERO) { LOG(debug, "Warming up %s", _bluePrint->asString().c_str()); _bluePrint->fetchPostings(true); SearchIterator::UP it(_bluePrint->createSearch(*_matchData, true)); diff --git a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h index 992cedb1057..c13a0257019 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h +++ b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h @@ -101,7 +101,7 @@ private: IndexSearchable & _warmup; vespalib::SyncableThreadExecutor & _executor; IWarmupDone & _warmupDone; - fastos::TimeStamp _warmupEndTime; + fastos::SteadyTimeStamp _warmupEndTime; std::mutex _lock; std::unique_ptr<FieldTermMap> _handledTerms; }; diff --git a/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp b/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp index 46af181c26b..8f22ab87c97 100644 --- a/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp +++ b/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp @@ -277,7 +277,7 @@ Test::Main() LOG(info, "sizeof(CountAggregationResult) = %ld", sizeof(CountAggregationResult)); LOG(info, "sizeof(Int64ResultNode) = %ld", sizeof(Int64ResultNode)); - fastos::TimeStamp start(fastos::ClockSteady::now()); + fastos::SteadyTimeStamp start(fastos::ClockSteady::now()); if (idType == "int") { if (aggrType == "sum") { benchmarkIntegerSum(useEngine, numDocs, numQueries, maxGroups); diff --git a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp index f5ce8a9608b..bf1b5352778 100644 --- a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp +++ b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp @@ -170,7 +170,7 @@ public: }; PhraseSearchTest::PhraseSearchTest(bool expiredDoom) - : _requestContext(nullptr, expiredDoom ? 0 : std::numeric_limits<int64_t>::max()), + : _requestContext(nullptr, expiredDoom ? fastos::SteadyTimeStamp::ZERO : fastos::SteadyTimeStamp::FUTURE), _index(), _phrase_fs(field, fieldId, phrase_handle), _phrase(_phrase_fs, _requestContext, false), @@ -199,7 +199,7 @@ void Test::requireThatIteratorHonorsFutureDoom() { test.fetchPostings(false); vespalib::Clock clock; - vespalib::Doom futureDoom(clock, std::numeric_limits<int64_t>::max()); + vespalib::Doom futureDoom(clock, fastos::SteadyTimeStamp::FUTURE); unique_ptr<SearchIterator> search(test.createSearch(false)); static_cast<SimplePhraseSearch &>(*search).setDoom(&futureDoom); EXPECT_TRUE(!search->seek(1u)); @@ -213,7 +213,7 @@ void Test::requireThatIteratorHonorsDoom() { test.fetchPostings(false); vespalib::Clock clock; - vespalib::Doom futureDoom(clock, 0); + vespalib::Doom futureDoom(clock, fastos::SteadyTimeStamp::ZERO); unique_ptr<SearchIterator> search(test.createSearch(false)); static_cast<SimplePhraseSearch &>(*search).setDoom(&futureDoom); EXPECT_TRUE(!search->seek(1u)); diff --git a/searchlib/src/tests/sortspec/multilevelsort.cpp b/searchlib/src/tests/sortspec/multilevelsort.cpp index 84f67a041b0..65c4cd7da95 100644 --- a/searchlib/src/tests/sortspec/multilevelsort.cpp +++ b/searchlib/src/tests/sortspec/multilevelsort.cpp @@ -241,7 +241,7 @@ MultilevelSortTest::sortAndCheck(const std::vector<Spec> &spec, uint32_t num, } vespalib::Clock clock; - vespalib::Doom doom(clock, std::numeric_limits<fastos::TimeStamp::TimeT>::max()); + vespalib::Doom doom(clock, fastos::SteadyTimeStamp::FUTURE); search::uca::UcaConverterFactory ucaFactory; FastS_SortSpec sorter(7, doom, ucaFactory, _sortMethod); // init sorter with sort data @@ -399,7 +399,7 @@ TEST("require that all sort methods behave the same") TEST("test that [docid] translates to [lid][paritionid]") { vespalib::Clock clock; - vespalib::Doom doom(clock, fastos::ClockSystem::now() + fastos::TimeStamp::SEC*10); + vespalib::Doom doom(clock, fastos::SteadyTimeStamp::FUTURE); search::uca::UcaConverterFactory ucaFactory; FastS_SortSpec asc(7, doom, ucaFactory); RankedHit hits[2] = {RankedHit(91, 0.0), RankedHit(3, 2.0)}; diff --git a/searchlib/src/vespa/searchlib/aggregation/grouping.h b/searchlib/src/vespa/searchlib/aggregation/grouping.h index 1d71eb0c0aa..4230bd777d6 100644 --- a/searchlib/src/vespa/searchlib/aggregation/grouping.h +++ b/searchlib/src/vespa/searchlib/aggregation/grouping.h @@ -6,11 +6,11 @@ #include <vespa/vespalib/util/clock.h> namespace search { + class BitVector; + struct IDocumentMetaStore; +} -class BitVector; -struct IDocumentMetaStore; - -namespace aggregation { +namespace search::aggregation { /** * This class represents a top-level grouping request. @@ -22,18 +22,18 @@ public: typedef std::unique_ptr<Grouping> UP; private: - uint32_t _id; // client id for this grouping - bool _valid; // is this grouping object valid? - bool _all; // if true, group all document, not just hits (streaming only) - int64_t _topN; // hits to process per search node - uint32_t _firstLevel; // first processing level this iteration (levels before considered frozen) - uint32_t _lastLevel; // last processing level this iteration - GroupingLevelList _levels; // grouping parameters per level - Group _root; // the grouping tree - const vespalib::Clock *_clock; // An optional clock to be used for timeout handling. - fastos::TimeStamp _timeOfDoom; // Used if clock is specified. This is time when request expires. + uint32_t _id; // client id for this grouping + bool _valid; // is this grouping object valid? + bool _all; // if true, group all document, not just hits (streaming only) + int64_t _topN; // hits to process per search node + uint32_t _firstLevel; // first processing level this iteration (levels before considered frozen) + uint32_t _lastLevel; // last processing level this iteration + GroupingLevelList _levels; // grouping parameters per level + Group _root; // the grouping tree + const vespalib::Clock *_clock; // An optional clock to be used for timeout handling. + fastos::SteadyTimeStamp _timeOfDoom; // Used if clock is specified. This is time when request expires. - bool hasExpired() const { return _clock->getTimeNS() >= _timeOfDoom; } + bool hasExpired() const { return _clock->getTimeNS() > _timeOfDoom; } void aggregateWithoutClock(const RankedHit * rankedHit, unsigned int len); void aggregateWithClock(const RankedHit * rankedHit, unsigned int len); void postProcess(); @@ -46,7 +46,7 @@ public: Grouping & operator = (const Grouping &); Grouping(Grouping &&) = default; Grouping & operator = (Grouping &&) = default; - ~Grouping(); + ~Grouping() override; Grouping unchain() const { return *this; } @@ -59,7 +59,7 @@ public: Grouping &addLevel(GroupingLevel && level) { _levels.push_back(std::move(level)); return *this; } Grouping &setRoot(const Group &root_) { _root = root_; return *this; } Grouping &setClock(const vespalib::Clock * clock) { _clock = clock; return *this; } - Grouping &setTimeOfDoom(fastos::TimeStamp timeOfDoom) { _timeOfDoom = timeOfDoom; return *this; } + Grouping &setTimeOfDoom(fastos::SteadyTimeStamp timeOfDoom) { _timeOfDoom = timeOfDoom; return *this; } unsigned int getId() const { return _id; } bool valid() const { return _valid; } @@ -97,4 +97,3 @@ public: }; } -} diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h index 286f4cfc36c..99fd5a88e48 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.h +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h @@ -572,22 +572,22 @@ private: LoadedBufferUP loadFile(const char *suffix); - BaseName _baseFileName; - Config _config; + BaseName _baseFileName; + Config _config; std::shared_ptr<attribute::Interlock> _interlock; - mutable std::shared_timed_mutex _enumLock; - GenerationHandler _genHandler; - GenerationHolder _genHolder; - Status _status; - int _highestValueCount; - uint32_t _enumMax; - uint32_t _committedDocIdLimit; // docid limit for search - uint32_t _uncommittedDocIdLimit; // based on queued changes - uint64_t _createSerialNum; - uint64_t _compactLidSpaceGeneration; - bool _hasEnum; - bool _loaded; - fastos::TimeStamp _nextStatUpdateTime; + mutable std::shared_timed_mutex _enumLock; + GenerationHandler _genHandler; + GenerationHolder _genHolder; + Status _status; + int _highestValueCount; + uint32_t _enumMax; + uint32_t _committedDocIdLimit; // docid limit for search + uint32_t _uncommittedDocIdLimit; // based on queued changes + uint64_t _createSerialNum; + uint64_t _compactLidSpaceGeneration; + bool _hasEnum; + bool _loaded; + fastos::SteadyTimeStamp _nextStatUpdateTime; ////// Locking strategy interface. only available from the Guards. /** diff --git a/searchlib/src/vespa/searchlib/engine/request.h b/searchlib/src/vespa/searchlib/engine/request.h index a021ec6bfaa..4f4bf526920 100644 --- a/searchlib/src/vespa/searchlib/engine/request.h +++ b/searchlib/src/vespa/searchlib/engine/request.h @@ -16,8 +16,8 @@ public: Request & operator =(const Request &) = delete; virtual ~Request(); void setTimeout(const fastos::TimeStamp & timeout); - fastos::TimeStamp getStartTime() const { return _relativeTime.timeOfDawn(); } - fastos::TimeStamp getTimeOfDoom() const { return _timeOfDoom; } + fastos::SteadyTimeStamp getStartTime() const { return _relativeTime.timeOfDawn(); } + fastos::SteadyTimeStamp getTimeOfDoom() const { return _timeOfDoom; } fastos::TimeStamp getTimeout() const { return _timeOfDoom - getStartTime(); } fastos::TimeStamp getTimeUsed() const; fastos::TimeStamp getTimeLeft() const; @@ -37,8 +37,8 @@ public: Trace & trace() const { return _trace; } private: - RelativeTime _relativeTime; - fastos::TimeStamp _timeOfDoom; + RelativeTime _relativeTime; + fastos::SteadyTimeStamp _timeOfDoom; public: /// Everything here should move up to private section and have accessors bool dumpFeatures; diff --git a/searchlib/src/vespa/searchlib/engine/trace.cpp b/searchlib/src/vespa/searchlib/engine/trace.cpp index 576b8dc92a5..ae0c6810ca1 100644 --- a/searchlib/src/vespa/searchlib/engine/trace.cpp +++ b/searchlib/src/vespa/searchlib/engine/trace.cpp @@ -5,7 +5,7 @@ namespace search::engine { -fastos::TimeStamp +fastos::SteadyTimeStamp SteadyClock::now() const { return fastos::ClockSteady::now(); } @@ -38,7 +38,7 @@ Trace::Trace(const RelativeTime & relativeTime, uint32_t level) void Trace::start(int level) { if (shouldTrace(level) && !hasTrace()) { - root().setString("start_time_utc", _relativeTime.timeOfDawn().toString()); + root().setString("start_time_relative", _relativeTime.timeOfDawn().toString()); } } diff --git a/searchlib/src/vespa/searchlib/engine/trace.h b/searchlib/src/vespa/searchlib/engine/trace.h index f2b67d02df8..0d7dc2982f1 100644 --- a/searchlib/src/vespa/searchlib/engine/trace.h +++ b/searchlib/src/vespa/searchlib/engine/trace.h @@ -13,21 +13,21 @@ namespace search::engine { class Clock { public: virtual ~Clock() = default; - virtual fastos::TimeStamp now() const = 0; + virtual fastos::SteadyTimeStamp now() const = 0; }; class SteadyClock : public Clock { public: - fastos::TimeStamp now() const override; + fastos::SteadyTimeStamp now() const override; }; class CountingClock : public Clock { public: CountingClock(int64_t start, int64_t increment) : _increment(increment), _nextTime(start) { } - fastos::TimeStamp now() const override { + fastos::SteadyTimeStamp now() const override { int64_t prev = _nextTime; _nextTime += _increment; - return prev; + return fastos::SteadyTimeStamp(prev); } private: const int64_t _increment; @@ -37,12 +37,12 @@ private: class RelativeTime { public: RelativeTime(std::unique_ptr<Clock> clock); - fastos::TimeStamp timeOfDawn() const { return _start; } + fastos::SteadyTimeStamp timeOfDawn() const { return _start; } fastos::TimeStamp timeSinceDawn() const { return _clock->now() - _start; } - fastos::TimeStamp now() const { return _clock->now(); } + fastos::SteadyTimeStamp now() const { return _clock->now(); } private: - fastos::TimeStamp _start; - std::unique_ptr<Clock> _clock; + fastos::SteadyTimeStamp _start; + std::unique_ptr<Clock> _clock; }; /** diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp index 456d1919430..7d82fa706ca 100644 --- a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp @@ -2,14 +2,12 @@ #include <vespa/searchlib/queryeval/fake_requestcontext.h> -namespace search { -namespace queryeval { +namespace search::queryeval { -FakeRequestContext::FakeRequestContext(attribute::IAttributeContext * context, fastos::TimeStamp doom_in) : +FakeRequestContext::FakeRequestContext(attribute::IAttributeContext * context, fastos::SteadyTimeStamp doom_in) : _clock(), _doom(_clock, doom_in), _attributeContext(context) { } } -} diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h index d31cc9a7f9d..fefa7f5b6ff 100644 --- a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h +++ b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h @@ -7,13 +7,12 @@ #include <vespa/searchlib/attribute/attributevector.h> #include <limits> -namespace search { -namespace queryeval { +namespace search::queryeval { class FakeRequestContext : public IRequestContext { public: - FakeRequestContext(attribute::IAttributeContext * context = nullptr, fastos::TimeStamp doom=std::numeric_limits<int64_t>::max()); + FakeRequestContext(attribute::IAttributeContext * context = nullptr, fastos::SteadyTimeStamp doom=fastos::SteadyTimeStamp(fastos::TimeStamp::FUTURE)); const vespalib::Doom & getSoftDoom() const override { return _doom; } const attribute::IAttributeVector *getAttribute(const vespalib::string &name) const override { return _attributeContext @@ -32,4 +31,3 @@ private: }; } -} diff --git a/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp b/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp index 5e208864502..a9e1499f014 100644 --- a/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp +++ b/staging_vespalib/src/tests/array/allocinarray_benchmark.cpp @@ -111,7 +111,7 @@ Test::Main() count = strtol(_argv[2], NULL, 0); } TEST_INIT("allocinarray_benchmark"); - fastos::TimeStamp start(fastos::ClockSteady::now()); + fastos::SteadyTimeStamp start(fastos::ClockSteady::now()); if (type == "direct") { benchmarkTree(count); } else { diff --git a/staging_vespalib/src/tests/array/sort_benchmark.cpp b/staging_vespalib/src/tests/array/sort_benchmark.cpp index bdb96567f9e..03a99aa044f 100644 --- a/staging_vespalib/src/tests/array/sort_benchmark.cpp +++ b/staging_vespalib/src/tests/array/sort_benchmark.cpp @@ -100,7 +100,7 @@ Test::Main() payLoad = strtol(_argv[3], NULL, 0); } TEST_INIT("sort_benchmark"); - fastos::TimeStamp start(fastos::ClockSteady::now()); + fastos::SteadyTimeStamp start(fastos::ClockSteady::now()); if (payLoad < 8) { typedef TT<8> T; if (type == "sortdirect") { diff --git a/staging_vespalib/src/tests/clock/clock_test.cpp b/staging_vespalib/src/tests/clock/clock_test.cpp index b733869c39b..45f17bbba92 100644 --- a/staging_vespalib/src/tests/clock/clock_test.cpp +++ b/staging_vespalib/src/tests/clock/clock_test.cpp @@ -21,13 +21,13 @@ Test::Main() Clock clock(0.050); FastOS_ThreadPool pool(0x10000); ASSERT_TRUE(pool.NewThread(&clock, NULL) != NULL); - uint64_t start = clock.getTimeNS(); + fastos::SteadyTimeStamp start = clock.getTimeNS(); FastOS_Thread::Sleep(5000); - uint64_t stop = clock.getTimeNS(); + fastos::SteadyTimeStamp stop = clock.getTimeNS(); EXPECT_TRUE(stop > start); FastOS_Thread::Sleep(6000); clock.stop(); - uint64_t stop2 = clock.getTimeNS(); + fastos::SteadyTimeStamp stop2 = clock.getTimeNS(); EXPECT_TRUE(stop2 > stop); EXPECT_TRUE((stop2 - stop)/TimeStamp::MICRO > 1000); TEST_DONE(); diff --git a/staging_vespalib/src/tests/rusage/rusage_test.cpp b/staging_vespalib/src/tests/rusage/rusage_test.cpp index 503018ee70d..23b9d4072b1 100644 --- a/staging_vespalib/src/tests/rusage/rusage_test.cpp +++ b/staging_vespalib/src/tests/rusage/rusage_test.cpp @@ -30,12 +30,12 @@ Test::testRUsage() RUsage diff = r2-r1; EXPECT_EQUAL(diff.toString(), r2.toString()); { - RUsage then = RUsage::createSelf(7); + RUsage then = RUsage::createSelf(fastos::SteadyTimeStamp(7)); RUsage now = RUsage::createSelf(); EXPECT_NOT_EQUAL(now.toString(), then.toString()); } { - RUsage then = RUsage::createChildren(1337583); + RUsage then = RUsage::createChildren(fastos::SteadyTimeStamp(1337583)); RUsage now = RUsage::createChildren(); EXPECT_NOT_EQUAL(now.toString(), then.toString()); } diff --git a/staging_vespalib/src/vespa/vespalib/util/clock.h b/staging_vespalib/src/vespa/vespalib/util/clock.h index b44b1454cd4..43cea258d23 100644 --- a/staging_vespalib/src/vespa/vespalib/util/clock.h +++ b/staging_vespalib/src/vespa/vespalib/util/clock.h @@ -20,7 +20,7 @@ private: Clock(const Clock &); Clock & operator = (const Clock &); - mutable fastos::TimeStamp _timeNS; + mutable fastos::SteadyTimeStamp _timeNS; int _timePeriodMS; std::mutex _lock; std::condition_variable _cond; @@ -35,13 +35,13 @@ public: Clock(double timePeriod=0.100); ~Clock(); - fastos::TimeStamp getTimeNS() const { + fastos::SteadyTimeStamp getTimeNS() const { if (!_running) { setTime(); } return _timeNS; } - fastos::TimeStamp getTimeNSAssumeRunning() const { return _timeNS; } + fastos::SteadyTimeStamp getTimeNSAssumeRunning() const { return _timeNS; } void stop(); }; diff --git a/staging_vespalib/src/vespa/vespalib/util/doom.cpp b/staging_vespalib/src/vespa/vespalib/util/doom.cpp index aa737cc7464..df20981c584 100644 --- a/staging_vespalib/src/vespa/vespalib/util/doom.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/doom.cpp @@ -4,10 +4,10 @@ namespace vespalib { -Doom::Doom(const vespalib::Clock &clock, fastos::TimeStamp timeOfDoom) : +Doom::Doom(const vespalib::Clock &clock, fastos::SteadyTimeStamp timeOfDoom) : _clock(clock), _timeOfDoom(timeOfDoom) { } -} // namespace vespalib +} // namespace vespalib
\ No newline at end of file diff --git a/staging_vespalib/src/vespa/vespalib/util/doom.h b/staging_vespalib/src/vespa/vespalib/util/doom.h index 623cc23fcc8..ee0c1af3177 100644 --- a/staging_vespalib/src/vespa/vespalib/util/doom.h +++ b/staging_vespalib/src/vespa/vespalib/util/doom.h @@ -9,11 +9,11 @@ namespace vespalib { class Doom { private: - const vespalib::Clock &_clock; - fastos::TimeStamp _timeOfDoom; + const vespalib::Clock &_clock; + fastos::SteadyTimeStamp _timeOfDoom; public: - Doom(const vespalib::Clock &clock, fastos::TimeStamp timeOfDoom); + Doom(const vespalib::Clock &clock, fastos::SteadyTimeStamp timeOfDoom); bool doom() const { return (_clock.getTimeNSAssumeRunning() > _timeOfDoom); } diff --git a/staging_vespalib/src/vespa/vespalib/util/rusage.cpp b/staging_vespalib/src/vespa/vespalib/util/rusage.cpp index 96a9c7ef206..32f76775586 100644 --- a/staging_vespalib/src/vespa/vespalib/util/rusage.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/rusage.cpp @@ -30,37 +30,42 @@ RUsage::RUsage() : ru_nivcsw = 0; } -RUsage RUsage::createSelf() +RUsage +RUsage::createSelf() { - return createSelf(0); + return createSelf(fastos::SteadyTimeStamp()); } -RUsage RUsage::createChildren() +RUsage +RUsage::createChildren() { - return createChildren(0); + return createChildren(fastos::SteadyTimeStamp()); } -RUsage RUsage::createSelf(const fastos::TimeStamp & since) +RUsage +RUsage::createSelf(fastos::SteadyTimeStamp since) { RUsage r; - r._time = fastos::TimeStamp(fastos::ClockSteady::now()) - since; + r._time = fastos::ClockSteady::now() - since; if (getrusage(RUSAGE_SELF, &r) != 0) { throw std::runtime_error(vespalib::make_string("getrusage failed with errno = %d", errno).c_str()); } return r; } -RUsage RUsage::createChildren(const fastos::TimeStamp & since) +RUsage +RUsage::createChildren(fastos::SteadyTimeStamp since) { RUsage r; - r._time = fastos::TimeStamp(fastos::ClockSteady::now()) - since; + r._time = fastos::ClockSteady::now() - since; if (getrusage(RUSAGE_CHILDREN, &r) != 0) { throw std::runtime_error(vespalib::make_string("getrusage failed with errno = %d", errno).c_str()); } return r; } -vespalib::string RUsage::toString() +vespalib::string +RUsage::toString() { vespalib::string s; if (_time.sec() != 0.0) s += make_string("duration = %1.6f\n", _time.sec()); diff --git a/staging_vespalib/src/vespa/vespalib/util/rusage.h b/staging_vespalib/src/vespa/vespalib/util/rusage.h index 07b0c5814bc..381d4d764e7 100644 --- a/staging_vespalib/src/vespa/vespalib/util/rusage.h +++ b/staging_vespalib/src/vespa/vespalib/util/rusage.h @@ -17,12 +17,12 @@ public: * Will create an RUsage and initialize member with RUSAGE_SELF **/ static RUsage createSelf(); - static RUsage createSelf(const fastos::TimeStamp & since); + static RUsage createSelf(fastos::SteadyTimeStamp since); /** * Will create an RUsage and initialize member with RUSAGE_CHILDREN **/ static RUsage createChildren(); - static RUsage createChildren(const fastos::TimeStamp & since); + static RUsage createChildren(fastos::SteadyTimeStamp since); /** * Will create an RUsage and initialize member with RUSAGE_CHILDREN **/ diff --git a/vespalib/src/vespa/vespalib/util/time_tracker.h b/vespalib/src/vespa/vespalib/util/time_tracker.h index d9d661bcf30..99f88d69110 100644 --- a/vespalib/src/vespa/vespalib/util/time_tracker.h +++ b/vespalib/src/vespa/vespalib/util/time_tracker.h @@ -17,7 +17,7 @@ private: vespalib::string name; fastos::StopWatch task_time; std::vector<Task> sub_tasks; - Task(const char *name_in) : name(name_in), task_time() { task_time.start(); } + Task(const char *name_in) : name(name_in), task_time() { } ~Task(); void close_task() { task_time.stop(); } double ms() const { return (task_time.elapsed().sec() * 1000.0); } |