summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-12-06 20:17:56 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-12-09 20:43:38 +0000
commit9156592055b871be41b1f634ee37842854dc73a4 (patch)
tree9fe512730a78b950ed07ee7f84a330821a109062
parent3a8c63f34d8554573b42b0c3749e44ad4f43fb0e (diff)
Use std::chrono.
-rw-r--r--fastos/src/vespa/fastos/timestamp.cpp24
-rw-r--r--fastos/src/vespa/fastos/timestamp.h19
-rw-r--r--searchcore/src/tests/grouping/grouping.cpp19
-rw-r--r--searchcore/src/tests/proton/common/cachedselect_test.cpp6
-rw-r--r--searchcore/src/tests/proton/docsummary/docsummary.cpp2
-rw-r--r--searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp2
-rw-r--r--searchcore/src/tests/proton/index/indexcollection_test.cpp4
-rw-r--r--searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp6
-rw-r--r--searchcore/src/tests/proton/matching/matching_stats_test.cpp42
-rw-r--r--searchcore/src/tests/proton/matching/matching_test.cpp5
-rw-r--r--searchcore/src/tests/proton/matching/request_context/request_context_test.cpp2
-rw-r--r--searchcore/src/tests/proton/matching/sessionmanager_test.cpp14
-rw-r--r--searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/grouping/groupingcontext.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/grouping/groupingcontext.h15
-rw-r--r--searchcore/src/vespa/searchcore/grouping/groupingsession.h6
-rw-r--r--searchcore/src/vespa/searchcore/proton/docsummary/docsumcontext.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/fakesearchcontext.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/isessioncachepruner.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_master.cpp16
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp14
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_thread.h2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/matcher.cpp18
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/matching_stats.cpp8
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/matching_stats.h10
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/search_session.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/search_session.h16
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/session_manager_explorer.cpp5
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/sessionmanager.cpp12
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/sessionmanager.h12
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentdb.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/prune_session_cache_job.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/rpc_hooks.cpp10
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/rpc_hooks.h12
-rw-r--r--searchcore/src/vespa/searchcore/proton/summaryengine/summaryengine.cpp4
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp4
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/warmupconfig.h12
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp17
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h2
-rw-r--r--searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp12
-rw-r--r--searchlib/src/tests/aggregator/perdocexpr.cpp8
-rw-r--r--searchlib/src/tests/attribute/benchmark/attributesearcher.h24
-rw-r--r--searchlib/src/tests/attribute/benchmark/attributeupdater.h30
-rw-r--r--searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp4
-rw-r--r--searchlib/src/tests/features/featurebenchmark.cpp10
-rw-r--r--searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp6
-rw-r--r--searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp22
-rw-r--r--searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp13
-rw-r--r--searchlib/src/tests/sortspec/multilevelsort.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/aggregation/grouping.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/aggregation/grouping.h4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributevector.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/attributevector.h4
-rw-r--r--searchlib/src/vespa/searchlib/engine/proto_converter.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/engine/proto_rpc_adapter.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/engine/request.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/engine/request.h19
-rw-r--r--searchlib/src/vespa/searchlib/engine/trace.cpp16
-rw-r--r--searchlib/src/vespa/searchlib/engine/trace.h20
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h4
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.cpp14
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.h20
-rw-r--r--staging_vespalib/src/tests/clock/clock_benchmark.cpp35
-rw-r--r--staging_vespalib/src/tests/clock/clock_test.cpp12
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/clock.cpp2
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/clock.h8
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/doom.cpp4
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/doom.h18
-rw-r--r--vespalib/src/vespa/vespalib/testkit/test_comparators.cpp6
-rw-r--r--vespalib/src/vespa/vespalib/testkit/test_comparators.h2
-rw-r--r--vespalib/src/vespa/vespalib/util/time.cpp7
-rw-r--r--vespalib/src/vespa/vespalib/util/time.h2
75 files changed, 349 insertions, 386 deletions
diff --git a/fastos/src/vespa/fastos/timestamp.cpp b/fastos/src/vespa/fastos/timestamp.cpp
index 14825d7d4f4..ef206067900 100644
--- a/fastos/src/vespa/fastos/timestamp.cpp
+++ b/fastos/src/vespa/fastos/timestamp.cpp
@@ -14,10 +14,7 @@ namespace fastos {
const TimeStamp::TimeT TimeStamp::MILLI;
const TimeStamp::TimeT TimeStamp::MICRO;
const TimeStamp::TimeT TimeStamp::NANO;
-const TimeStamp::TimeT TimeStamp::US;
-const TimeStamp::TimeT TimeStamp::MS;
const TimeStamp::TimeT TimeStamp::SEC;
-const TimeStamp::TimeT TimeStamp::MINUTE;
using seconds = std::chrono::duration<double>;
@@ -56,27 +53,6 @@ steady_now() {
}
-std::ostream &
-operator << (std::ostream & os, SteadyTimeStamp ts) {
- return os << ts.toString();
-}
-
-SteadyTimeStamp
-ClockSteady::now()
-{
- return steady_now();
-}
-
-const SteadyTimeStamp SteadyTimeStamp::ZERO;
-const SteadyTimeStamp SteadyTimeStamp::FUTURE(TimeStamp::FUTURE);
-
-system_clock::time_point
-SteadyTimeStamp::toUTC() const {
- system_clock::time_point nowUtc = system_clock::now();
- SteadyTimeStamp nowSteady = ClockSteady::now();
- return system_clock::time_point (std::chrono::nanoseconds(nowUtc.time_since_epoch().count() - (nowSteady - *this).ns()));
-}
-
StopWatch::StopWatch()
: _startTime(steady_now())
{ }
diff --git a/fastos/src/vespa/fastos/timestamp.h b/fastos/src/vespa/fastos/timestamp.h
index 5dd6c350602..0d23cf7151f 100644
--- a/fastos/src/vespa/fastos/timestamp.h
+++ b/fastos/src/vespa/fastos/timestamp.h
@@ -15,10 +15,7 @@ public:
static const TimeT MILLI = 1000LL;
static const TimeT MICRO = 1000*MILLI;
static const TimeT NANO = 1000*MICRO;
- static const TimeT US = MILLI;
- static const TimeT MS = MICRO;
static const TimeT SEC = NANO;
- static const TimeT MINUTE = 60*SEC;
class Seconds {
public:
explicit Seconds(double v) : _v(v * NANO) {}
@@ -26,10 +23,8 @@ public:
private:
TimeT _v;
};
- enum Special { FUTURE };
TimeStamp() : _time(0) { }
TimeStamp(const timeval & tv) : _time(tv.tv_sec*SEC + tv.tv_usec*MILLI) { }
- TimeStamp(Special s) : _time(std::numeric_limits<TimeT>::max()) { (void) s; }
TimeStamp(int v) : _time(v) { }
TimeStamp(unsigned int v) : _time(v) { }
TimeStamp(long v) : _time(v) { }
@@ -48,8 +43,7 @@ public:
double sec() const { return val()/1000000000.0; }
std::string toString() const { return asString(sec()); }
static std::string asString(double timeInSeconds);
- static std::string asString(std::chrono::system_clock::time_point duration);
- static TimeStamp fromSec(double sec) { return Seconds(sec); }
+ static std::string asString(std::chrono::system_clock::time_point time);
private:
TimeT _time;
};
@@ -61,8 +55,6 @@ inline TimeStamp operator *(double a, TimeStamp b) { return TimeStamp(static_cas
class SteadyTimeStamp {
public:
- static const SteadyTimeStamp ZERO;
- static const SteadyTimeStamp FUTURE;
SteadyTimeStamp() : _timeStamp() { }
explicit SteadyTimeStamp(TimeStamp timeStamp) : _timeStamp(timeStamp) { }
@@ -87,20 +79,11 @@ public:
friend bool operator > (SteadyTimeStamp a, SteadyTimeStamp b) {
return a._timeStamp > b._timeStamp;
}
- std::chrono::system_clock::time_point toUTC() const;
std::string toString() const { return _timeStamp.toString(); };
private:
TimeStamp _timeStamp;
};
-std::ostream & operator << (std::ostream & os, SteadyTimeStamp ts);
-
-class ClockSteady
-{
-public:
- static SteadyTimeStamp now();
-};
-
class StopWatch
{
public:
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 &params);
};
-
-} // 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);
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
index 0ca6d299288..fc05a5bbc4c 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
@@ -391,8 +391,8 @@ IndexMaintainer::swapInNewIndex(LockGuard & guard,
{
assert(indexes->valid());
(void) guard;
- if (_warmupConfig.getDuration() > 0) {
- if (dynamic_cast<const IDiskIndex *>(&source) != NULL) {
+ if (_warmupConfig.getDuration() > vespalib::duration::zero()) {
+ if (dynamic_cast<const IDiskIndex *>(&source) != nullptr) {
LOG(debug, "Warming up a disk index.");
indexes = std::make_shared<WarmupIndexCollection>
(_warmupConfig, getLeaf(guard, _source_list, true), indexes,
diff --git a/searchcorespi/src/vespa/searchcorespi/index/warmupconfig.h b/searchcorespi/src/vespa/searchcorespi/index/warmupconfig.h
index 4c2e431f082..9ec5b29b3b6 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/warmupconfig.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/warmupconfig.h
@@ -1,6 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
+#include <vespa/vespalib/util/time.h>
+
namespace searchcorespi::index {
/**
@@ -8,13 +10,13 @@ namespace searchcorespi::index {
**/
class WarmupConfig {
public:
- WarmupConfig() : _duration(0.0), _unpack(false) { }
- WarmupConfig(double duration, bool unpack) : _duration(duration), _unpack(unpack) { }
- double getDuration() const { return _duration; }
+ WarmupConfig() : _duration(vespalib::duration::zero()), _unpack(false) { }
+ WarmupConfig(vespalib::duration duration, bool unpack) : _duration(duration), _unpack(unpack) { }
+ vespalib::duration getDuration() const { return _duration; }
bool getUnpack() const { return _unpack; }
private:
- const double _duration;
- const bool _unpack;
+ const vespalib::duration _duration;
+ const bool _unpack;
};
}
diff --git a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp
index a49518a6d50..72ac28bfd8c 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp
@@ -12,7 +12,6 @@ LOG_SETUP(".searchcorespi.index.warmupindexcollection");
namespace searchcorespi {
-using fastos::ClockSteady;
using fastos::TimeStamp;
using index::IDiskIndex;
using search::fef::MatchDataLayout;
@@ -42,7 +41,7 @@ WarmupIndexCollection::WarmupIndexCollection(const WarmupConfig & warmupConfig,
_warmup(warmup),
_executor(executor),
_warmupDone(warmupDone),
- _warmupEndTime(ClockSteady::now() + TimeStamp::Seconds(warmupConfig.getDuration())),
+ _warmupEndTime(vespalib::steady_clock::now() + warmupConfig.getDuration()),
_handledTerms(std::make_unique<FieldTermMap>())
{
if (next->valid()) {
@@ -50,7 +49,7 @@ WarmupIndexCollection::WarmupIndexCollection(const WarmupConfig & warmupConfig,
} else {
LOG(warning, "Next index is not valid, Dangerous !! : %s", next->toString().c_str());
}
- LOG(debug, "For %g seconds I will warm up '%s' %s unpack.", warmupConfig.getDuration(), typeid(_warmup).name(), warmupConfig.getUnpack() ? "with" : "without");
+ LOG(debug, "For %g seconds I will warm up '%s' %s unpack.", vespalib::to_s(warmupConfig.getDuration()), typeid(_warmup).name(), warmupConfig.getUnpack() ? "with" : "without");
LOG(debug, "%s", toString().c_str());
}
@@ -81,7 +80,7 @@ WarmupIndexCollection::toString() const
WarmupIndexCollection::~WarmupIndexCollection()
{
- if (_warmupEndTime != fastos::SteadyTimeStamp::ZERO) {
+ if (_warmupEndTime != vespalib::steady_time()) {
LOG(info, "Warmup aborted due to new state change or application shutdown");
}
_executor.sync();
@@ -114,13 +113,13 @@ WarmupIndexCollection::getSourceId(uint32_t i) const
void
WarmupIndexCollection::fireWarmup(Task::UP task)
{
- fastos::SteadyTimeStamp now(fastos::ClockSteady::now());
+ vespalib::steady_time now(vespalib::steady_clock::now());
if (now < _warmupEndTime) {
_executor.execute(std::move(task));
} else {
std::unique_lock<std::mutex> guard(_lock);
- if (_warmupEndTime != fastos::SteadyTimeStamp::ZERO) {
- _warmupEndTime = fastos::SteadyTimeStamp::ZERO;
+ if (_warmupEndTime != vespalib::steady_time()) {
+ _warmupEndTime = vespalib::steady_time();
guard.unlock();
LOG(info, "Done warming up. Posting WarmupDoneTask");
_warmupDone.warmupDone(shared_from_this());
@@ -155,7 +154,7 @@ WarmupIndexCollection::createBlueprint(const IRequestContext & requestContext,
const FieldSpecList &fields,
const Node &term)
{
- if ( _warmupEndTime == fastos::SteadyTimeStamp::ZERO) {
+ if ( _warmupEndTime == vespalib::steady_time()) {
// warmup done
return _next->createBlueprint(requestContext, fields, term);
}
@@ -224,7 +223,7 @@ WarmupIndexCollection::getSearchableSP(uint32_t i) const
void
WarmupIndexCollection::WarmupTask::run()
{
- if (_warmup._warmupEndTime != fastos::SteadyTimeStamp::ZERO) {
+ if (_warmup._warmupEndTime != vespalib::steady_time()) {
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 c13a0257019..571353574c1 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::SteadyTimeStamp _warmupEndTime;
+ vespalib::steady_time _warmupEndTime;
std::mutex _lock;
std::unique_ptr<FieldTermMap> _handledTerms;
};
diff --git a/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp b/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp
index f4de610a06d..245f082a2db 100644
--- a/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp
+++ b/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp
@@ -165,16 +165,16 @@ LoadAttribute::Main()
c.setFastSearch(doFastSearch);
c.setHuge(doHuge);
AttributePtr ptr = AttributeFactory::createAttribute(fileName, c);
- fastos::StopWatch timer;
+ vespalib::Timer timer;
load(ptr);
- std::cout << "load time: " << timer.elapsed().sec() << " seconds " << std::endl;
+ std::cout << "load time: " << vespalib::to_s(timer.elapsed()) << " seconds " << std::endl;
std::cout << "numDocs: " << ptr->getNumDocs() << std::endl;
if (doApplyUpdate) {
- timer.restart();
+ timer = vespalib::Timer();
applyUpdate(ptr);
- std::cout << "update time: " << timer.elapsed().sec() << " seconds " << std::endl;
+ std::cout << "update time: " << vespalib::to_s(timer.elapsed()) << " seconds " << std::endl;
}
if (doPrintContent) {
@@ -191,9 +191,9 @@ LoadAttribute::Main()
if (doSave) {
vespalib::string saveFile = fileName + ".save";
std::cout << "saving attribute: " << saveFile << std::endl;
- timer.restart();
+ timer = vespalib::Timer();
ptr->save(saveFile);
- std::cout << "save time: " << timer.elapsed().sec() << " seconds " << std::endl;
+ std::cout << "save time: " << vespalib::to_s(timer.elapsed()) << " seconds " << std::endl;
}
return 0;
diff --git a/searchlib/src/tests/aggregator/perdocexpr.cpp b/searchlib/src/tests/aggregator/perdocexpr.cpp
index c078282c442..513e94321e1 100644
--- a/searchlib/src/tests/aggregator/perdocexpr.cpp
+++ b/searchlib/src/tests/aggregator/perdocexpr.cpp
@@ -694,9 +694,9 @@ TEST("testDebugFunction") {
DebugWaitFunctionNode n(std::move(add), 1.3, false);
n.prepare(false);
- fastos::StopWatch timer;
+ vespalib::Timer timer;
n.execute();
- EXPECT_TRUE(timer.elapsed().ms() > 1000.0);
+ EXPECT_TRUE(timer.elapsed() > 1s);
EXPECT_EQUAL(static_cast<const Int64ResultNode &>(n.getResult()).get(), 7);
}
{
@@ -706,9 +706,9 @@ TEST("testDebugFunction") {
DebugWaitFunctionNode n(std::move(add), 1.3, true);
n.prepare(false);
- fastos::StopWatch timer;
+ vespalib::Timer timer;
n.execute();
- EXPECT_TRUE(timer.elapsed().ms() > 1000.0);
+ EXPECT_TRUE(timer.elapsed() > 1s);
EXPECT_EQUAL(static_cast<const Int64ResultNode &>(n.getResult()).get(), 7);
}
}
diff --git a/searchlib/src/tests/attribute/benchmark/attributesearcher.h b/searchlib/src/tests/attribute/benchmark/attributesearcher.h
index 66bb6467194..cfb69044792 100644
--- a/searchlib/src/tests/attribute/benchmark/attributesearcher.h
+++ b/searchlib/src/tests/attribute/benchmark/attributesearcher.h
@@ -26,7 +26,7 @@ performSearch(queryeval::SearchIterator & sb, uint32_t numDocs)
class AttributeSearcherStatus
{
public:
- double _totalSearchTime;
+ vespalib::duration _totalSearchTime;
uint64_t _totalHitCount;
uint64_t _numQueries;
uint64_t _numClients;
@@ -39,17 +39,17 @@ public:
_numClients += status._numClients;
}
void printXML() const {
- std::cout << "<total-search-time>" << _totalSearchTime << "</total-search-time>" << std::endl; // ms
+ std::cout << "<total-search-time>" << vespalib::count_ms(_totalSearchTime) << "</total-search-time>" << std::endl; // ms
std::cout << "<avg-search-time>" << avgSearchTime() << "</avg-search-time>" << std::endl; // ms
std::cout << "<search-throughput>" << searchThroughout() << "</search-throughput>" << std::endl; // per/sec
std::cout << "<total-hit-count>" << _totalHitCount << "</total-hit-count>" << std::endl;
std::cout << "<avg-hit-count>" << avgHitCount() << "</avg-hit-count>" << std::endl;
}
double avgSearchTime() const {
- return _totalSearchTime / _numQueries;
+ return double(vespalib::count_ms(_totalSearchTime)) / _numQueries;
}
double searchThroughout() const {
- return _numClients * 1000 * _numQueries / _totalSearchTime;
+ return _numClients * 1000 * _numQueries / double(vespalib::count_ms(_totalSearchTime));
}
double avgHitCount() const {
return _totalHitCount / static_cast<double>(_numQueries);
@@ -62,8 +62,8 @@ class AttributeSearcher : public Runnable
protected:
typedef AttributeVector::SP AttributePtr;
- const AttributePtr & _attrPtr;
- fastos::StopWatch _timer;
+ const AttributePtr & _attrPtr;
+ vespalib::Timer _timer;
AttributeSearcherStatus _status;
public:
@@ -121,7 +121,7 @@ template <typename T>
void
AttributeFindSearcher<T>::doRun()
{
- _timer.restart();
+ _timer = vespalib::Timer();
for (uint32_t i = 0; i < _status._numQueries; ++i) {
// build simple term query
vespalib::asciistream ss;
@@ -139,7 +139,7 @@ AttributeFindSearcher<T>::doRun()
_status._totalHitCount += results->getNumHits();
}
- _status._totalSearchTime += _timer.elapsed().ms();
+ _status._totalSearchTime += _timer.elapsed();
}
@@ -198,7 +198,7 @@ public:
void
AttributeRangeSearcher::doRun()
{
- _timer.restart();
+ _timer = vespalib::Timer();
RangeIterator iter(_spec);
for (uint32_t i = 0; i < _status._numQueries; ++i, ++iter) {
// build simple range term query
@@ -217,7 +217,7 @@ AttributeRangeSearcher::doRun()
_status._totalHitCount += results->getNumHits();
}
- _status._totalSearchTime += _timer.elapsed().ms();
+ _status._totalSearchTime += _timer.elapsed();
}
@@ -240,7 +240,7 @@ public:
void
AttributePrefixSearcher::doRun()
{
- _timer.restart();
+ _timer = vespalib::Timer();
for (uint32_t i = 0; i < _status._numQueries; ++i) {
// build simple prefix term query
buildTermQuery(_query, _attrPtr->getName(), _values[i % _values.size()].c_str(), true);
@@ -256,7 +256,7 @@ AttributePrefixSearcher::doRun()
_status._totalHitCount += results->getNumHits();
}
- _status._totalSearchTime += _timer.elapsed().ms();
+ _status._totalSearchTime += _timer.elapsed();
}
} // search
diff --git a/searchlib/src/tests/attribute/benchmark/attributeupdater.h b/searchlib/src/tests/attribute/benchmark/attributeupdater.h
index c56c809457b..3ed26c31ecb 100644
--- a/searchlib/src/tests/attribute/benchmark/attributeupdater.h
+++ b/searchlib/src/tests/attribute/benchmark/attributeupdater.h
@@ -49,19 +49,19 @@ public:
class AttributeUpdaterStatus
{
public:
- double _totalUpdateTime;
+ vespalib::duration _totalUpdateTime;
uint64_t _numDocumentUpdates;
uint64_t _numValueUpdates;
AttributeUpdaterStatus() :
- _totalUpdateTime(0), _numDocumentUpdates(0), _numValueUpdates(0) {}
+ _totalUpdateTime(vespalib::duration::zero()), _numDocumentUpdates(0), _numValueUpdates(0) {}
void reset() {
- _totalUpdateTime = 0;
+ _totalUpdateTime = vespalib::duration::zero();
_numDocumentUpdates = 0;
_numValueUpdates = 0;
}
void printXML() const {
- std::cout << "<total-update-time>" << _totalUpdateTime << "</total-update-time>" << std::endl;
+ std::cout << "<total-update-time>" << vespalib::count_ms(_totalUpdateTime) << "</total-update-time>" << std::endl;
std::cout << "<documents-updated>" << _numDocumentUpdates << "</documents-updated>" << std::endl;
std::cout << "<document-update-throughput>" << documentUpdateThroughput() << "</document-update-throughput>" << std::endl;
std::cout << "<avg-document-update-time>" << avgDocumentUpdateTime() << "</avg-document-update-time>" << std::endl;
@@ -70,16 +70,16 @@ public:
std::cout << "<avg-value-update-time>" << avgValueUpdateTime() << "</avg-value-update-time>" << std::endl;
}
double documentUpdateThroughput() const {
- return _numDocumentUpdates * 1000 / _totalUpdateTime;
+ return _numDocumentUpdates * 1000 / vespalib::count_ms(_totalUpdateTime);
}
double avgDocumentUpdateTime() const {
- return _totalUpdateTime / _numDocumentUpdates;
+ return vespalib::count_ms(_totalUpdateTime) / _numDocumentUpdates;
}
double valueUpdateThroughput() const {
- return _numValueUpdates * 1000 / _totalUpdateTime;
+ return _numValueUpdates * 1000 / vespalib::count_ms(_totalUpdateTime);
}
double avgValueUpdateTime() const {
- return _totalUpdateTime / _numValueUpdates;
+ return vespalib::count_ms(_totalUpdateTime) / _numValueUpdates;
}
};
@@ -98,7 +98,7 @@ protected:
std::vector<BT> _getBuffer;
RandomGenerator & _rndGen;
AttributeCommit _expected;
- fastos::StopWatch _timer;
+ vespalib::Timer _timer;
AttributeUpdaterStatus _status;
AttributeValidator _validator;
@@ -267,7 +267,7 @@ template <typename Vector, typename T, typename BT>
void
AttributeUpdater<Vector, T, BT>::populate()
{
- _timer.restart();
+ _timer = vespalib::Timer();
for (uint32_t doc = 0; doc < _attrPtr->getNumDocs(); ++doc) {
updateValues(doc);
if (doc % _commitFreq == (_commitFreq - 1)) {
@@ -275,7 +275,7 @@ AttributeUpdater<Vector, T, BT>::populate()
}
}
commit();
- _status._totalUpdateTime += _timer.elapsed().ms();
+ _status._totalUpdateTime += _timer.elapsed();
}
@@ -283,7 +283,7 @@ template <typename Vector, typename T, typename BT>
void
AttributeUpdater<Vector, T, BT>::update(uint32_t numUpdates)
{
- _timer.restart();
+ _timer = vespalib::Timer();
for (uint32_t i = 0; i < numUpdates; ++i) {
uint32_t doc = getRandomDoc();
updateValues(doc);
@@ -292,7 +292,7 @@ AttributeUpdater<Vector, T, BT>::update(uint32_t numUpdates)
}
}
commit();
- _status._totalUpdateTime += _timer.elapsed().ms();
+ _status._totalUpdateTime += _timer.elapsed();
}
@@ -300,7 +300,7 @@ template <typename Vector, typename T, typename BT>
void
AttributeUpdaterThread<Vector, T, BT>::doRun()
{
- this->_timer.restart();
+ this->_timer = vespalib::Timer();
while(!_done) {
uint32_t doc = this->getRandomDoc();
this->updateValues(doc);
@@ -309,7 +309,7 @@ AttributeUpdaterThread<Vector, T, BT>::doRun()
}
}
this->commit();
- this->_status._totalUpdateTime += this->_timer.elapsed().ms();
+ this->_status._totalUpdateTime += this->_timer.elapsed();
}
diff --git a/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp b/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp
index 7526326b6ca..3e129457d46 100644
--- a/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp
+++ b/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp
@@ -46,7 +46,7 @@ TEST_F(SearchRequestTest, require_that_hits_is_converted) {
TEST_F(SearchRequestTest, require_that_timeout_is_converted) {
proto.set_timeout(500);
convert();
- EXPECT_EQ(request.getTimeout().ms(), 500);
+ EXPECT_EQ(request.getTimeout(), 500ms);
}
TEST_F(SearchRequestTest, require_that_trace_level_is_converted) {
@@ -317,7 +317,7 @@ TEST_F(DocsumRequestTest, require_that_root_slime_is_used) {
TEST_F(DocsumRequestTest, require_that_timeout_is_converted) {
proto.set_timeout(500);
convert();
- EXPECT_EQ(request.getTimeout().ms(), 500);
+ EXPECT_EQ(request.getTimeout(), 500ms);
}
TEST_F(DocsumRequestTest, require_that_session_key_is_converted) {
diff --git a/searchlib/src/tests/features/featurebenchmark.cpp b/searchlib/src/tests/features/featurebenchmark.cpp
index 43b1e38f4a4..54c2e8c7033 100644
--- a/searchlib/src/tests/features/featurebenchmark.cpp
+++ b/searchlib/src/tests/features/featurebenchmark.cpp
@@ -105,10 +105,10 @@ public:
private:
search::fef::BlueprintFactory _factory;
- fastos::StopWatch _timer;
- fastos::TimeStamp _sample;
+ vespalib::Timer _timer;
+ vespalib::duration _sample;
- void start() { _timer.restart(); }
+ void start() { _timer = vespalib::Timer(); }
void sample() { _sample = _timer.elapsed(); }
void setupPropertyMap(Properties & props, const KeyValueVector & values);
void runFieldMatch(Config & cfg);
@@ -648,8 +648,8 @@ Benchmark::Main()
std::cout << "feature case '" << cfg.getCase() << "' is not known" << std::endl;
}
- std::cout << "TET: " << _sample.ms() << " (ms)" << std::endl;
- std::cout << "ETPD: " << std::fixed << std::setprecision(10) << _sample.ms() / cfg.getNumRuns() << " (ms)" << std::endl;
+ std::cout << "TET: " << vespalib::count_ms(_sample) << " (ms)" << std::endl;
+ std::cout << "ETPD: " << std::fixed << std::setprecision(10) << vespalib::count_ms(_sample) / cfg.getNumRuns() << " (ms)" << std::endl;
std::cout << "**** '" << cfg.getFeature() << "' ****" << std::endl;
TEST_DONE();
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 bf1b5352778..0743ac8408d 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 ? fastos::SteadyTimeStamp::ZERO : fastos::SteadyTimeStamp::FUTURE),
+ : _requestContext(nullptr, expiredDoom ? vespalib::steady_time(): vespalib::steady_time::max()),
_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, fastos::SteadyTimeStamp::FUTURE);
+ vespalib::Doom futureDoom(clock, vespalib::steady_time::max());
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, fastos::SteadyTimeStamp::ZERO);
+ vespalib::Doom futureDoom(clock, vespalib::steady_time());
unique_ptr<SearchIterator> search(test.createSearch(false));
static_cast<SimplePhraseSearch &>(*search).setDoom(&futureDoom);
EXPECT_TRUE(!search->seek(1u));
diff --git a/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp b/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp
index 7d2efc5f2bc..3b61aaaac3e 100644
--- a/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp
+++ b/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp
@@ -131,8 +131,8 @@ int Plot::_plots = 0;
//-----------------------------------------------------------------------------
-uint32_t default_weight = 100;
-double max_time = 1000000.0;
+constexpr uint32_t default_weight = 100;
+constexpr vespalib::duration max_time = 1000s;
//-----------------------------------------------------------------------------
@@ -312,20 +312,20 @@ struct NegativeFilterAfterStrategy : FilterStrategy {
//-----------------------------------------------------------------------------
struct Result {
- double time_ms;
+ vespalib::duration time;
uint32_t num_hits;
- Result() : time_ms(max_time), num_hits(0) {}
- Result(double t, uint32_t n) : time_ms(t), num_hits(n) {}
+ Result() : time(max_time), num_hits(0) {}
+ Result(vespalib::duration t, uint32_t n) : time(t), num_hits(n) {}
void combine(const Result &r) {
- if (time_ms == max_time) {
+ if (time == max_time) {
*this = r;
} else {
assert(num_hits == r.num_hits);
- time_ms = std::min(time_ms, r.time_ms);
+ time = std::min(time, r.time);
}
}
std::string toString() const {
- return vespalib::make_string("%u hits, %g ms", num_hits, time_ms);
+ return vespalib::make_string("%u hits, %ld ms", num_hits, vespalib::count_ms(time));
}
};
@@ -333,12 +333,12 @@ Result run_single_benchmark(FilterStrategy &filterStrategy, SparseVectorFactory
SearchIterator::UP search(filterStrategy.createRoot(vectorFactory, childFactory, childCnt, limit));
SearchIterator &sb = *search;
uint32_t num_hits = 0;
- fastos::StopWatch timer;
+ vespalib::Timer timer;
for (sb.seek(1); !sb.isAtEnd(); sb.seek(sb.getDocId() + 1)) {
++num_hits;
sb.unpack(sb.getDocId());
}
- return Result(timer.elapsed().ms(), num_hits);
+ return Result(timer.elapsed(), num_hits);
}
//-----------------------------------------------------------------------------
@@ -371,7 +371,7 @@ public:
for (int j = 0; j < 5; ++j) {
result.combine(run_single_benchmark(_filterStrategy, svf, _childFactory, childCnt, _limit));
}
- graph->addValue(childCnt, result.time_ms);
+ graph->addValue(childCnt, vespalib::count_ms(result.time));
fprintf(stderr, " %u children => %s\n", childCnt, result.toString().c_str());
}
}
diff --git a/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp b/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp
index 65890f81e16..576c9abe249 100644
--- a/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp
+++ b/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp
@@ -187,22 +187,21 @@ struct FilterFactory : WandFactory {
struct Setup {
Stats stats;
- double minTimeMs;
- Setup() : stats(), minTimeMs(10000000.0) {}
+ vespalib::duration minTime;
+ Setup() : stats(), minTime(10000s) {}
virtual ~Setup() {}
virtual std::string name() const = 0;
virtual SearchIterator::UP create() = 0;
void perform() {
SearchIterator::UP search = create();
SearchIterator &sb = *search;
- fastos::StopWatch timer;
+ vespalib::Timer timer;
for (sb.seek(1); !sb.isAtEnd(); sb.seek(sb.getDocId() + 1)) {
stats.hit();
sb.unpack(sb.getDocId());
}
- double ms = timer.elapsed().ms();
- if (ms < minTimeMs) {
- minTimeMs = ms;
+ if (timer.elapsed() < minTime) {
+ minTime = timer.elapsed();
}
}
void benchmark() {
@@ -213,7 +212,7 @@ struct Setup {
stats.print();
}
}
- fprintf(stderr, "time (ms): %g\n", minTimeMs);
+ fprintf(stderr, "time (ms): %ld\n", vespalib::count_ms(minTime));
}
};
diff --git a/searchlib/src/tests/sortspec/multilevelsort.cpp b/searchlib/src/tests/sortspec/multilevelsort.cpp
index 640e6f45e80..8c4b931a265 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, fastos::SteadyTimeStamp::FUTURE);
+ vespalib::Doom doom(clock, vespalib::steady_time::max());
search::uca::UcaConverterFactory ucaFactory;
FastS_SortSpec sorter(7, doom, ucaFactory, _sortMethod);
// init sorter with sort data
@@ -263,9 +263,9 @@ MultilevelSortTest::sortAndCheck(const std::vector<Spec> &spec, uint32_t num,
}
}
- fastos::StopWatch timer;
+ vespalib::Timer timer;
sorter.sortResults(hits, num, num);
- LOG(info, "sort time = %ld ms", timer.elapsed().ms());
+ LOG(info, "sort time = %ld ms", vespalib::count_ms(timer.elapsed()));
uint32_t *offsets = new uint32_t[num + 1];
char *buf = new char[sorter.getSortDataSize(0, num)];
@@ -398,7 +398,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::SteadyTimeStamp::FUTURE);
+ vespalib::Doom doom(clock, vespalib::steady_time::max());
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.cpp b/searchlib/src/vespa/searchlib/aggregation/grouping.cpp
index 5c93fb4161c..4ad8e0089d9 100644
--- a/searchlib/src/vespa/searchlib/aggregation/grouping.cpp
+++ b/searchlib/src/vespa/searchlib/aggregation/grouping.cpp
@@ -115,8 +115,8 @@ Grouping::Grouping()
_lastLevel(0),
_levels(),
_root(),
- _clock(NULL),
- _timeOfDoom(0)
+ _clock(nullptr),
+ _timeOfDoom(vespalib::duration::zero())
{
}
diff --git a/searchlib/src/vespa/searchlib/aggregation/grouping.h b/searchlib/src/vespa/searchlib/aggregation/grouping.h
index 4230bd777d6..249262438da 100644
--- a/searchlib/src/vespa/searchlib/aggregation/grouping.h
+++ b/searchlib/src/vespa/searchlib/aggregation/grouping.h
@@ -31,7 +31,7 @@ private:
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.
+ vespalib::steady_time _timeOfDoom; // Used if clock is specified. This is time when request expires.
bool hasExpired() const { return _clock->getTimeNS() > _timeOfDoom; }
void aggregateWithoutClock(const RankedHit * rankedHit, unsigned int len);
@@ -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::SteadyTimeStamp timeOfDoom) { _timeOfDoom = timeOfDoom; return *this; }
+ Grouping &setTimeOfDoom(vespalib::steady_time timeOfDoom) { _timeOfDoom = timeOfDoom; return *this; }
unsigned int getId() const { return _id; }
bool valid() const { return _valid; }
diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
index e79db2fae11..4c060c5fab8 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp
@@ -136,9 +136,9 @@ AttributeVector::~AttributeVector() = default;
void AttributeVector::updateStat(bool force) {
if (force) {
onUpdateStat();
- } else if (_nextStatUpdateTime < fastos::ClockSteady::now()) {
+ } else if (_nextStatUpdateTime < vespalib::steady_clock::now()) {
onUpdateStat();
- _nextStatUpdateTime = fastos::ClockSteady::now() + fastos::TimeStamp(5ul * fastos::TimeStamp::SEC);
+ _nextStatUpdateTime = vespalib::steady_clock::now() + 5s;
}
}
diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h
index d45cd995ea5..48ef8257329 100644
--- a/searchlib/src/vespa/searchlib/attribute/attributevector.h
+++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h
@@ -20,7 +20,7 @@
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/util/address_space.h>
#include <vespa/vespalib/util/rcuvector.h>
-#include <vespa/fastos/timestamp.h>
+#include <vespa/vespalib/util/time.h>
#include <cmath>
#include <mutex>
#include <shared_mutex>
@@ -587,7 +587,7 @@ private:
uint64_t _compactLidSpaceGeneration;
bool _hasEnum;
bool _loaded;
- fastos::SteadyTimeStamp _nextStatUpdateTime;
+ vespalib::steady_time _nextStatUpdateTime;
////// Locking strategy interface. only available from the Guards.
/**
diff --git a/searchlib/src/vespa/searchlib/engine/proto_converter.cpp b/searchlib/src/vespa/searchlib/engine/proto_converter.cpp
index 2495a6e12bd..e5846734a8d 100644
--- a/searchlib/src/vespa/searchlib/engine/proto_converter.cpp
+++ b/searchlib/src/vespa/searchlib/engine/proto_converter.cpp
@@ -52,7 +52,7 @@ ProtoConverter::search_request_from_proto(const ProtoSearchRequest &proto, Searc
{
request.offset = proto.offset();
request.maxhits = proto.hits();
- request.setTimeout(fastos::TimeStamp::Seconds(0.001 * proto.timeout()));
+ request.setTimeout(1ms * proto.timeout());
request.setTraceLevel(proto.trace_level());
request.sortSpec = make_sort_spec(proto.sorting());
request.sessionId.assign(proto.session_key().begin(), proto.session_key().end());
@@ -111,7 +111,7 @@ ProtoConverter::search_reply_to_proto(const SearchReply &reply, ProtoSearchReply
void
ProtoConverter::docsum_request_from_proto(const ProtoDocsumRequest &proto, DocsumRequest &request)
{
- request.setTimeout(fastos::TimeStamp::Seconds(0.001 * proto.timeout()));
+ request.setTimeout(1ms * proto.timeout());
request.sessionId.assign(proto.session_key().begin(), proto.session_key().end());
request.propertiesMap.lookupCreate(MapNames::MATCH).add("documentdb.searchdoctype", proto.document_type());
request.resultClassName = proto.summary_class();
diff --git a/searchlib/src/vespa/searchlib/engine/proto_rpc_adapter.cpp b/searchlib/src/vespa/searchlib/engine/proto_rpc_adapter.cpp
index 4fa7079fe46..4634c192a51 100644
--- a/searchlib/src/vespa/searchlib/engine/proto_rpc_adapter.cpp
+++ b/searchlib/src/vespa/searchlib/engine/proto_rpc_adapter.cpp
@@ -115,7 +115,7 @@ struct SearchCompletionHandler : SearchClient {
encode_search_reply(msg, *req.GetReturn());
stats.reply_size = (*req.GetReturn())[2]._data._len;
if (reply->request) {
- stats.latency = reply->request->getTimeUsed().sec();
+ stats.latency = vespalib::to_s(reply->request->getTimeUsed());
metrics.update_query_metrics(stats);
}
req.Return();
@@ -161,7 +161,7 @@ struct GetDocsumsCompletionHandler : DocsumClient {
encode_message(msg, *req.GetReturn());
stats.reply_size = (*req.GetReturn())[2]._data._len;
if (reply->request) {
- stats.latency = reply->request->getTimeUsed().sec();
+ stats.latency = vespalib::to_s(reply->request->getTimeUsed());
metrics.update_docsum_metrics(stats);
}
req.Return();
diff --git a/searchlib/src/vespa/searchlib/engine/request.cpp b/searchlib/src/vespa/searchlib/engine/request.cpp
index 84615105579..cb00dfcf09b 100644
--- a/searchlib/src/vespa/searchlib/engine/request.cpp
+++ b/searchlib/src/vespa/searchlib/engine/request.cpp
@@ -6,7 +6,7 @@ namespace search::engine {
Request::Request(RelativeTime relativeTime)
: _relativeTime(std::move(relativeTime)),
- _timeOfDoom(fastos::TimeStamp(fastos::TimeStamp::FUTURE)),
+ _timeOfDoom(vespalib::steady_time::max()),
dumpFeatures(false),
ranking(),
location(),
@@ -19,17 +19,17 @@ Request::Request(RelativeTime relativeTime)
Request::~Request() = default;
-void Request::setTimeout(const fastos::TimeStamp & timeout)
+void Request::setTimeout(vespalib::duration timeout)
{
_timeOfDoom = getStartTime() + timeout;
}
-fastos::TimeStamp Request::getTimeUsed() const
+vespalib::duration Request::getTimeUsed() const
{
return _relativeTime.timeSinceDawn();
}
-fastos::TimeStamp Request::getTimeLeft() const
+vespalib::duration Request::getTimeLeft() const
{
return _timeOfDoom - _relativeTime.now();
}
diff --git a/searchlib/src/vespa/searchlib/engine/request.h b/searchlib/src/vespa/searchlib/engine/request.h
index 4f4bf526920..ef90e38dc3d 100644
--- a/searchlib/src/vespa/searchlib/engine/request.h
+++ b/searchlib/src/vespa/searchlib/engine/request.h
@@ -4,7 +4,6 @@
#include "propertiesmap.h"
#include "trace.h"
-#include <vespa/fastos/timestamp.h>
namespace search::engine {
@@ -15,14 +14,14 @@ public:
Request(const Request &) = delete;
Request & operator =(const Request &) = delete;
virtual ~Request();
- void setTimeout(const fastos::TimeStamp & timeout);
- 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;
+ void setTimeout(vespalib::duration timeout);
+ vespalib::steady_time getStartTime() const { return _relativeTime.timeOfDawn(); }
+ vespalib::steady_time getTimeOfDoom() const { return _timeOfDoom; }
+ vespalib::duration getTimeout() const { return _timeOfDoom - getStartTime(); }
+ vespalib::duration getTimeUsed() const;
+ vespalib::duration getTimeLeft() const;
const RelativeTime & getRelativeTime() const { return _relativeTime; }
- bool expired() const { return getTimeLeft() <= 0l; }
+ bool expired() const { return getTimeLeft() <= vespalib::duration::zero(); }
const vespalib::stringref getStackRef() const {
return vespalib::stringref(&stackDump[0], stackDump.size());
@@ -37,8 +36,8 @@ public:
Trace & trace() const { return _trace; }
private:
- RelativeTime _relativeTime;
- fastos::SteadyTimeStamp _timeOfDoom;
+ RelativeTime _relativeTime;
+ vespalib::steady_time _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 ae0c6810ca1..95d6c967369 100644
--- a/searchlib/src/vespa/searchlib/engine/trace.cpp
+++ b/searchlib/src/vespa/searchlib/engine/trace.cpp
@@ -2,12 +2,13 @@
#include "trace.h"
#include <vespa/vespalib/data/slime/slime.h>
+#include <vespa/fastos/timestamp.h>
namespace search::engine {
-fastos::SteadyTimeStamp
+vespalib::steady_time
SteadyClock::now() const {
- return fastos::ClockSteady::now();
+ return vespalib::steady_clock::now();
}
RelativeTime::RelativeTime(std::unique_ptr<Clock> clock)
@@ -36,9 +37,12 @@ Trace::Trace(const RelativeTime & relativeTime, uint32_t level)
}
void
-Trace::start(int level) {
+Trace::start(int level, bool useUTC) {
if (shouldTrace(level) && !hasTrace()) {
- root().setString("start_time_relative", _relativeTime.timeOfDawn().toString());
+ vespalib::duration since_epoch = useUTC
+ ? vespalib::to_utc(_relativeTime.timeOfDawn()).time_since_epoch()
+ : _relativeTime.timeOfDawn().time_since_epoch();
+ root().setString("start_time", fastos::TimeStamp::asString(vespalib::to_s(since_epoch)));
}
}
@@ -68,13 +72,13 @@ Trace::addEvent(uint32_t level, vespalib::stringref event) {
void
Trace::addTimeStamp(Cursor & trace) {
- trace.setDouble("timestamp_ms", _relativeTime.timeSinceDawn()/1000000.0);
+ trace.setDouble("timestamp_ms", vespalib::count_ns(_relativeTime.timeSinceDawn())/1000000.0);
}
void Trace::done() {
if (!hasTrace()) { return; }
- root().setDouble("duration_ms", _relativeTime.timeSinceDawn()/1000000.0);
+ root().setDouble("duration_ms", vespalib::count_ns(_relativeTime.timeSinceDawn())/1000000.0);
}
vespalib::string
diff --git a/searchlib/src/vespa/searchlib/engine/trace.h b/searchlib/src/vespa/searchlib/engine/trace.h
index 0d7dc2982f1..4076f0a3daa 100644
--- a/searchlib/src/vespa/searchlib/engine/trace.h
+++ b/searchlib/src/vespa/searchlib/engine/trace.h
@@ -3,7 +3,7 @@
#pragma once
#include <vespa/vespalib/stllike/string.h>
-#include <vespa/fastos/timestamp.h>
+#include <vespa/vespalib/util/time.h>
namespace vespalib { class Slime; }
namespace vespalib::slime { struct Cursor; }
@@ -13,21 +13,21 @@ namespace search::engine {
class Clock {
public:
virtual ~Clock() = default;
- virtual fastos::SteadyTimeStamp now() const = 0;
+ virtual vespalib::steady_time now() const = 0;
};
class SteadyClock : public Clock {
public:
- fastos::SteadyTimeStamp now() const override;
+ vespalib::steady_time now() const override;
};
class CountingClock : public Clock {
public:
CountingClock(int64_t start, int64_t increment) : _increment(increment), _nextTime(start) { }
- fastos::SteadyTimeStamp now() const override {
+ vespalib::steady_time now() const override {
int64_t prev = _nextTime;
_nextTime += _increment;
- return fastos::SteadyTimeStamp(prev);
+ return vespalib::steady_time(vespalib::duration(prev));
}
private:
const int64_t _increment;
@@ -37,11 +37,11 @@ private:
class RelativeTime {
public:
RelativeTime(std::unique_ptr<Clock> clock);
- fastos::SteadyTimeStamp timeOfDawn() const { return _start; }
- fastos::TimeStamp timeSinceDawn() const { return _clock->now() - _start; }
- fastos::SteadyTimeStamp now() const { return _clock->now(); }
+ vespalib::steady_time timeOfDawn() const { return _start; }
+ vespalib::duration timeSinceDawn() const { return _clock->now() - _start; }
+ vespalib::steady_time now() const { return _clock->now(); }
private:
- fastos::SteadyTimeStamp _start;
+ vespalib::steady_time _start;
std::unique_ptr<Clock> _clock;
};
@@ -60,7 +60,7 @@ public:
* Will add start timestamp if level is high enough
* @param level
*/
- void start(int level);
+ void start(int level, bool useUTC=true);
/**
* Will give you a trace entry. It will also add a timestamp relative to the creation of the trace.
diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp
index 9af6d7024a2..28af2c14781 100644
--- a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp
+++ b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp
@@ -1,10 +1,10 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/searchlib/queryeval/fake_requestcontext.h>
+#include "fake_requestcontext.h"
namespace search::queryeval {
-FakeRequestContext::FakeRequestContext(attribute::IAttributeContext * context, fastos::SteadyTimeStamp softDoom, fastos::SteadyTimeStamp hardDoom)
+FakeRequestContext::FakeRequestContext(attribute::IAttributeContext * context, vespalib::steady_time softDoom, vespalib::steady_time hardDoom)
: _clock(),
_doom(_clock, softDoom, hardDoom, false),
_attributeContext(context),
diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h
index 184e0f7faf8..3de464224f9 100644
--- a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h
+++ b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h
@@ -17,8 +17,8 @@ class FakeRequestContext : public IRequestContext
{
public:
FakeRequestContext(attribute::IAttributeContext * context = nullptr,
- fastos::SteadyTimeStamp soft=fastos::SteadyTimeStamp::FUTURE,
- fastos::SteadyTimeStamp hard=fastos::SteadyTimeStamp::FUTURE);
+ vespalib::steady_time soft=vespalib::steady_time::max(),
+ vespalib::steady_time hard=vespalib::steady_time::max());
~FakeRequestContext();
const vespalib::Doom & getDoom() const override { return _doom; }
const attribute::IAttributeVector *getAttribute(const vespalib::string &name) const override {
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.cpp b/searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.cpp
index 8f8166a2806..4e1544ee5d7 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.cpp
+++ b/searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.cpp
@@ -11,7 +11,7 @@ GetDocsumArgs::GetDocsumArgs()
_stackItems(0),
_stackDump(),
_location(),
- _timeout(30 * fastos::TimeStamp::SEC),
+ _timeout(30s),
_propertiesMap()
{ }
@@ -19,18 +19,6 @@ GetDocsumArgs::GetDocsumArgs()
GetDocsumArgs::~GetDocsumArgs() = default;
void
-GetDocsumArgs::setTimeout(const fastos::TimeStamp & timeout)
-{
- _timeout = timeout;
-}
-
-fastos::TimeStamp
-GetDocsumArgs::getTimeout() const
-{
- return _timeout;
-}
-
-void
GetDocsumArgs::initFromDocsumRequest(const search::engine::DocsumRequest &req)
{
_ranking = req.ranking;
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.h b/searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.h
index ce5dc695f08..c17f44baec9 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.h
+++ b/searchsummary/src/vespa/searchsummary/docsummary/getdocsumargs.h
@@ -14,14 +14,14 @@ public:
typedef engine::PropertiesMap PropsMap;
private:
- vespalib::string _ranking;
- vespalib::string _resultClassName;
- bool _dumpFeatures;
- uint32_t _stackItems;
- std::vector<char> _stackDump;
- vespalib::string _location;
- fastos::TimeStamp _timeout;
- PropsMap _propertiesMap;
+ vespalib::string _ranking;
+ vespalib::string _resultClassName;
+ bool _dumpFeatures;
+ uint32_t _stackItems;
+ std::vector<char> _stackDump;
+ vespalib::string _location;
+ vespalib::duration _timeout;
+ PropsMap _propertiesMap;
public:
GetDocsumArgs();
~GetDocsumArgs();
@@ -35,8 +35,8 @@ public:
_location = location;
}
- void setTimeout(const fastos::TimeStamp & timeout);
- fastos::TimeStamp getTimeout() const;
+ void setTimeout(vespalib::duration timeout) { _timeout = timeout; }
+ vespalib::duration getTimeout() const { return _timeout; }
const vespalib::string & getResultClassName() const { return _resultClassName; }
const vespalib::string & getLocation() const { return _location; }
diff --git a/staging_vespalib/src/tests/clock/clock_benchmark.cpp b/staging_vespalib/src/tests/clock/clock_benchmark.cpp
index a9618d50682..1a4cb20e338 100644
--- a/staging_vespalib/src/tests/clock/clock_benchmark.cpp
+++ b/staging_vespalib/src/tests/clock/clock_benchmark.cpp
@@ -10,7 +10,10 @@
#include <mutex>
using vespalib::Clock;
-using fastos::TimeStamp;
+using vespalib::steady_time;
+using vespalib::steady_clock;
+using vespalib::duration;
+using vespalib::to_s;
struct UpdateClock {
virtual ~UpdateClock() {}
@@ -89,12 +92,12 @@ struct Sampler : public SamplerBase {
{ }
void Run(FastOS_ThreadInterface *, void *) override {
uint64_t samples;
- fastos::SteadyTimeStamp prev = _func();
+ steady_time prev = _func();
for (samples = 0; (samples < _samples); samples++) {
- fastos::SteadyTimeStamp now = _func();
- fastos::TimeStamp diff = now - prev;
- if (diff > 0) prev = now;
- _count[1 + ((diff == 0) ? 0 : (diff > 0) ? 1 : -1)]++;
+ steady_time now = _func();
+ duration diff = now - prev;
+ if (diff > duration::zero()) prev = now;
+ _count[1 + ((diff == duration::zero()) ? 0 : (diff > duration::zero()) ? 1 : -1)]++;
}
}
@@ -105,7 +108,7 @@ template<typename Func>
void benchmark(const char * desc, FastOS_ThreadPool & pool, uint64_t samples, uint32_t numThreads, Func func) {
std::vector<std::unique_ptr<SamplerBase>> threads;
threads.reserve(numThreads);
- fastos::SteadyTimeStamp start = fastos::ClockSteady::now();
+ steady_time start = steady_clock::now();
for (uint32_t i(0); i < numThreads; i++) {
SamplerBase * sampler = new Sampler<Func>(func, i);
sampler->_samples = samples;
@@ -120,7 +123,7 @@ void benchmark(const char * desc, FastOS_ThreadPool & pool, uint64_t samples, ui
count[i] += sampler->_count[i];
}
}
- printf("%s: Took %ld clock samples in %2.3f with [%ld, %ld, %ld] counts\n", desc, samples, (fastos::ClockSteady::now() - start).sec(), count[0], count[1], count[2]);
+ printf("%s: Took %ld clock samples in %2.3f with [%ld, %ld, %ld] counts\n", desc, samples, to_s(steady_clock ::now() - start), count[0], count[1], count[2]);
}
int
@@ -146,26 +149,26 @@ main(int , char *argv[])
return clock.getTimeNSAssumeRunning();
});
benchmark("uint64_t", pool, samples, numThreads, [&nsValue]() {
- return fastos::SteadyTimeStamp(nsValue._value) ;
+ return steady_time (duration(nsValue._value));
});
benchmark("volatile uint64_t", pool, samples, numThreads, [&nsVolatile]() {
- return fastos::SteadyTimeStamp(nsVolatile._value) ;
+ return steady_time(duration(nsVolatile._value));
});
benchmark("memory_order_relaxed", pool, samples, numThreads, [&nsAtomic]() {
- return fastos::SteadyTimeStamp(nsAtomic._value.load(std::memory_order_relaxed)) ;
+ return steady_time(duration(nsAtomic._value.load(std::memory_order_relaxed)));
});
benchmark("memory_order_consume", pool, samples, numThreads, [&nsAtomic]() {
- return fastos::SteadyTimeStamp(nsAtomic._value.load(std::memory_order_consume)) ;
+ return steady_time(duration(nsAtomic._value.load(std::memory_order_consume)));
});
benchmark("memory_order_acquire", pool, samples, numThreads, [&nsAtomic]() {
- return fastos::SteadyTimeStamp(nsAtomic._value.load(std::memory_order_acquire)) ;
+ return steady_time(duration(nsAtomic._value.load(std::memory_order_acquire)));
});
benchmark("memory_order_seq_cst", pool, samples, numThreads, [&nsAtomic]() {
- return fastos::SteadyTimeStamp(nsAtomic._value.load(std::memory_order_seq_cst)) ;
+ return steady_time(duration(nsAtomic._value.load(std::memory_order_seq_cst)));
});
- benchmark("fastos::ClockSteady::now()", pool, samples, numThreads, []() {
- return fastos::ClockSteady::now();
+ benchmark("vespalib::steady_time::now()", pool, samples, numThreads, []() {
+ return steady_clock::now();
});
pool.Close();
diff --git a/staging_vespalib/src/tests/clock/clock_test.cpp b/staging_vespalib/src/tests/clock/clock_test.cpp
index b5650244a45..4a06787fce5 100644
--- a/staging_vespalib/src/tests/clock/clock_test.cpp
+++ b/staging_vespalib/src/tests/clock/clock_test.cpp
@@ -2,11 +2,11 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/clock.h>
-#include <vespa/vespalib/util/time.h>
#include <vespa/fastos/thread.h>
using vespalib::Clock;
-using fastos::TimeStamp;
+using vespalib::duration;
+using vespalib::steady_time;
TEST("Test that clock is ticking forward") {
@@ -14,15 +14,15 @@ TEST("Test that clock is ticking forward") {
Clock clock(0.050);
FastOS_ThreadPool pool(0x10000);
ASSERT_TRUE(pool.NewThread(clock.getRunnable(), nullptr) != nullptr);
- fastos::SteadyTimeStamp start = clock.getTimeNS();
+ steady_time start = clock.getTimeNS();
std::this_thread::sleep_for(5s);
- fastos::SteadyTimeStamp stop = clock.getTimeNS();
+ steady_time stop = clock.getTimeNS();
EXPECT_TRUE(stop > start);
std::this_thread::sleep_for(6s);
clock.stop();
- fastos::SteadyTimeStamp stop2 = clock.getTimeNS();
+ steady_time stop2 = clock.getTimeNS();
EXPECT_TRUE(stop2 > stop);
- EXPECT_TRUE((stop2 - stop)/TimeStamp::MICRO > 1000);
+ EXPECT_TRUE(vespalib::count_ms(stop2 - stop) > 1000);
}
TEST_MAIN() { TEST_RUN_ALL(); } \ No newline at end of file
diff --git a/staging_vespalib/src/vespa/vespalib/util/clock.cpp b/staging_vespalib/src/vespa/vespalib/util/clock.cpp
index cd2a13029ab..0a7f89781e8 100644
--- a/staging_vespalib/src/vespa/vespalib/util/clock.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/clock.cpp
@@ -80,7 +80,7 @@ Clock::~Clock()
void Clock::setTime() const
{
- _timeNS.store(fastos::ClockSteady::now() - fastos::SteadyTimeStamp::ZERO, std::memory_order_relaxed);
+ _timeNS.store(count_ns(steady_clock::now().time_since_epoch()), std::memory_order_relaxed);
}
void
diff --git a/staging_vespalib/src/vespa/vespalib/util/clock.h b/staging_vespalib/src/vespa/vespalib/util/clock.h
index e9e1ebace3f..d506b0c7e16 100644
--- a/staging_vespalib/src/vespa/vespalib/util/clock.h
+++ b/staging_vespalib/src/vespa/vespalib/util/clock.h
@@ -1,7 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <vespa/fastos/timestamp.h>
+#include <vespa/vespalib/util/time.h>
#include <atomic>
#include <memory>
@@ -31,14 +31,14 @@ public:
Clock(double timePeriod=0.100);
~Clock();
- fastos::SteadyTimeStamp getTimeNS() const {
+ vespalib::steady_time getTimeNS() const {
if (!_running) {
setTime();
}
return getTimeNSAssumeRunning();
}
- fastos::SteadyTimeStamp getTimeNSAssumeRunning() const {
- return fastos::SteadyTimeStamp(_timeNS.load(std::memory_order_relaxed));
+ vespalib::steady_time getTimeNSAssumeRunning() const {
+ return vespalib::steady_time(std::chrono::nanoseconds(_timeNS.load(std::memory_order_relaxed)));
}
void stop();
diff --git a/staging_vespalib/src/vespa/vespalib/util/doom.cpp b/staging_vespalib/src/vespa/vespalib/util/doom.cpp
index 87b24799721..329f4cad913 100644
--- a/staging_vespalib/src/vespa/vespalib/util/doom.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/doom.cpp
@@ -4,8 +4,8 @@
namespace vespalib {
-Doom::Doom(const vespalib::Clock &clock, fastos::SteadyTimeStamp softDoom,
- fastos::SteadyTimeStamp hardDoom, bool explicitSoftDoom)
+Doom::Doom(const vespalib::Clock &clock, steady_time softDoom,
+ steady_time hardDoom, bool explicitSoftDoom)
: _clock(clock),
_softDoom(softDoom),
_hardDoom(hardDoom),
diff --git a/staging_vespalib/src/vespa/vespalib/util/doom.h b/staging_vespalib/src/vespa/vespalib/util/doom.h
index d85c3dc9084..dc3d124fc71 100644
--- a/staging_vespalib/src/vespa/vespalib/util/doom.h
+++ b/staging_vespalib/src/vespa/vespalib/util/doom.h
@@ -8,22 +8,22 @@ namespace vespalib {
class Doom {
public:
- Doom(const vespalib::Clock &clock, fastos::SteadyTimeStamp doom)
+ Doom(const Clock &clock, steady_time doom)
: Doom(clock, doom, doom, false)
{}
- Doom(const vespalib::Clock &clock, fastos::SteadyTimeStamp softDoom,
- fastos::SteadyTimeStamp hardDoom, bool explicitSoftDoom);
+ Doom(const Clock &clock, vespalib::steady_time softDoom,
+ steady_time hardDoom, bool explicitSoftDoom);
bool soft_doom() const { return (_clock.getTimeNSAssumeRunning() > _softDoom); }
bool hard_doom() const { return (_clock.getTimeNSAssumeRunning() > _hardDoom); }
- fastos::TimeStamp soft_left() const { return _softDoom - _clock.getTimeNS(); }
- fastos::TimeStamp hard_left() const { return _hardDoom - _clock.getTimeNS(); }
+ duration soft_left() const { return _softDoom - _clock.getTimeNS(); }
+ duration hard_left() const { return _hardDoom - _clock.getTimeNS(); }
bool isExplicitSoftDoom() const { return _isExplicitSoftDoom; }
private:
- const vespalib::Clock &_clock;
- fastos::SteadyTimeStamp _softDoom;
- fastos::SteadyTimeStamp _hardDoom;
- bool _isExplicitSoftDoom;
+ const Clock &_clock;
+ steady_time _softDoom;
+ steady_time _hardDoom;
+ bool _isExplicitSoftDoom;
};
}
diff --git a/vespalib/src/vespa/vespalib/testkit/test_comparators.cpp b/vespalib/src/vespa/vespalib/testkit/test_comparators.cpp
index d00ad8d954c..b30b3aaa421 100644
--- a/vespalib/src/vespa/vespalib/testkit/test_comparators.cpp
+++ b/vespalib/src/vespa/vespalib/testkit/test_comparators.cpp
@@ -8,7 +8,11 @@ ostream & operator << (ostream & os, system_clock::time_point ts) {
return os << ts.time_since_epoch() << "ns";
}
+ostream & operator << (ostream & os, steady_clock::time_point ts) {
+ return os << ts.time_since_epoch() << "ns";
+}
+
}
namespace vespalib {
-} // namespace vespalib
+} \ No newline at end of file
diff --git a/vespalib/src/vespa/vespalib/testkit/test_comparators.h b/vespalib/src/vespa/vespalib/testkit/test_comparators.h
index 161c125757b..164e486cf4a 100644
--- a/vespalib/src/vespa/vespalib/testkit/test_comparators.h
+++ b/vespalib/src/vespa/vespalib/testkit/test_comparators.h
@@ -14,7 +14,7 @@ ostream & operator << (ostream & os, duration<rep, period> ts) {
}
ostream & operator << (ostream & os, system_clock::time_point ts);
-
+ostream & operator << (ostream & os, steady_clock::time_point ts);
}
diff --git a/vespalib/src/vespa/vespalib/util/time.cpp b/vespalib/src/vespa/vespalib/util/time.cpp
index d38e40a6d6a..fdd13849287 100644
--- a/vespalib/src/vespa/vespalib/util/time.cpp
+++ b/vespalib/src/vespa/vespalib/util/time.cpp
@@ -4,6 +4,13 @@
namespace vespalib {
+system_time
+to_utc(steady_time ts) {
+ system_clock::time_point nowUtc = system_clock::now();
+ steady_time nowSteady = steady_clock::now();
+ return system_time(nowUtc.time_since_epoch() - nowSteady.time_since_epoch() + ts.time_since_epoch());
+}
+
Timer::~Timer() = default;
}
diff --git a/vespalib/src/vespa/vespalib/util/time.h b/vespalib/src/vespa/vespalib/util/time.h
index a3390114bb1..3111239ffab 100644
--- a/vespalib/src/vespa/vespalib/util/time.h
+++ b/vespalib/src/vespa/vespalib/util/time.h
@@ -39,6 +39,8 @@ constexpr double to_s(duration d) {
return std::chrono::duration_cast<std::chrono::duration<double>>(d).count();
}
+system_time to_utc(steady_time ts);
+
constexpr duration from_s(double seconds) {
return std::chrono::duration_cast<duration>(std::chrono::duration<double>(seconds));
}