diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-12-06 20:17:56 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-12-09 20:43:38 +0000 |
commit | 9156592055b871be41b1f634ee37842854dc73a4 (patch) | |
tree | 9fe512730a78b950ed07ee7f84a330821a109062 /searchcore | |
parent | 3a8c63f34d8554573b42b0c3749e44ad4f43fb0e (diff) |
Use std::chrono.
Diffstat (limited to 'searchcore')
35 files changed, 146 insertions, 149 deletions
diff --git a/searchcore/src/tests/grouping/grouping.cpp b/searchcore/src/tests/grouping/grouping.cpp index edaa8792d6c..667f83d18f9 100644 --- a/searchcore/src/tests/grouping/grouping.cpp +++ b/searchcore/src/tests/grouping/grouping.cpp @@ -22,7 +22,8 @@ using namespace search::grouping; using namespace search; using search::attribute::test::MockAttributeContext; using proton::matching::SessionManager; -using fastos::SteadyTimeStamp; +using vespalib::steady_time; +using vespalib::duration; //----------------------------------------------------------------------------- @@ -111,8 +112,8 @@ private: struct DoomFixture { vespalib::Clock clock; - fastos::SteadyTimeStamp timeOfDoom; - DoomFixture() : clock(), timeOfDoom(fastos::SteadyTimeStamp::FUTURE) {} + steady_time timeOfDoom; + DoomFixture() : clock(), timeOfDoom(steady_time::max()) {} }; //----------------------------------------------------------------------------- @@ -472,24 +473,24 @@ TEST_F("test session timeout", DoomFixture()) { SessionId id1("foo"); SessionId id2("bar"); - GroupingContext initContext1(f1.clock, SteadyTimeStamp(10)); - GroupingContext initContext2(f1.clock, SteadyTimeStamp(20)); + GroupingContext initContext1(f1.clock, steady_time(duration(10))); + GroupingContext initContext2(f1.clock, steady_time(duration(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(SteadyTimeStamp(5)); + mgr.pruneTimedOutSessions(steady_time(duration(5))); SessionManager::Stats stats(mgr.getGroupingStats()); ASSERT_EQUAL(2u, stats.numCached); - mgr.pruneTimedOutSessions(SteadyTimeStamp(10)); + mgr.pruneTimedOutSessions(steady_time(duration(10))); stats = mgr.getGroupingStats(); ASSERT_EQUAL(2u, stats.numCached); - mgr.pruneTimedOutSessions(SteadyTimeStamp(11)); + mgr.pruneTimedOutSessions(steady_time(duration(11))); stats = mgr.getGroupingStats(); ASSERT_EQUAL(1u, stats.numCached); - mgr.pruneTimedOutSessions(SteadyTimeStamp(21)); + mgr.pruneTimedOutSessions(steady_time(duration(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 74d65a5bf7f..0fc290c9d2c 100644 --- a/searchcore/src/tests/proton/common/cachedselect_test.cpp +++ b/searchcore/src/tests/proton/common/cachedselect_test.cpp @@ -617,7 +617,7 @@ TEST_F("Test performance when using attributes", TestFixture) uint32_t i; const uint32_t loopcnt = 30000; LOG(info, "Starting minibm loop, %u ierations of 4 docs each", loopcnt); - fastos::StopWatch sw; + vespalib::Timer sw; for (i = 0; i < loopcnt; ++i) { ctx._docId = 1u; if (sel->contains(ctx) != Result::False) @@ -632,11 +632,11 @@ TEST_F("Test performance when using attributes", TestFixture) if (sel->contains(ctx) != Result::Invalid) break; } - fastos::TimeStamp elapsed = sw.elapsed(); + vespalib::duration elapsed = sw.elapsed(); EXPECT_EQUAL(loopcnt, i); LOG(info, "Elapsed time for %u iterations of 4 docs each: %" PRId64 " ns, %8.4f ns/doc", - i, elapsed.ns(), static_cast<double>(elapsed.ns()) / ( 4 * i)); + i, vespalib::count_ns(elapsed), static_cast<double>(vespalib::count_ns(elapsed)) / ( 4 * i)); } diff --git a/searchcore/src/tests/proton/docsummary/docsummary.cpp b/searchcore/src/tests/proton/docsummary/docsummary.cpp index 637ce90c72e..3e86e703e1e 100644 --- a/searchcore/src/tests/proton/docsummary/docsummary.cpp +++ b/searchcore/src/tests/proton/docsummary/docsummary.cpp @@ -646,7 +646,7 @@ Test::requireThatSummariesTimeout() 1); DocsumRequest req; - req.setTimeout(0); + req.setTimeout(vespalib::duration::zero()); EXPECT_TRUE(req.expired()); req.resultClassName = "class2"; req.hits.push_back(DocsumRequest::Hit(gid1)); diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp index fdb7488bf65..0720f59471b 100644 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp +++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp @@ -197,7 +197,7 @@ struct MySessionCachePruner : public ISessionCachePruner { bool isInvoked; MySessionCachePruner() : isInvoked(false) { } - void pruneTimedOutSessions(fastos::SteadyTimeStamp current) override { + void pruneTimedOutSessions(vespalib::steady_time current) override { (void) current; isInvoked = true; } diff --git a/searchcore/src/tests/proton/index/indexcollection_test.cpp b/searchcore/src/tests/proton/index/indexcollection_test.cpp index 7a42fe574c2..113901e893f 100644 --- a/searchcore/src/tests/proton/index/indexcollection_test.cpp +++ b/searchcore/src/tests/proton/index/indexcollection_test.cpp @@ -75,7 +75,7 @@ public: } IndexCollection::UP create_warmup(const IndexCollection::SP& prev, const IndexCollection::SP& next) { - return std::make_unique<WarmupIndexCollection>(WarmupConfig(1.0, false), prev, next, *_warmup, _executor, *this); + return std::make_unique<WarmupIndexCollection>(WarmupConfig(1s, false), prev, next, *_warmup, _executor, *this); } virtual void warmupDone(ISearchableIndexCollection::SP current) override { @@ -90,7 +90,7 @@ public: _executor(1, 128*1024), _warmup(new FakeIndexSearchable) {} - ~IndexCollectionTest() {} + ~IndexCollectionTest() = default; }; 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 478cf0b2f98..2d0482b0d92 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,9 +289,9 @@ 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(10000000), 1700000L)); + RelativeTime clock(std::make_unique<CountingClock>(vespalib::count_ns(10000000s), 1700000L)); Trace trace(clock, 7); - trace.start(4); + trace.start(4, false); SearchIterator::UP search = limiter.maybe_limit(prepare(new MockSearch("search")), 0.1, 100000, trace.maybeCreateCursor(7, "limit")); limiter.updateDocIdSpaceEstimate(1000, 9000); EXPECT_EQUAL(1680u, limiter.getDocIdSpaceEstimate()); @@ -315,7 +315,7 @@ TEST("require that the match phase limiter is able to pre-limit the query") { trace.done(); verify( "{" - " start_time_relative: '1970-04-26 17:46:40.000 UTC'," + " start_time: '1970-04-26 17:46:40.000 UTC'," " traces: [" " {" " timestamp_ms: 1.7," diff --git a/searchcore/src/tests/proton/matching/matching_stats_test.cpp b/searchcore/src/tests/proton/matching/matching_stats_test.cpp index 9bf627a6289..0d7778274b8 100644 --- a/searchcore/src/tests/proton/matching/matching_stats_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_stats_test.cpp @@ -150,7 +150,7 @@ TEST("requireThatPartitionsAreAddedCorrectly") { EXPECT_EQUAL(0u, all1.docsMatched()); EXPECT_EQUAL(0u, all1.getNumPartitions()); EXPECT_EQUAL(0u, all1.softDoomed()); - EXPECT_EQUAL(0u, all1.doomOvertime()); + EXPECT_EQUAL(vespalib::duration::zero(), all1.doomOvertime()); MatchingStats::Partition subPart; subPart.docsCovered(7).docsMatched(3).docsRanked(2).docsReRanked(1) @@ -158,8 +158,8 @@ TEST("requireThatPartitionsAreAddedCorrectly") { EXPECT_EQUAL(0u, subPart.softDoomed()); EXPECT_EQUAL(0u, subPart.softDoomed(false).softDoomed()); EXPECT_EQUAL(1u, subPart.softDoomed(true).softDoomed()); - EXPECT_EQUAL(0l, subPart.doomOvertime()); - EXPECT_EQUAL(1000, subPart.doomOvertime(1000).doomOvertime()); + EXPECT_EQUAL(vespalib::duration::zero(), subPart.doomOvertime()); + EXPECT_EQUAL(1000ns, subPart.doomOvertime(1000ns).doomOvertime()); EXPECT_EQUAL(7u, subPart.docsCovered()); EXPECT_EQUAL(3u, subPart.docsMatched()); EXPECT_EQUAL(2u, subPart.docsRanked()); @@ -180,7 +180,7 @@ TEST("requireThatPartitionsAreAddedCorrectly") { EXPECT_EQUAL(1u, all1.docsReRanked()); EXPECT_EQUAL(1u, all1.getNumPartitions()); EXPECT_EQUAL(1u, all1.softDoomed()); - EXPECT_EQUAL(1000, all1.doomOvertime()); + EXPECT_EQUAL(1000ns, all1.doomOvertime()); EXPECT_EQUAL(7u, all1.getPartition(0).docsCovered()); EXPECT_EQUAL(3u, all1.getPartition(0).docsMatched()); EXPECT_EQUAL(2u, all1.getPartition(0).docsRanked()); @@ -194,14 +194,14 @@ TEST("requireThatPartitionsAreAddedCorrectly") { EXPECT_EQUAL(1.0, all1.getPartition(0).active_time_max()); EXPECT_EQUAL(0.5, all1.getPartition(0).wait_time_max()); EXPECT_EQUAL(1u, all1.getPartition(0).softDoomed()); - EXPECT_EQUAL(1000, all1.getPartition(0).doomOvertime()); + EXPECT_EQUAL(1000ns, all1.getPartition(0).doomOvertime()); MatchingStats::Partition otherSubPart; otherSubPart.docsCovered(7).docsMatched(3).docsRanked(2).docsReRanked(1) - .active_time(0.5).wait_time(1.0).softDoomed(true).doomOvertime(300); + .active_time(0.5).wait_time(1.0).softDoomed(true).doomOvertime(300ns); all1.merge_partition(otherSubPart, 1); EXPECT_EQUAL(1u, all1.softDoomed()); - EXPECT_EQUAL(1000, all1.doomOvertime()); + EXPECT_EQUAL(1000ns, all1.doomOvertime()); EXPECT_EQUAL(14u, all1.docidSpaceCovered()); EXPECT_EQUAL(6u, all1.docsMatched()); EXPECT_EQUAL(4u, all1.docsRanked()); @@ -219,7 +219,7 @@ TEST("requireThatPartitionsAreAddedCorrectly") { EXPECT_EQUAL(0.5, all1.getPartition(1).active_time_max()); EXPECT_EQUAL(1.0, all1.getPartition(1).wait_time_max()); EXPECT_EQUAL(1u, all1.getPartition(1).softDoomed()); - EXPECT_EQUAL(300, all1.getPartition(1).doomOvertime()); + EXPECT_EQUAL(300ns, all1.getPartition(1).doomOvertime()); MatchingStats all2; all2.merge_partition(otherSubPart, 0); @@ -227,7 +227,7 @@ TEST("requireThatPartitionsAreAddedCorrectly") { all1.add(all2); EXPECT_EQUAL(2u, all1.softDoomed()); - EXPECT_EQUAL(1000, all1.doomOvertime()); + EXPECT_EQUAL(1000ns, all1.doomOvertime()); EXPECT_EQUAL(28u, all1.docidSpaceCovered()); EXPECT_EQUAL(12u, all1.docsMatched()); EXPECT_EQUAL(8u, all1.docsRanked()); @@ -245,7 +245,7 @@ TEST("requireThatPartitionsAreAddedCorrectly") { EXPECT_EQUAL(1.0, all1.getPartition(0).active_time_max()); EXPECT_EQUAL(1.0, all1.getPartition(0).wait_time_max()); EXPECT_EQUAL(2u, all1.getPartition(0).softDoomed()); - EXPECT_EQUAL(1000, all1.getPartition(0).doomOvertime()); + EXPECT_EQUAL(1000ns, all1.getPartition(0).doomOvertime()); EXPECT_EQUAL(6u, all1.getPartition(1).docsMatched()); EXPECT_EQUAL(4u, all1.getPartition(1).docsRanked()); EXPECT_EQUAL(2u, all1.getPartition(1).docsReRanked()); @@ -258,7 +258,7 @@ TEST("requireThatPartitionsAreAddedCorrectly") { EXPECT_EQUAL(1.0, all1.getPartition(1).active_time_max()); EXPECT_EQUAL(1.0, all1.getPartition(1).wait_time_max()); EXPECT_EQUAL(2u, all1.getPartition(1).softDoomed()); - EXPECT_EQUAL(1000, all1.getPartition(1).doomOvertime()); + EXPECT_EQUAL(1000ns, all1.getPartition(1).doomOvertime()); } TEST("requireThatSoftDoomIsSetAndAdded") { @@ -280,19 +280,19 @@ TEST("requireThatSoftDoomFacorIsComputedCorrectlyForDownAdjustment") { EXPECT_EQUAL(0ul, stats.softDoomed()); EXPECT_EQUAL(0.5, stats.softDoomFactor()); stats.softDoomed(1); - stats.updatesoftDoomFactor(1.0, 0.5, 2.0); + stats.updatesoftDoomFactor(1000ms, 500ms, 2000ms); EXPECT_EQUAL(1ul, stats.softDoomed()); EXPECT_EQUAL(0.47, stats.softDoomFactor()); - stats.updatesoftDoomFactor(1.0, 0.5, 2.0); + stats.updatesoftDoomFactor(1000ms, 500ms, 2000ms); EXPECT_EQUAL(1ul, stats.softDoomed()); EXPECT_EQUAL(0.44, stats.softDoomFactor()); - stats.updatesoftDoomFactor(0.0009, 0.5, 2.0); // hard limits less than 1ms should be ignored + stats.updatesoftDoomFactor(900us, 500ms, 2000ms); // hard limits less than 1ms should be ignored EXPECT_EQUAL(1ul, stats.softDoomed()); EXPECT_EQUAL(0.44, stats.softDoomFactor()); - stats.updatesoftDoomFactor(1.0, 0.0009, 2.0); // soft limits less than 1ms should be ignored + stats.updatesoftDoomFactor(1000ms, 900us, 2000ms); // soft limits less than 1ms should be ignored EXPECT_EQUAL(1ul, stats.softDoomed()); EXPECT_EQUAL(0.44, stats.softDoomFactor()); - stats.updatesoftDoomFactor(1.0, 0.5, 10.0); // Prevent changes above 10% + stats.updatesoftDoomFactor(1000ms, 500ms, 10s); // Prevent changes above 10% EXPECT_EQUAL(1ul, stats.softDoomed()); EXPECT_EQUAL(0.396, stats.softDoomFactor()); } @@ -302,20 +302,20 @@ TEST("requireThatSoftDoomFacorIsComputedCorrectlyForUpAdjustment") { EXPECT_EQUAL(0ul, stats.softDoomed()); EXPECT_EQUAL(0.5, stats.softDoomFactor()); stats.softDoomed(1); - stats.updatesoftDoomFactor(1.0, 0.9, 0.1); + stats.updatesoftDoomFactor(1s, 900ms, 100ms); EXPECT_EQUAL(1ul, stats.softDoomed()); EXPECT_EQUAL(0.508, stats.softDoomFactor()); - stats.updatesoftDoomFactor(1.0, 0.9, 0.1); + stats.updatesoftDoomFactor(1s, 900ms, 100ms); EXPECT_EQUAL(1ul, stats.softDoomed()); EXPECT_EQUAL(0.516, stats.softDoomFactor()); - stats.updatesoftDoomFactor(0.0009, 0.9, 0.1); // hard limits less than 1ms should be ignored + stats.updatesoftDoomFactor(900us, 900ms, 100ms); // hard limits less than 1ms should be ignored EXPECT_EQUAL(1ul, stats.softDoomed()); EXPECT_EQUAL(0.516, stats.softDoomFactor()); - stats.updatesoftDoomFactor(1.0, 0.0009, 0.1); // soft limits less than 1ms should be ignored + stats.updatesoftDoomFactor(1s, 900us, 100ms); // soft limits less than 1ms should be ignored EXPECT_EQUAL(1ul, stats.softDoomed()); EXPECT_EQUAL(0.516, stats.softDoomFactor()); stats.softDoomFactor(0.1); - stats.updatesoftDoomFactor(1.0, 0.9, 0.001); // Prevent changes above 5% + stats.updatesoftDoomFactor(1s, 900ms, 1ms); // Prevent changes above 5% EXPECT_EQUAL(1ul, stats.softDoomed()); EXPECT_EQUAL(0.105, stats.softDoomFactor()); } diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp index 88705e73bc5..8c4bf0d55b0 100644 --- a/searchcore/src/tests/proton/matching/matching_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_test.cpp @@ -261,7 +261,7 @@ struct MyWorld { static SearchRequest::SP createRequest(const vespalib::string &stack_dump) { SearchRequest::SP request(new SearchRequest); - request->setTimeout(60 * fastos::TimeStamp::SEC); + request->setTimeout(60s); setStackDump(*request, stack_dump); request->maxhits = 10; return request; @@ -768,8 +768,7 @@ TEST("require that getSummaryFeatures prefers cached query setup") { ASSERT_EQUAL(0u, fs->numDocs()); // "spread" has no hits // Empty cache - auto pruneTime = fastos::ClockSteady::now() + - fastos::TimeStamp::MINUTE * 10; + auto pruneTime = vespalib::steady_clock::now() + 600s; world.sessionManager->pruneTimedOutSessions(pruneTime); fs = world.getSummaryFeatures(req); diff --git a/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp b/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp index 3152b737ea7..109a4cc7a25 100644 --- a/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp +++ b/searchcore/src/tests/proton/matching/request_context/request_context_test.cpp @@ -42,7 +42,7 @@ private: public: RequestContextTest() : _clock(), - _doom(_clock, fastos::SteadyTimeStamp::ZERO, fastos::SteadyTimeStamp::ZERO, false), + _doom(_clock, vespalib::steady_time(), vespalib::steady_time(), false), _attr_ctx(), _props(), _request_ctx(_doom, _attr_ctx, _props), diff --git a/searchcore/src/tests/proton/matching/sessionmanager_test.cpp b/searchcore/src/tests/proton/matching/sessionmanager_test.cpp index 5998b165b51..f3edf2bf747 100644 --- a/searchcore/src/tests/proton/matching/sessionmanager_test.cpp +++ b/searchcore/src/tests/proton/matching/sessionmanager_test.cpp @@ -18,7 +18,7 @@ using vespalib::string; using namespace proton; using namespace proton::matching; using vespalib::StateExplorer; -using fastos::SteadyTimeStamp; +using vespalib::steady_time; namespace { @@ -35,8 +35,8 @@ void checkStats(SessionManager::Stats stats, uint32_t numInsert, TEST("require that SessionManager handles SearchSessions.") { string session_id("foo"); - SteadyTimeStamp start(100); - SteadyTimeStamp doom(1000); + steady_time start(100ns); + steady_time doom(1000ns); MatchToolsFactory::UP mtf; SearchSession::OwnershipBundle owned_objects; auto session = std::make_shared<SearchSession>(session_id, start, doom, std::move(mtf), std::move(owned_objects)); @@ -50,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(SteadyTimeStamp(500)); + session_manager.pruneTimedOutSessions(steady_time(500ns)); TEST_DO(checkStats(session_manager.getSearchStats(), 0, 0, 0, 1, 0)); - session_manager.pruneTimedOutSessions(SteadyTimeStamp(2000)); + session_manager.pruneTimedOutSessions(steady_time(2000ns)); TEST_DO(checkStats(session_manager.getSearchStats(), 0, 0, 0, 0, 1)); session = session_manager.pickSearch(session_id); @@ -60,8 +60,8 @@ TEST("require that SessionManager handles SearchSessions.") { } TEST("require that SessionManager can be explored") { - SteadyTimeStamp start(100); - SteadyTimeStamp doom(1000); + steady_time start(100ns); + steady_time doom(1000ns); SessionManager session_manager(10); session_manager.insert(std::make_shared<SearchSession>("foo", start, doom, MatchToolsFactory::UP(), SearchSession::OwnershipBundle())); diff --git a/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp b/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp index 41eda598726..549b2d2626a 100644 --- a/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp +++ b/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp @@ -9,7 +9,6 @@ using fastos::TimeStamp; using vespalib::system_time; -using fastos::SteadyTimeStamp; using search::SerialNum; using namespace proton; using namespace searchcorespi; diff --git a/searchcore/src/vespa/searchcore/grouping/groupingcontext.cpp b/searchcore/src/vespa/searchcore/grouping/groupingcontext.cpp index 3869ffe8a6a..5c9321a6ff3 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::SteadyTimeStamp timeOfDoom, const char *groupSpec, uint32_t groupSpecLen) : +GroupingContext::GroupingContext(const vespalib::Clock & clock, vespalib::steady_time timeOfDoom, const char *groupSpec, uint32_t groupSpecLen) : _clock(clock), _timeOfDoom(timeOfDoom), _os(), @@ -59,7 +59,7 @@ GroupingContext::GroupingContext(const vespalib::Clock & clock, fastos::SteadyTi deserialize(groupSpec, groupSpecLen); } -GroupingContext::GroupingContext(const vespalib::Clock & clock, fastos::SteadyTimeStamp timeOfDoom) : +GroupingContext::GroupingContext(const vespalib::Clock & clock, vespalib::steady_time 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 eb6afca5f59..3ec16fab2cc 100644 --- a/searchcore/src/vespa/searchcore/grouping/groupingcontext.h +++ b/searchcore/src/vespa/searchcore/grouping/groupingcontext.h @@ -3,6 +3,7 @@ #include <vespa/searchlib/aggregation/grouping.h> #include <vespa/vespalib/objects/nbostream.h> +#include <vespa/vespalib/util/time.h> #include <vector> #include <memory> @@ -21,10 +22,10 @@ public: using GroupingList = std::vector<GroupingPtr>; private: - const vespalib::Clock & _clock; - fastos::SteadyTimeStamp _timeOfDoom; - vespalib::nbostream _os; - GroupingList _groupingList; + const vespalib::Clock & _clock; + vespalib::steady_time _timeOfDoom; + vespalib::nbostream _os; + GroupingList _groupingList; public: /** @@ -40,14 +41,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::SteadyTimeStamp timeOfDoom, const char *groupSpec, uint32_t groupSpecLen); + GroupingContext(const vespalib::Clock & clock, vespalib::steady_time 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::SteadyTimeStamp timeOfDoom); + GroupingContext(const vespalib::Clock & clock, vespalib::steady_time timeOfDoom); /** * Shallow copy of references @@ -105,7 +106,7 @@ public: /** * Obtain the time of doom. */ - fastos::SteadyTimeStamp getTimeOfDoom() const { return _timeOfDoom; } + vespalib::steady_time 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 055fd41f0e1..70953f212d1 100644 --- a/searchcore/src/vespa/searchcore/grouping/groupingsession.h +++ b/searchcore/src/vespa/searchcore/grouping/groupingsession.h @@ -3,7 +3,7 @@ #include "sessionid.h" #include <vespa/searchlib/attribute/iattributemanager.h> -#include <vespa/fastos/timestamp.h> +#include <vespa/vespalib/util/time.h> #include <vector> #include <map> @@ -30,7 +30,7 @@ private: std::unique_ptr<GroupingContext> _mgrContext; std::unique_ptr<GroupingManager> _groupingManager; GroupingMap _groupingMap; - fastos::SteadyTimeStamp _timeOfDoom; + vespalib::steady_time _timeOfDoom; public: typedef std::unique_ptr<GroupingSession> UP; @@ -108,7 +108,7 @@ public: /** * Get this sessions timeout. */ - fastos::SteadyTimeStamp getTimeOfDoom() const { return _timeOfDoom; } + vespalib::steady_time getTimeOfDoom() const { return _timeOfDoom; } }; } diff --git a/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.cpp b/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.cpp index e19719fa966..872b4b27584 100644 --- a/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.cpp +++ b/searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.cpp @@ -78,7 +78,7 @@ DocsumContext::createReply() Slime slime(Slime::Params(std::move(symbols))); vespalib::slime::SlimeInserter inserter(slime); if (_request.expired()) { - inserter.insertString(make_string("Timed out with %" PRId64 "us left.", _request.getTimeLeft().us())); + inserter.insertString(make_string("Timed out with %" PRId64 "us left.", vespalib::count_us(_request.getTimeLeft()))); } else { _docsumWriter.insertDocsum(rci, docId, &_docsumState, &_docsumStore, slime, inserter); } @@ -129,7 +129,7 @@ DocsumContext::createSlimeReply() Cursor & timeout = errors.addObject(); timeout.setString(TYPE, TIMEOUT); timeout.setString(MESSAGE, make_string("Timed out %d summaries with %" PRId64 "us left.", - numTimedOut, _request.getTimeLeft().us())); + numTimedOut, vespalib::count_us(_request.getTimeLeft()))); } return response; } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp index c4b6d88c1c3..a1a8297d5c0 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp @@ -44,14 +44,14 @@ DocumentMetaStoreInitializer::run() vespalib::string attrFileName = _baseDir + "/" + snap.dirName + "/" + name; _dms->setBaseFileName(attrFileName); assert(_dms->hasLoadData()); - fastos::StopWatch stopWatch; + vespalib::Timer stopWatch; EventLogger::loadDocumentMetaStoreStart(_subDbName); if (!_dms->load()) { throw IllegalStateException(failedMsg(_docTypeName.c_str())); } else { _dms->commit(snap.syncToken, snap.syncToken); } - EventLogger::loadDocumentMetaStoreComplete(_subDbName, stopWatch.elapsed().ms()); + EventLogger::loadDocumentMetaStoreComplete(_subDbName, vespalib::count_ms(stopWatch.elapsed())); } } else { vespalib::mkdir(_baseDir, false); diff --git a/searchcore/src/vespa/searchcore/proton/matching/fakesearchcontext.cpp b/searchcore/src/vespa/searchcore/proton/matching/fakesearchcontext.cpp index c7a75bff9ca..5758b9a796f 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/fakesearchcontext.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/fakesearchcontext.cpp @@ -6,7 +6,7 @@ namespace proton::matching { FakeSearchContext::FakeSearchContext(size_t initialNumDocs) : _clock(), - _doom(_clock, fastos::SteadyTimeStamp::ZERO), + _doom(_clock, vespalib::steady_time()), _selector(new search::FixedSourceSelector(0, "fs", initialNumDocs)), _indexes(new IndexCollection(_selector)), _attrSearchable(), diff --git a/searchcore/src/vespa/searchcore/proton/matching/isessioncachepruner.h b/searchcore/src/vespa/searchcore/proton/matching/isessioncachepruner.h index 2d38ec13cda..a34e7211de7 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/isessioncachepruner.h +++ b/searchcore/src/vespa/searchcore/proton/matching/isessioncachepruner.h @@ -2,14 +2,14 @@ #pragma once -#include <vespa/fastos/timestamp.h> +#include <vespa/vespalib/util/time.h> namespace proton::matching { struct ISessionCachePruner { virtual ~ISessionCachePruner() {} - virtual void pruneTimedOutSessions(fastos::SteadyTimeStamp currentTime) = 0; + virtual void pruneTimedOutSessions(vespalib::steady_time 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 370569276d5..3cbf88facd5 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp @@ -26,20 +26,20 @@ namespace { struct TimedMatchLoopCommunicator : IMatchLoopCommunicator { IMatchLoopCommunicator &communicator; - fastos::StopWatch rerank_time; - fastos::TimeStamp elapsed; - TimedMatchLoopCommunicator(IMatchLoopCommunicator &com) : communicator(com) {} + vespalib::Timer timer; + vespalib::duration elapsed; + TimedMatchLoopCommunicator(IMatchLoopCommunicator &com) : communicator(com), elapsed(vespalib::duration::zero()) {} double estimate_match_frequency(const Matches &matches) override { return communicator.estimate_match_frequency(matches); } Hits selectBest(SortedHitSequence sortedHits) override { auto result = communicator.selectBest(sortedHits); - rerank_time.restart(); + timer = vespalib::Timer(); return result; } RangePair rangeCover(const RangePair &ranges) override { RangePair result = communicator.rangeCover(ranges); - elapsed = rerank_time.elapsed(); + elapsed = timer.elapsed(); return result; } }; @@ -67,7 +67,7 @@ MatchMaster::match(search::engine::Trace & trace, uint32_t distributionKey, uint32_t numSearchPartitions) { - fastos::StopWatch query_latency_time; + vespalib::Timer query_latency_time; vespalib::DualMergeDirector mergeDirector(threadBundle.size()); MatchLoopCommunicator communicator(threadBundle.size(), params.heapSize, mtf.createDiversifier(params.heapSize)); TimedMatchLoopCommunicator timedCommunicator(communicator); @@ -87,8 +87,8 @@ MatchMaster::match(search::engine::Trace & trace, resultProcessor.prepareThreadContextCreation(threadBundle.size()); threadBundle.run(targets); ResultProcessor::Result::UP reply = resultProcessor.makeReply(threadState[0]->extract_result()); - double query_time_s = query_latency_time.elapsed().sec(); - double rerank_time_s = timedCommunicator.elapsed.sec(); + double query_time_s = vespalib::to_s(query_latency_time.elapsed()); + double rerank_time_s = vespalib::to_s(timedCommunicator.elapsed); double match_time_s = 0.0; std::unique_ptr<vespalib::slime::Inserter> inserter; if (trace.shouldTrace(4)) { diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp index a0381af29a8..7c5e7584eed 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp @@ -34,12 +34,12 @@ namespace { struct WaitTimer { double &wait_time_s; - fastos::StopWatch wait_time; + vespalib::Timer wait_time; WaitTimer(double &wait_time_s_in) : wait_time_s(wait_time_s_in), wait_time() { } void done() { - wait_time_s += wait_time.elapsed().sec(); + wait_time_s += vespalib::to_s(wait_time.elapsed()); } }; @@ -184,7 +184,7 @@ MatchThread::match_loop(MatchTools &tools, HitCollector &hits) { bool softDoomed = false; uint32_t docsCovered = 0; - fastos::TimeStamp overtime(0); + vespalib::duration overtime(vespalib::duration::zero()); Context context(matchParams.rankDropLimit, tools, hits, num_threads); for (DocidRange docid_range = scheduler.first_range(thread_id); !docid_range.empty(); @@ -425,12 +425,12 @@ MatchThread::MatchThread(size_t thread_id_in, void MatchThread::run() { - fastos::StopWatch total_time; - fastos::StopWatch match_time; + vespalib::Timer total_time; + vespalib::Timer match_time(total_time); trace->addEvent(4, "Start MatchThread::run"); MatchTools::UP matchTools = matchToolsFactory.createMatchTools(); search::ResultSet::UP result = findMatches(*matchTools); - match_time_s = match_time.elapsed().sec(); + match_time_s = vespalib::to_s(match_time.elapsed()); resultContext = resultProcessor.createThreadContext(matchTools->getDoom(), thread_id, _distributionKey); { trace->addEvent(5, "Wait for result processing token"); @@ -445,7 +445,7 @@ MatchThread::run() trace->addEvent(5, "Start result processing"); processResult(matchTools->getDoom(), std::move(result), *resultContext); } - total_time_s = total_time.elapsed().sec(); + total_time_s = vespalib::to_s(total_time.elapsed()); thread_stats.active_time(total_time_s - wait_time_s).wait_time(wait_time_s); trace->addEvent(4, "Start thread merge"); mergeDirector.dualMerge(thread_id, *resultContext->result, resultContext->groupingSource); diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.h b/searchcore/src/vespa/searchcore/proton/matching/match_thread.h index 7ecbfef634e..66bd8d29c2f 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.h +++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.h @@ -74,7 +74,7 @@ private: bool isBelowLimit() const { return matches < _matches_limit; } bool isAtLimit() const { return matches == _matches_limit; } bool atSoftDoom() const { return _doom.soft_doom(); } - fastos::TimeStamp timeLeft() const { return _doom.soft_left(); } + vespalib::duration timeLeft() const { return _doom.soft_left(); } uint32_t matches; private: uint32_t _matches_limit; diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp index 426bb353826..0be67a424ee 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp @@ -134,11 +134,11 @@ Matcher::create_match_tools_factory(const search::engine::Request &request, ISea ? Factor::lookup(rankProperties, _stats.softDoomFactor()) : _stats.softDoomFactor()) : 0.95; - int64_t safeLeft = request.getTimeLeft() * factor; - fastos::SteadyTimeStamp safeDoom(_clock.getTimeNSAssumeRunning() + safeLeft); + vespalib::duration safeLeft = std::chrono::duration_cast<vespalib::duration>(request.getTimeLeft() * factor); + vespalib::steady_time safeDoom(_clock.getTimeNSAssumeRunning() + safeLeft); if (softTimeoutEnabled) { LOG(debug, "Soft-timeout computed factor=%1.3f, used factor=%1.3f, userSupplied=%d, softTimeout=%" PRId64, - _stats.softDoomFactor(), factor, hasFactorOverride, safeLeft); + _stats.softDoomFactor(), factor, hasFactorOverride, vespalib::count_ns(safeLeft)); } vespalib::Doom doom(_clock, safeDoom, request.getTimeOfDoom(), hasFactorOverride); return std::make_unique<MatchToolsFactory>(_queryLimiter, doom, searchContext, attrContext, request.getStackRef(), @@ -288,15 +288,15 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl } my_stats.queryCollateralTime(total_matching_time.elapsed().sec() - my_stats.queryLatencyAvg()); { - fastos::TimeStamp duration = request.getTimeUsed(); + vespalib::duration duration = request.getTimeUsed(); std::lock_guard<std::mutex> guard(_statsLock); _stats.add(my_stats); if (my_stats.softDoomed()) { double old = _stats.softDoomFactor(); - fastos::TimeStamp overtimeLimit = (1.0 - _rankSetup->getSoftTimeoutTailCost()) * request.getTimeout(); - fastos::TimeStamp adjustedDuration = duration - my_stats.doomOvertime(); - if (adjustedDuration < 0) { - adjustedDuration = 0; + vespalib::duration overtimeLimit = std::chrono::duration_cast<vespalib::duration>((1.0 - _rankSetup->getSoftTimeoutTailCost()) * request.getTimeout()); + vespalib::duration adjustedDuration = duration - my_stats.doomOvertime(); + if (adjustedDuration < vespalib::duration::zero()) { + adjustedDuration = vespalib::duration::zero(); } bool allowedSoftTimeoutFactorAdjustment = (std::chrono::duration_cast<std::chrono::seconds>(my_clock::now() - _startTime).count() > SECONDS_BEFORE_ALLOWING_SOFT_TIMEOUT_FACTOR_ADJUSTMENT) && ! isDoomExplicit; @@ -307,7 +307,7 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl ", factor %sadjusted from %1.3f to %1.3f", isDoomExplicit ? "with query override" : "factor adjustment", covered, numActiveLids, - request.getTimeout().sec(), my_stats.doomOvertime().sec(), overtimeLimit.sec(), duration.sec(), + vespalib::to_s(request.getTimeout()), vespalib::to_s(my_stats.doomOvertime()), vespalib::to_s(overtimeLimit), vespalib::to_s(duration), request.ranking.c_str(), (allowedSoftTimeoutFactorAdjustment ? "" : "NOT "), old, _stats.softDoomFactor()); } } diff --git a/searchcore/src/vespa/searchcore/proton/matching/matching_stats.cpp b/searchcore/src/vespa/searchcore/proton/matching/matching_stats.cpp index 7280653c4f9..84e5b9dfd15 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matching_stats.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/matching_stats.cpp @@ -14,7 +14,7 @@ MatchingStats::Partition &get_writable_partition(std::vector<MatchingStats::Part return state[id]; } -constexpr double MIN_TIMEOUT_SEC = 0.001; +constexpr vespalib::duration MIN_TIMEOUT = 1ms; constexpr double MAX_CHANGE_FACTOR = 5; } // namespace proton::matching::<unnamed> @@ -81,13 +81,13 @@ MatchingStats::add(const MatchingStats &rhs) } MatchingStats & -MatchingStats::updatesoftDoomFactor(double hardLimit, double softLimit, double duration) { +MatchingStats::updatesoftDoomFactor(vespalib::duration hardLimit, vespalib::duration softLimit, vespalib::duration duration) { // The safety capping here should normally not be necessary as all input numbers // will normally be within reasonable values. // It is merely a safety measure to avoid overflow on bad input as can happen with time senstive stuff // in any soft real time system. - if ((hardLimit >= MIN_TIMEOUT_SEC) && (softLimit >= MIN_TIMEOUT_SEC)) { - double diff = (softLimit - duration)/hardLimit; + if ((hardLimit >= MIN_TIMEOUT) && (softLimit >= MIN_TIMEOUT)) { + double diff = vespalib::to_s(softLimit - duration)/vespalib::to_s(hardLimit); if (duration < softLimit) { diff = std::min(diff, _softDoomFactor*MAX_CHANGE_FACTOR); _softDoomFactor += 0.01*diff; diff --git a/searchcore/src/vespa/searchcore/proton/matching/matching_stats.h b/searchcore/src/vespa/searchcore/proton/matching/matching_stats.h index a28c423eb7b..f5eccdd1127 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matching_stats.h +++ b/searchcore/src/vespa/searchcore/proton/matching/matching_stats.h @@ -4,7 +4,7 @@ #include <vector> #include <cstddef> -#include <vespa/fastos/timestamp.h> +#include <vespa/vespalib/util/time.h> namespace proton::matching { @@ -87,8 +87,8 @@ public: size_t docsReRanked() const { return _docsReRanked; } Partition &softDoomed(bool v) { _softDoomed += v ? 1 : 0; return *this; } size_t softDoomed() const { return _softDoomed; } - Partition & doomOvertime(fastos::TimeStamp overtime) { _doomOvertime.set(overtime.sec()); return *this; } - fastos::TimeStamp doomOvertime() const { return fastos::TimeStamp::fromSec(_doomOvertime.max()); } + Partition & doomOvertime(vespalib::duration overtime) { _doomOvertime.set(vespalib::to_s(overtime)); return *this; } + vespalib::duration doomOvertime() const { return vespalib::from_s(_doomOvertime.max()); } Partition &active_time(double time_s) { _active_time.set(time_s); return *this; } double active_time_avg() const { return _active_time.avg(); } @@ -162,11 +162,11 @@ public: MatchingStats &softDoomed(size_t value) { _softDoomed = value; return *this; } size_t softDoomed() const { return _softDoomed; } - fastos::TimeStamp doomOvertime() const { return fastos::TimeStamp::fromSec(_doomOvertime.max()); } + vespalib::duration doomOvertime() const { return vespalib::from_s(_doomOvertime.max()); } MatchingStats &softDoomFactor(double value) { _softDoomFactor = value; return *this; } double softDoomFactor() const { return _softDoomFactor; } - MatchingStats &updatesoftDoomFactor(double hardLimit, double softLimit, double duration); + MatchingStats &updatesoftDoomFactor(vespalib::duration hardLimit, vespalib::duration softLimit, vespalib::duration duration); MatchingStats &queryCollateralTime(double time_s) { _queryCollateralTime.set(time_s); return *this; } double queryCollateralTimeAvg() const { return _queryCollateralTime.avg(); } diff --git a/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp b/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp index 5053cc5fdbe..37ab0054851 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp @@ -20,9 +20,9 @@ QueryLimiter::grabToken(const Doom & doom) { std::unique_lock<std::mutex> guard(_lock); while ((_maxThreads > 0) && (_activeThreads >= _maxThreads) && !doom.hard_doom()) { - int left = doom.hard_left().ms(); - if (left > 0) { - _cond.wait_for(guard, std::chrono::milliseconds(left)); + vespalib::duration left = doom.hard_left(); + if (left > vespalib::duration::zero()) { + _cond.wait_for(guard, left); } } _activeThreads++; diff --git a/searchcore/src/vespa/searchcore/proton/matching/search_session.cpp b/searchcore/src/vespa/searchcore/proton/matching/search_session.cpp index 055325b851f..d502a8aba5d 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::SteadyTimeStamp create_time, fastos::SteadyTimeStamp time_of_doom, +SearchSession::SearchSession(const SessionId &id, vespalib::steady_time create_time, vespalib::steady_time 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 5f9436cce72..0aec02e9d31 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/search_session.h +++ b/searchcore/src/vespa/searchcore/proton/matching/search_session.h @@ -5,8 +5,8 @@ #include <vespa/searchcore/proton/documentmetastore/i_document_meta_store_context.h> #include <vespa/searchcore/proton/summaryengine/isearchhandler.h> #include <vespa/vespalib/stllike/string.h> +#include <vespa/vespalib/util/time.h> #include <memory> -#include <vespa/fastos/timestamp.h> namespace search::fef { class Properties; } @@ -34,16 +34,16 @@ public: private: typedef vespalib::string SessionId; - SessionId _session_id; - fastos::SteadyTimeStamp _create_time; - fastos::SteadyTimeStamp _time_of_doom; - OwnershipBundle _owned_objects; + SessionId _session_id; + vespalib::steady_time _create_time; + vespalib::steady_time _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::SteadyTimeStamp create_time, fastos::SteadyTimeStamp time_of_doom, + SearchSession(const SessionId &id, vespalib::steady_time create_time, vespalib::steady_time 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::SteadyTimeStamp getCreateTime() const { return _create_time; } + vespalib::steady_time getCreateTime() const { return _create_time; } /** * Gets this session's timeout. */ - fastos::SteadyTimeStamp getTimeOfDoom() const { return _time_of_doom; } + vespalib::steady_time 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 1976bf8252f..785ceadba9a 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/session_manager_explorer.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/session_manager_explorer.cpp @@ -3,6 +3,7 @@ #include "session_manager_explorer.h" #include "sessionmanager.h" #include <vespa/vespalib/data/slime/slime.h> +#include <vespa/fastos/timestamp.h> using vespalib::slime::Inserter; using vespalib::slime::Cursor; @@ -30,8 +31,8 @@ public: for (const auto &session: sessions) { Cursor &entry = array.addObject(); entry.setString("id", session.id); - entry.setString("created", fastos::TimeStamp::asString(session.created.toUTC())); - entry.setString("doom", fastos::TimeStamp::asString(session.doom.toUTC())); + entry.setString("created", fastos::TimeStamp::asString(vespalib::to_utc(session.created))); + entry.setString("doom", fastos::TimeStamp::asString(vespalib::to_utc(session.doom))); } } } diff --git a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp index 02c08a1c401..cf3a788ef7d 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::SteadyTimeStamp currentTime) { + void pruneTimedOutSessions(vespalib::steady_time currentTime) { std::vector<EntryUP> toDestruct = stealTimedOutSessions(currentTime); toDestruct.clear(); } - std::vector<EntryUP> stealTimedOutSessions(fastos::SteadyTimeStamp currentTime) { + std::vector<EntryUP> stealTimedOutSessions(vespalib::steady_time 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::SteadyTimeStamp currentTime) { + void pruneTimedOutSessions(vespalib::steady_time currentTime) { std::vector<EntrySP> toDestruct = stealTimedOutSessions(currentTime); toDestruct.clear(); } - std::vector<EntrySP> stealTimedOutSessions(fastos::SteadyTimeStamp currentTime) { + std::vector<EntrySP> stealTimedOutSessions(vespalib::steady_time 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::SteadyTimeStamp currentTime) { +void SessionManager::pruneTimedOutSessions(vespalib::steady_time currentTime) { _grouping_cache->pruneTimedOutSessions(currentTime); _search_map->pruneTimedOutSessions(currentTime); } void SessionManager::close() { - pruneTimedOutSessions(fastos::SteadyTimeStamp::FUTURE); + pruneTimedOutSessions(vespalib::steady_time::max()); 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 dc981c939b4..96c83270735 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.h +++ b/searchcore/src/vespa/searchcore/proton/matching/sessionmanager.h @@ -9,7 +9,7 @@ namespace proton::matching { -typedef vespalib::string SessionId; +using SessionId = vespalib::string; struct GroupingSessionCache; struct SearchSessionCache; @@ -33,11 +33,11 @@ public: struct SearchSessionInfo { vespalib::string id; - fastos::SteadyTimeStamp created; - fastos::SteadyTimeStamp doom; + vespalib::steady_time created; + vespalib::steady_time doom; SearchSessionInfo(const vespalib::string &id_in, - fastos::SteadyTimeStamp created_in, - fastos::SteadyTimeStamp doom_in) + vespalib::steady_time created_in, + vespalib::steady_time doom_in) : id(id_in), created(created_in), doom(doom_in) {} }; @@ -62,7 +62,7 @@ public: size_t getNumSearchSessions() const; std::vector<SearchSessionInfo> getSortedSearchSessionInfo() const; - void pruneTimedOutSessions(fastos::SteadyTimeStamp currentTime) override; + void pruneTimedOutSessions(vespalib::steady_time currentTime) override; void close(); }; diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp index 45784fc2683..1532ab35c26 100644 --- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp @@ -87,7 +87,7 @@ makeSubDBConfig(const ProtonConfig::Distribution & distCfg, const Allocation & a index::IndexConfig makeIndexConfig(const ProtonConfig::Index & cfg) { - return index::IndexConfig(WarmupConfig(cfg.warmup.time, cfg.warmup.unpack), cfg.maxflushed, cfg.cache.size); + return index::IndexConfig(WarmupConfig(vespalib::from_s(cfg.warmup.time), cfg.warmup.unpack), cfg.maxflushed, cfg.cache.size); } ProtonConfig::Documentdb _G_defaultProtonDocumentDBConfig; 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 7c27728bc22..70ed5b29541 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 @@ -1,7 +1,5 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "prune_session_cache_job.h" -#include <vespa/fastos/timestamp.h> -#include <chrono> namespace proton { @@ -16,7 +14,7 @@ PruneSessionCacheJob::PruneSessionCacheJob(ISessionCachePruner &pruner, double j bool PruneSessionCacheJob::run() { - _pruner.pruneTimedOutSessions(fastos::ClockSteady::now()); + _pruner.pruneTimedOutSessions(vespalib::steady_clock::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 e5b5bc0e559..309dd44391d 100644 --- a/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp @@ -13,7 +13,6 @@ LOG_SETUP(".proton.server.rtchooks"); using namespace vespalib; using vespalib::compression::CompressionConfig; -using fastos::SteadyTimeStamp; using fastos::TimeStamp; namespace { @@ -38,10 +37,11 @@ namespace proton { void RPCHooksBase::checkState(std::unique_ptr<StateArg> arg) { - SteadyTimeStamp now(fastos::ClockSteady::now()); + steady_time now(steady_clock::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) { + vespalib::duration left = (arg->_dueTime - now); + if (_stateCond.wait_for(guard, left) == std::cv_status::no_timeout) { LOG(debug, "state has changed"); reportState(*arg->_session, arg->_req); arg->_req->Return(); @@ -285,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 { - SteadyTimeStamp dueTime(fastos::ClockSteady::now() + TimeStamp(timeoutMS * TimeStamp::MS)); + steady_time dueTime(steady_clock::now() + std::chrono::milliseconds(timeoutMS)); auto stateArg = std::make_unique<StateArg>(sharedSession, req, dueTime); if (_executor.execute(makeTask(makeClosure(this, &RPCHooksBase::checkState, std::move(stateArg))))) { reportState(*sharedSession, req); @@ -350,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 { - SteadyTimeStamp dueTime(fastos::ClockSteady::now() + TimeStamp(timeoutMS * TimeStamp::MS)); + steady_time dueTime(steady_clock::now() + std::chrono::milliseconds(timeoutMS)); 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 21c3283d790..494551c05bf 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::SteadyTimeStamp dueTime) : + StateArg(Session::SP session, FRT_RPCRequest * req, vespalib::steady_time dueTime) : _session(std::move(session)), _req(req), _dueTime(dueTime) { } - Session::SP _session; - FRT_RPCRequest * _req; - fastos::SteadyTimeStamp _dueTime; + Session::SP _session; + FRT_RPCRequest * _req; + vespalib::steady_time _dueTime; }; Proton & _proton; @@ -122,6 +122,4 @@ public: RPCHooks(Params ¶ms); }; - -} // namespace proton - +} diff --git a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp index 9744b24a74c..e154c6761e2 100644 --- a/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp +++ b/searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp @@ -1,9 +1,9 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "summaryengine.h" +#include <vespa/vespalib/data/slime/slime.h> #include <vespa/log/log.h> LOG_SETUP(".proton.summaryengine.summaryengine"); -#include <vespa/vespalib/data/slime/slime.h> using namespace search::engine; using namespace proton; @@ -137,7 +137,7 @@ SummaryEngine::getDocsums(DocsumRequest::UP req) reply = snapshot->get()->getDocsums(*req); // use the first handler } } - updateDocsumMetrics(req->getTimeUsed().sec(), getNumDocs(*reply)); + updateDocsumMetrics(vespalib::to_s(req->getTimeUsed()), getNumDocs(*reply)); } reply->request = std::move(req); |