summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-11-18 22:44:04 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-11-20 10:16:58 +0000
commit55069682323b0c204b2ddda696bfcd33f4e47a64 (patch)
tree508042cdb977ec9ea3c6323e8727aa149e09ba54
parent95432b0ec4be8e844fe5433598a9045d0de08fef (diff)
Use C++11 chrono instead prehistoric homegrown stuff.
-rw-r--r--messagebus/src/vespa/messagebus/message.cpp17
-rw-r--r--messagebus/src/vespa/messagebus/message.h42
-rw-r--r--messagebus/src/vespa/messagebus/reply.h2
-rw-r--r--messagebus/src/vespa/messagebus/routablequeue.cpp9
-rw-r--r--messagebus/src/vespa/messagebus/routing/resender.cpp22
-rw-r--r--messagebus/src/vespa/messagebus/routing/resender.h8
-rw-r--r--messagebus/src/vespa/messagebus/systemtimer.cpp7
-rw-r--r--messagebus/src/vespa/messagebus/testlib/receptor.cpp27
-rw-r--r--messagebus_test/src/tests/speed/cpp-client.cpp9
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.cpp30
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.h27
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/fusionrunner.cpp16
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp13
-rw-r--r--searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp15
-rw-r--r--storage/src/vespa/storage/common/statusmetricconsumer.cpp5
15 files changed, 88 insertions, 161 deletions
diff --git a/messagebus/src/vespa/messagebus/message.cpp b/messagebus/src/vespa/messagebus/message.cpp
index c6d1bcce36f..94ef718c404 100644
--- a/messagebus/src/vespa/messagebus/message.cpp
+++ b/messagebus/src/vespa/messagebus/message.cpp
@@ -10,6 +10,7 @@
#include <vespa/log/log.h>
LOG_SETUP(".message");
+using namespace std::chrono;
namespace mbus {
Message::Message() :
@@ -29,7 +30,7 @@ Message::~Message()
string backtrace = vespalib::getStackTrace(0);
LOG(warning, "Deleted message %p with non-empty call-stack. Deleted at:\n%s",
this, backtrace.c_str());
- Reply::UP reply(new EmptyReply());
+ auto reply = std::make_unique<EmptyReply>();
swapState(*reply);
reply->addError(Error(ErrorCode::TRANSIENT_ERROR,
"The message object was deleted while containing state information; "
@@ -55,23 +56,21 @@ Message::swapState(Routable &rhs)
}
Message &
-Message::setTimeReceived(uint64_t timeReceived)
+Message::setTimeReceivedNow()
{
- _timeReceived.SetMilliSecs(timeReceived);
+ _timeReceived = steady_clock::now();
return *this;
}
-Message &
-Message::setTimeReceivedNow()
-{
- _timeReceived.SetNow();
- return *this;
+uint64_t
+Message::getTimeReceived() const {
+ return duration_cast<milliseconds>(_timeReceived.time_since_epoch()).count();
}
uint64_t
Message::getTimeRemainingNow() const
{
- return (uint64_t)std::max(0.0, _timeRemaining - _timeReceived.MilliSecsToNow());
+ return std::max(0L, _timeRemaining - duration_cast<milliseconds>(steady_clock::now() - _timeReceived).count());
}
} // namespace mbus
diff --git a/messagebus/src/vespa/messagebus/message.h b/messagebus/src/vespa/messagebus/message.h
index 539720374d0..4d4c83b06bd 100644
--- a/messagebus/src/vespa/messagebus/message.h
+++ b/messagebus/src/vespa/messagebus/message.h
@@ -3,8 +3,8 @@
#include "routable.h"
#include <vespa/messagebus/routing/route.h>
-#include <vespa/fastos/time.h>
#include <memory>
+#include <chrono>
namespace mbus {
@@ -13,9 +13,10 @@ namespace mbus {
*/
class Message : public Routable {
private:
+ using time_point = std::chrono::steady_clock::time_point;
Route _route;
- FastOS_Time _timeReceived;
- uint64_t _timeRemaining;
+ time_point _timeReceived;
+ int64_t _timeRemaining;
bool _retryEnabled;
uint32_t _retry;
@@ -39,7 +40,7 @@ public:
* will log an error and generate an auto-reply to avoid having the sender
* wait indefinetly for a reply.
*/
- ~Message();
+ ~Message() override;
void swapState(Routable &rhs) override;
@@ -50,20 +51,7 @@ public:
*
* @return The timestamp this was last seen.
*/
- uint64_t getTimeReceived() const { return (uint64_t)_timeReceived.MilliSecs(); }
-
- /**
- * Sets the timestamp for when this message was last seen by message bus to
- * the given time in milliseconds since epoch. Please see comment on {@link
- * #isExpired()} for more information on how to determine whether or not a
- * message has expired. You should never need to call this method yourself,
- * as it is touched automatically whenever message bus encounters a new
- * message.
- *
- * @param timeReceived The time received in milliseconds.
- * @return This, to allow chaining.
- */
- Message &setTimeReceived(uint64_t timeReceived);
+ uint64_t getTimeReceived() const;
/**
* This is a convenience method to call {@link #setTimeReceived(uint64_t)}
@@ -108,14 +96,6 @@ public:
uint64_t getTimeRemainingNow() const;
/**
- * Returns whether or not this message has expired.
- *
- * @return True if {@link this#getTimeRemainingNow()} is less than or equal
- * to zero.
- */
- bool isExpired() { return getTimeRemainingNow() == 0; }
-
- /**
* Access the route associated with this message.
*
* @return reference to internal route object
@@ -173,16 +153,6 @@ public:
virtual bool hasBucketSequence() { return false; }
/**
- * Returns the identifier used to order message buckets. Any two messages
- * that have the same bucket sequence are ensured to arrive at the NEXT peer
- * in the order they were sent by THIS peer. This value is only respected if
- * the {@link #hasBucketSequence()} method returns true.
- *
- * @return The bucket sequence.
- */
- virtual uint64_t getBucketSequence() { return 0; }
-
- /**
* Obtain the approximate size of this message object in bytes. This enables
* messagebus to track the size of the send queue in both memory usage and
* item count. This method returns 1 by default, and must be overridden to
diff --git a/messagebus/src/vespa/messagebus/reply.h b/messagebus/src/vespa/messagebus/reply.h
index a7040c0cbb9..64b9f5c0b13 100644
--- a/messagebus/src/vespa/messagebus/reply.h
+++ b/messagebus/src/vespa/messagebus/reply.h
@@ -40,7 +40,7 @@ public:
* will log an error and generate an auto-reply to avoid having the sender
* wait indefinetly for a reply.
*/
- ~Reply();
+ ~Reply() override;
void swapState(Routable &rhs) override;
bool isReply() const override;
diff --git a/messagebus/src/vespa/messagebus/routablequeue.cpp b/messagebus/src/vespa/messagebus/routablequeue.cpp
index a3ba2ffadd3..eb2d93c6688 100644
--- a/messagebus/src/vespa/messagebus/routablequeue.cpp
+++ b/messagebus/src/vespa/messagebus/routablequeue.cpp
@@ -2,6 +2,8 @@
#include "routablequeue.h"
+using namespace std::chrono;
+
namespace mbus {
RoutableQueue::RoutableQueue()
@@ -39,15 +41,14 @@ RoutableQueue::enqueue(Routable::UP r)
Routable::UP
RoutableQueue::dequeue(uint32_t msTimeout)
{
- FastOS_Time t;
- t.SetNow();
- uint32_t msLeft = msTimeout;
+ steady_clock::time_point startTime = steady_clock::now();
+ uint64_t msLeft = msTimeout;
vespalib::MonitorGuard guard(_monitor);
while (_queue.size() == 0 && msLeft > 0) {
if (!guard.wait(msLeft) || _queue.size() > 0) {
break;
}
- uint32_t elapsed = (uint32_t)t.MilliSecsToNow();
+ uint64_t elapsed = duration_cast<milliseconds>(steady_clock::now() - startTime).count();
msLeft = (elapsed > msTimeout) ? 0 : msTimeout - elapsed;
}
if (_queue.size() == 0) {
diff --git a/messagebus/src/vespa/messagebus/routing/resender.cpp b/messagebus/src/vespa/messagebus/routing/resender.cpp
index 0ba6e0827b2..5385ebd8844 100644
--- a/messagebus/src/vespa/messagebus/routing/resender.cpp
+++ b/messagebus/src/vespa/messagebus/routing/resender.cpp
@@ -6,15 +6,14 @@
#include <vespa/messagebus/tracelevel.h>
#include <vespa/vespalib/util/stringfmt.h>
+using namespace std::chrono;
+
namespace mbus {
Resender::Resender(IRetryPolicy::SP retryPolicy) :
_queue(),
- _retryPolicy(retryPolicy),
- _time()
-{
- _time.SetNow();
-}
+ _retryPolicy(retryPolicy)
+{ }
Resender::~Resender()
{
@@ -30,18 +29,15 @@ Resender::resendScheduled()
typedef std::vector<RoutingNode*> NodeList;
NodeList sendList;
- double now = _time.MilliSecsToNow();
+ time_point now = steady_clock::now();
while (!_queue.empty() && _queue.top().first <= now) {
sendList.push_back(_queue.top().second);
_queue.pop();
}
- for (NodeList::iterator it = sendList.begin();
- it != sendList.end(); ++it)
- {
- (*it)->getTrace().trace(mbus::TraceLevel::COMPONENT,
- "Resender resending message.");
- (*it)->send();
+ for (RoutingNode *node : sendList) {
+ node->getTrace().trace(mbus::TraceLevel::COMPONENT, "Resender resending message.");
+ node->send();
}
}
@@ -87,7 +83,7 @@ Resender::scheduleRetry(RoutingNode &node)
TraceLevel::COMPONENT,
vespalib::make_string("Message scheduled for retry %u in %.3f seconds.", retry, delay));
msg.setRetry(retry);
- _queue.push(Entry((uint64_t)(_time.MilliSecsToNow() + delay * 1000), &node));
+ _queue.push(Entry(steady_clock::now() + milliseconds(static_cast<long>(delay * 1000)), &node));
return true;
}
diff --git a/messagebus/src/vespa/messagebus/routing/resender.h b/messagebus/src/vespa/messagebus/routing/resender.h
index 93752dcfd5c..68b49cde606 100644
--- a/messagebus/src/vespa/messagebus/routing/resender.h
+++ b/messagebus/src/vespa/messagebus/routing/resender.h
@@ -5,7 +5,6 @@
#include <vespa/messagebus/queue.h>
#include <vespa/messagebus/reply.h>
#include <vespa/vespalib/util/sync.h>
-#include <vespa/fastos/time.h>
#include <queue>
#include <vector>
@@ -23,18 +22,17 @@ class RoutingNode;
class Resender
{
private:
- typedef std::pair<uint64_t, RoutingNode*> Entry;
+ using time_point = std::chrono::steady_clock::time_point;
+ typedef std::pair<time_point , RoutingNode*> Entry;
struct Cmp {
bool operator()(const Entry &a, const Entry &b) {
return (b.first < a.first);
}
};
- typedef std::priority_queue<Entry, std::vector<Entry>, Cmp> PriorityQueue;
+ using PriorityQueue = std::priority_queue<Entry, std::vector<Entry>, Cmp>;
PriorityQueue _queue;
IRetryPolicy::SP _retryPolicy;
- FastOS_Time _time;
-
public:
/**
* Convenience typedefs.
diff --git a/messagebus/src/vespa/messagebus/systemtimer.cpp b/messagebus/src/vespa/messagebus/systemtimer.cpp
index 6c787509fbf..0570d81ce68 100644
--- a/messagebus/src/vespa/messagebus/systemtimer.cpp
+++ b/messagebus/src/vespa/messagebus/systemtimer.cpp
@@ -1,15 +1,14 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "systemtimer.h"
-#include <vespa/fastos/time.h>
+#include <chrono>
+using namespace std::chrono;
namespace mbus {
uint64_t
SystemTimer::getMilliTime() const
{
- FastOS_Time time;
- time.SetNow();
- return (uint64_t)time.MilliSecs();
+ return duration_cast<milliseconds>(steady_clock::now().time_since_epoch()).count();
}
} // namespace mbus
diff --git a/messagebus/src/vespa/messagebus/testlib/receptor.cpp b/messagebus/src/vespa/messagebus/testlib/receptor.cpp
index f821021a482..f98a4be05c3 100644
--- a/messagebus/src/vespa/messagebus/testlib/receptor.cpp
+++ b/messagebus/src/vespa/messagebus/testlib/receptor.cpp
@@ -2,17 +2,12 @@
#include "receptor.h"
-namespace mbus {
+using namespace std::chrono;
-Receptor::Receptor()
- : IMessageHandler(),
- IReplyHandler(),
- _mon(),
- _msg(),
- _reply()
-{ }
+namespace mbus {
-Receptor::~Receptor() {}
+Receptor::Receptor() = default;
+Receptor::~Receptor() = default;
void
Receptor::handleMessage(Message::UP msg)
@@ -33,12 +28,11 @@ Receptor::handleReply(Reply::UP reply)
Message::UP
Receptor::getMessage(double maxWait)
{
- int ms = (int)(maxWait * 1000);
- FastOS_Time startTime;
- startTime.SetNow();
+ int64_t ms = (int64_t)(maxWait * 1000);
+ steady_clock::time_point startTime = steady_clock::now();
vespalib::MonitorGuard guard(_mon);
while (_msg.get() == 0) {
- int w = ms - (int)startTime.MilliSecsToNow();
+ int64_t w = ms - duration_cast<milliseconds>(steady_clock::now() - startTime).count();
if (w <= 0 || !guard.wait(w)) {
break;
}
@@ -49,12 +43,11 @@ Receptor::getMessage(double maxWait)
Reply::UP
Receptor::getReply(double maxWait)
{
- int ms = (int)(maxWait * 1000);
- FastOS_Time startTime;
- startTime.SetNow();
+ int64_t ms = (int)(maxWait * 1000);
+ steady_clock::time_point startTime = steady_clock::now();
vespalib::MonitorGuard guard(_mon);
while (_reply.get() == 0) {
- int w = ms - (int)startTime.MilliSecsToNow();
+ int64_t w = ms - duration_cast<milliseconds>(steady_clock::now() - startTime).count();
if (w <= 0 || !guard.wait(w)) {
break;
}
diff --git a/messagebus_test/src/tests/speed/cpp-client.cpp b/messagebus_test/src/tests/speed/cpp-client.cpp
index 8f65e919e97..299b2a01948 100644
--- a/messagebus_test/src/tests/speed/cpp-client.cpp
+++ b/messagebus_test/src/tests/speed/cpp-client.cpp
@@ -108,20 +108,17 @@ App::Main()
// let the system 'warm up'
FastOS_Thread::Sleep(5000);
- FastOS_Time start;
- FastOS_Time stop;
+ fastos::StopWatch stopWatch;
uint32_t okBefore = 0;
uint32_t okAfter = 0;
uint32_t failBefore = 0;
uint32_t failAfter = 0;
- start.SetNow();
client.sample(okBefore, failBefore);
FastOS_Thread::Sleep(10000); // Benchmark time
- stop.SetNow();
+ stopWatch.stop();
client.sample(okAfter, failAfter);
- stop -= start;
- double time = stop.MilliSecs();
+ double time = stopWatch.elapsed().ms();
double msgCnt = (double)(okAfter - okBefore);
double throughput = (msgCnt / time) * 1000.0;
fprintf(stdout, "CPP-CLIENT: %g msg/s\n", throughput);
diff --git a/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.cpp b/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.cpp
index 19175d1e2c7..5598b80b1ca 100644
--- a/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.cpp
@@ -2,7 +2,6 @@
#include "transactionlogmanagerbase.h"
#include <vespa/vespalib/util/stringfmt.h>
-#include <vespa/fastos/time.h>
#include <vespa/log/log.h>
LOG_SETUP(".proton.server.transactionlogmanagerbase");
@@ -21,7 +20,7 @@ TransactionLogManagerBase::TransactionLogManagerBase(
_replayCond(),
_replayDone(false),
_replayStarted(false),
- _replayStartTime(0)
+ _replayStopWatch()
{
}
@@ -31,7 +30,7 @@ TransactionLogManagerBase::StatusResult
TransactionLogManagerBase::init()
{
TransLogClient::Session::UP session = _tlc.open(_domainName);
- if (session.get() == NULL) {
+ if ( ! session) {
if (!_tlc.create(_domainName)) {
vespalib::string str = vespalib::make_string(
"Failed creating domain '%s' on TLS '%s'",
@@ -41,7 +40,7 @@ TransactionLogManagerBase::init()
LOG(debug, "Created domain '%s' on TLS '%s'",
_domainName.c_str(), _tlc.getRPCTarget().c_str());
session = _tlc.open(_domainName);
- if (session.get() == NULL) {
+ if ( ! session) {
vespalib::string str = vespalib::make_string(
"Could not open session for domain '%s' on TLS '%s'",
_domainName.c_str(), _tlc.getRPCTarget().c_str());
@@ -70,16 +69,7 @@ TransactionLogManagerBase::internalStartReplay()
std::lock_guard<std::mutex> guard(_replayLock);
_replayStarted = true;
_replayDone = false;
- FastOS_Time timer;
- timer.SetNow();
- _replayStartTime = timer.MilliSecs();
-}
-
-void
-TransactionLogManagerBase::markReplayStarted()
-{
- std::lock_guard<std::mutex> guard(_replayLock);
- _replayStarted = true;
+ _replayStopWatch = fastos::StopWatch();
}
void TransactionLogManagerBase::changeReplayDone()
@@ -101,18 +91,18 @@ TransactionLogManagerBase::waitForReplayDone() const
void
TransactionLogManagerBase::close()
{
- if (_tlcSession.get() != NULL) {
+ if (_tlcSession) {
_tlcSession->close();
}
// Delay destruction until replay is not active.
waitForReplayDone();
- if (_tlcSession.get() != NULL) {
+ if (_tlcSession) {
_tlcSession->clear();
}
}
-TransLogClient::Visitor::UP TransactionLogManagerBase::createTlcVisitor(
- TransLogClient::Session::Callback &callback) {
+TransLogClient::Visitor::UP
+TransactionLogManagerBase::createTlcVisitor(TransLogClient::Session::Callback &callback) {
return _tlc.createVisitor(_domainName, callback);
}
@@ -127,9 +117,7 @@ bool TransactionLogManagerBase::isDoingReplay() const {
}
void TransactionLogManagerBase::logReplayComplete() const {
- FastOS_Time timer;
- timer.SetMilliSecs(_replayStartTime);
- doLogReplayComplete(_domainName, static_cast<int64_t>(timer.MilliSecsToNow()));
+ doLogReplayComplete(_domainName, _replayStopWatch.stop().elapsed().ms());
}
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.h b/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.h
index 9f4e63842cd..d5a7ab41af0 100644
--- a/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.h
+++ b/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.h
@@ -5,6 +5,7 @@
#include <vespa/searchlib/transactionlog/translogclient.h>
#include <mutex>
#include <condition_variable>
+#include <vespa/fastos/timestamp.h>
namespace proton {
@@ -12,18 +13,19 @@ namespace proton {
* Base class managing the initialization and replay of a transaction log.
**/
class TransactionLogManagerBase {
-
- search::transactionlog::TransLogClient _tlc;
- search::transactionlog::TransLogClient::Session::UP _tlcSession;
- vespalib::string _domainName;
- mutable std::mutex _replayLock;
+protected:
+ using TransLogClient = search::transactionlog::TransLogClient;
+private:
+ TransLogClient _tlc;
+ TransLogClient::Session::UP _tlcSession;
+ vespalib::string _domainName;
+ mutable std::mutex _replayLock;
mutable std::condition_variable _replayCond;
- volatile bool _replayDone;
- bool _replayStarted;
- double _replayStartTime;
+ volatile bool _replayDone;
+ bool _replayStarted;
+ mutable fastos::StopWatch _replayStopWatch;
protected:
- typedef search::transactionlog::TransLogClient TransLogClient;
typedef search::SerialNum SerialNum;
struct StatusResult {
@@ -36,8 +38,7 @@ protected:
StatusResult init();
void internalStartReplay();
- virtual void doLogReplayComplete(const vespalib::string &domainName,
- int64_t elapsedTime) const = 0;
+ virtual void doLogReplayComplete(const vespalib::string &domainName, int64_t elapsedTime) const = 0;
public:
TransactionLogManagerBase(const TransactionLogManagerBase &) = delete;
@@ -65,10 +66,6 @@ public:
bool isDoingReplay() const;
void logReplayComplete() const;
const vespalib::string &getRpcTarget() const { return _tlc.getRPCTarget(); }
-
- void
- markReplayStarted();
};
} // namespace proton
-
diff --git a/searchcorespi/src/vespa/searchcorespi/index/fusionrunner.cpp b/searchcorespi/src/vespa/searchcorespi/index/fusionrunner.cpp
index 009bf5d16d9..fd9aea19faa 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/fusionrunner.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/fusionrunner.cpp
@@ -7,7 +7,6 @@
#include <vespa/searchlib/attribute/fixedsourceselector.h>
#include <vespa/searchlib/queryeval/isourceselector.h>
#include <vespa/searchlib/util/dirtraverse.h>
-#include <vespa/vespalib/util/jsonwriter.h>
#include <vespa/log/log.h>
LOG_SETUP(".searchcorespi.index.fusionrunner");
@@ -23,7 +22,6 @@ using search::diskindex::SelectorArray;
using search::SerialNum;
using std::vector;
using vespalib::string;
-using vespalib::JSONStringer;
namespace searchcorespi::index {
@@ -37,8 +35,7 @@ FusionRunner::FusionRunner(const string &base_dir,
_fileHeaderContext(fileHeaderContext)
{ }
-FusionRunner::~FusionRunner() {
-}
+FusionRunner::~FusionRunner() = default;
namespace {
@@ -102,16 +99,15 @@ FusionRunner::fuse(const FusionSpec &fusion_spec,
id_map[0] = sources.size();
sources.push_back(_diskLayout.getFusionDir(fusion_spec.last_fusion_id));
}
- for (size_t i = 0; i < ids.size(); ++i) {
- id_map[ids[i] - fusion_spec.last_fusion_id] = sources.size();
- sources.push_back(_diskLayout.getFlushDir(ids[i]));
+ for (uint32_t id : ids) {
+ id_map[id - fusion_spec.last_fusion_id] = sources.size();
+ sources.push_back(_diskLayout.getFlushDir(id));
}
if (LOG_WOULD_LOG(event)) {
EventLogger::diskFusionStart(sources, fusion_dir);
}
- FastOS_Time timer;
- timer.SetNow();
+ fastos::StopWatch stopWatch;
const string selector_name = IndexDiskLayout::getSelectorFileName(_diskLayout.getFlushDir(fusion_id));
SelectorArray selector_array;
@@ -128,7 +124,7 @@ FusionRunner::fuse(const FusionSpec &fusion_spec,
}
if (LOG_WOULD_LOG(event)) {
- EventLogger::diskFusionComplete(fusion_dir, (int64_t)timer.MilliSecsToNow());
+ EventLogger::diskFusionComplete(fusion_dir, stopWatch.stop().elapsed().ms());
}
return fusion_id;
}
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
index 45bd2a52349..f9bd2c0776c 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
@@ -10,7 +10,6 @@
#include "indexwriteutilities.h"
#include <vespa/fastos/file.h>
#include <vespa/searchcorespi/flush/closureflushtask.h>
-#include <vespa/searchlib/common/serialnumfileheadercontext.h>
#include <vespa/searchlib/index/schemautil.h>
#include <vespa/searchlib/util/dirtraverse.h>
#include <vespa/searchlib/util/filekit.h>
@@ -277,14 +276,13 @@ IndexMaintainer::loadDiskIndex(const string &indexDir)
if (LOG_WOULD_LOG(event)) {
EventLogger::diskIndexLoadStart(indexDir);
}
- FastOS_Time timer;
- timer.SetNow();
+ fastos::StopWatch stopWatch;
_active_indexes->setActive(indexDir);
IDiskIndex::SP retval(new DiskIndexWithDestructorClosure
(_operations.loadDiskIndex(indexDir),
makeClosure(this, &IndexMaintainer::deactivateDiskIndexes, indexDir)));
if (LOG_WOULD_LOG(event)) {
- EventLogger::diskIndexLoadComplete(indexDir, (int64_t)timer.MilliSecsToNow());
+ EventLogger::diskIndexLoadComplete(indexDir, stopWatch.stop().elapsed().ms());
}
return retval;
}
@@ -297,8 +295,7 @@ IndexMaintainer::reloadDiskIndex(const IDiskIndex &oldIndex)
if (LOG_WOULD_LOG(event)) {
EventLogger::diskIndexLoadStart(indexDir);
}
- FastOS_Time timer;
- timer.SetNow();
+ fastos::StopWatch stopWatch;
_active_indexes->setActive(indexDir);
const IDiskIndex &wrappedDiskIndex =
(dynamic_cast<const DiskIndexWithDestructorClosure &>(oldIndex)).getWrapped();
@@ -306,7 +303,7 @@ IndexMaintainer::reloadDiskIndex(const IDiskIndex &oldIndex)
(_operations.reloadDiskIndex(wrappedDiskIndex),
makeClosure(this, &IndexMaintainer::deactivateDiskIndexes, indexDir)));
if (LOG_WOULD_LOG(event)) {
- EventLogger::diskIndexLoadComplete(indexDir, (int64_t)timer.MilliSecsToNow());
+ EventLogger::diskIndexLoadComplete(indexDir, stopWatch.stop().elapsed().ms());
}
return retval;
}
@@ -441,7 +438,7 @@ IndexMaintainer::FlushArgs::FlushArgs()
_prunedSchema()
{
}
-IndexMaintainer::FlushArgs::~FlushArgs() { }
+IndexMaintainer::FlushArgs::~FlushArgs() = default;
IndexMaintainer::FlushArgs::FlushArgs(FlushArgs &&) = default;
IndexMaintainer::FlushArgs & IndexMaintainer::FlushArgs::operator=(FlushArgs &&) = default;
diff --git a/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp b/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp
index b2920b39eaf..b414671748c 100644
--- a/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp
+++ b/searchsummary/src/tests/extractkeywords/extractkeywordstest.cpp
@@ -3,7 +3,7 @@
#include "extractkeywordstest.h"
#include <vespa/searchsummary/docsummary/keywordextractor.h>
#include <vespa/searchlib/parsequery/simplequerystack.h>
-#include <vespa/fastos/time.h>
+#include <vespa/fastos/timestamp.h>
#define NUMTESTS 5
@@ -94,11 +94,10 @@ ExtractKeywordsTest::Main()
int testCnt = 0;
// init keyword extractor
- _extractor = new search::docsummary::KeywordExtractor(NULL);
+ _extractor = new search::docsummary::KeywordExtractor(nullptr);
_extractor->AddLegalIndexSpec("*");
- FastOS_Time timer;
- timer.SetNow();
+ fastos::StopWatch timer;
// Actually run the tests that we wanted.
for (int j = 0; j < multiplier; j++)
@@ -110,7 +109,7 @@ ExtractKeywordsTest::Main()
}
// Print time taken
- double timeTaken = timer.MilliSecsToNow();
+ double timeTaken = timer.stop().elapsed().ms();
printf("Time taken : %f ms\n", timeTaken);
printf("Number of tests run: %d\n", testCnt);
@@ -118,7 +117,7 @@ ExtractKeywordsTest::Main()
printf("Tests pr Sec: %f\n", avgTestPrMSec * 1000.0);
delete _extractor;
- _extractor = NULL;
+ _extractor = nullptr;
return failed ? 1 : 0;
}
@@ -159,8 +158,8 @@ ExtractKeywordsTest::RunTest(int testno, bool verify)
{
search::SimpleQueryStack stack;
search::RawBuf buf(32768);
- const char *correct = NULL;
- const char *keywords = NULL;
+ const char *correct = nullptr;
+ const char *keywords = nullptr;
switch (testno) {
case 0:
diff --git a/storage/src/vespa/storage/common/statusmetricconsumer.cpp b/storage/src/vespa/storage/common/statusmetricconsumer.cpp
index d458a821e02..6d5b6b1eb2b 100644
--- a/storage/src/vespa/storage/common/statusmetricconsumer.cpp
+++ b/storage/src/vespa/storage/common/statusmetricconsumer.cpp
@@ -33,9 +33,7 @@ StatusMetricConsumer::StatusMetricConsumer(
_component.registerStatusPage(*this);
}
-StatusMetricConsumer::~StatusMetricConsumer()
-{
-}
+StatusMetricConsumer::~StatusMetricConsumer() = default;
void
StatusMetricConsumer::updateMetrics(const MetricLockGuard & guard)
@@ -79,7 +77,6 @@ namespace {
name = "Clone of total metrics with active metrics added";
}
std::vector<char> buffer(40);
- //FastOS_Time::GMT_timestr(&buffer[0], data.first)
out << " <tr>\n"
<< " <td>" << name << "</td>\n";
//if (snapshot.getToTime() != 0 || interval < 0 || building != 0)