summaryrefslogtreecommitdiffstats
path: root/searchcorespi
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 /searchcorespi
parent3a8c63f34d8554573b42b0c3749e44ad4f43fb0e (diff)
Use std::chrono.
Diffstat (limited to 'searchcorespi')
-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
4 files changed, 18 insertions, 17 deletions
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;
};