summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-12-05 14:40:17 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2019-12-05 18:45:15 +0000
commit0a208d8a839f14164cd1561e38cb21a270c64380 (patch)
tree43b5185e77c237d322349edbee03cee30867e6a6
parente4b328f4ee05b55131420df7f6b5a3685d5dffa5 (diff)
Replace UTCTimeStamp with std::chrono::system_clock::time_point
-rw-r--r--fastos/src/vespa/fastos/timestamp.cpp30
-rw-r--r--fastos/src/vespa/fastos/timestamp.h50
-rw-r--r--searchcore/src/tests/proton/attribute/attributeflush_test.cpp18
-rw-r--r--searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp2
-rw-r--r--searchcore/src/tests/proton/flushengine/flushengine_test.cpp2
-rw-r--r--searchcore/src/tests/proton/flushengine/shrink_lid_space_flush_target/shrink_lid_space_flush_target_test.cpp2
-rw-r--r--searchcore/src/tests/proton/index/indexmanager_test.cpp18
-rw-r--r--searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp81
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h9
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp3
-rw-r--r--searchcore/src/vespa/searchcore/proton/docsummary/summarycompacttarget.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/docsummary/summarymanager.cpp6
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/flushengine/flush_engine_explorer.cpp12
-rw-r--r--searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h4
-rw-r--r--searchcore/src/vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.cpp7
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/session_manager_explorer.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/maintenance_jobs_injector.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.cpp4
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp25
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/memoryflush.h11
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/proton.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp5
-rw-r--r--searchcore/src/vespa/searchcore/proton/test/dummy_document_store.h2
-rw-r--r--searchcorespi/src/vespa/searchcorespi/flush/iflushtarget.h4
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexfusiontarget.cpp2
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp7
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h4
-rw-r--r--searchlib/src/tests/docstore/document_store/document_store_test.cpp2
-rw-r--r--searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/docstore/documentstore.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/docstore/documentstore.h2
-rw-r--r--searchlib/src/vespa/searchlib/docstore/filechunk.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/docstore/filechunk.h5
-rw-r--r--searchlib/src/vespa/searchlib/docstore/idatastore.h3
-rw-r--r--searchlib/src/vespa/searchlib/docstore/idocumentstore.h2
-rw-r--r--searchlib/src/vespa/searchlib/docstore/logdatastore.cpp10
-rw-r--r--searchlib/src/vespa/searchlib/docstore/logdatastore.h2
-rw-r--r--searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h4
-rw-r--r--searchlib/src/vespa/searchlib/util/filekit.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/util/filekit.h4
-rw-r--r--staging_vespalib/src/tests/benchmark/testbase.cpp9
45 files changed, 186 insertions, 215 deletions
diff --git a/fastos/src/vespa/fastos/timestamp.cpp b/fastos/src/vespa/fastos/timestamp.cpp
index 977af69049c..bd08eced395 100644
--- a/fastos/src/vespa/fastos/timestamp.cpp
+++ b/fastos/src/vespa/fastos/timestamp.cpp
@@ -4,7 +4,10 @@
#include <thread>
#include <sys/time.h>
-using namespace std::chrono;
+using std::chrono::system_clock;
+using std::chrono::steady_clock;
+using std::chrono::nanoseconds;
+using std::chrono::duration_cast;
namespace fastos {
@@ -16,6 +19,8 @@ const TimeStamp::TimeT TimeStamp::MS;
const TimeStamp::TimeT TimeStamp::SEC;
const TimeStamp::TimeT TimeStamp::MINUTE;
+using seconds = std::chrono::duration<double>;
+
std::string
TimeStamp::asString(double timeInSeconds)
{
@@ -32,15 +37,9 @@ TimeStamp::asString(double timeInSeconds)
return std::string(retval);
}
-UTCTimeStamp
-ClockSystem::now()
-{
- struct timeval timeNow;
- gettimeofday(&timeNow, nullptr);
- int64_t ns = timeNow.tv_sec;
- ns *= TimeStamp::NANO;
- ns += timeNow.tv_usec*1000;
- return UTCTimeStamp(ns);
+std::string
+TimeStamp::asString(std::chrono::system_clock::time_point ns) {
+ return asString(seconds(ns.time_since_epoch()).count());
}
time_t
@@ -58,8 +57,8 @@ steady_now() {
}
std::ostream &
-operator << (std::ostream & os, UTCTimeStamp ts) {
- return os << ts.toString();
+operator << (std::ostream & os, system_clock::time_point ts) {
+ return os << TimeStamp::asString(seconds(ts.time_since_epoch()).count());
}
std::ostream &
@@ -75,13 +74,12 @@ ClockSteady::now()
const SteadyTimeStamp SteadyTimeStamp::ZERO;
const SteadyTimeStamp SteadyTimeStamp::FUTURE(TimeStamp::FUTURE);
-const UTCTimeStamp UTCTimeStamp::ZERO;
-UTCTimeStamp
+system_clock::time_point
SteadyTimeStamp::toUTC() const {
- UTCTimeStamp nowUtc = ClockSystem::now();
+ system_clock::time_point nowUtc = system_clock::now();
SteadyTimeStamp nowSteady = ClockSteady::now();
- return nowUtc - (nowSteady - *this);
+ return system_clock::time_point (std::chrono::nanoseconds(nowUtc.time_since_epoch().count() - (nowSteady - *this).ns()));
}
StopWatch::StopWatch()
diff --git a/fastos/src/vespa/fastos/timestamp.h b/fastos/src/vespa/fastos/timestamp.h
index f1a40272938..842a71edfbe 100644
--- a/fastos/src/vespa/fastos/timestamp.h
+++ b/fastos/src/vespa/fastos/timestamp.h
@@ -48,6 +48,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); }
private:
TimeT _time;
@@ -58,45 +59,6 @@ inline TimeStamp operator -(TimeStamp a, TimeStamp b) { return TimeStamp(a.val()
inline TimeStamp operator *(long a, TimeStamp b) { return TimeStamp(a * b.val()); }
inline TimeStamp operator *(double a, TimeStamp b) { return TimeStamp(static_cast<int64_t>(a * b.val())); }
-class UTCTimeStamp {
-public:
- static const UTCTimeStamp ZERO;
- UTCTimeStamp() : _timeStamp() { }
- explicit UTCTimeStamp(TimeStamp timeStamp) : _timeStamp(timeStamp) { }
-
- friend TimeStamp operator -(UTCTimeStamp a, UTCTimeStamp b) {
- return a._timeStamp - b._timeStamp;
- }
- friend UTCTimeStamp operator -(UTCTimeStamp a, TimeStamp b) {
- return UTCTimeStamp(a._timeStamp - b);
- }
- friend UTCTimeStamp operator +(UTCTimeStamp a, TimeStamp b) {
- return UTCTimeStamp(a._timeStamp + b);
- }
- friend bool operator != (UTCTimeStamp a, UTCTimeStamp b) {
- return a._timeStamp != b._timeStamp;
- }
- friend bool operator == (UTCTimeStamp a, UTCTimeStamp b) {
- return a._timeStamp == b._timeStamp;
- }
- friend bool operator < (UTCTimeStamp a, UTCTimeStamp b) {
- return a._timeStamp < b._timeStamp;
- }
- friend bool operator <= (UTCTimeStamp a, UTCTimeStamp b) {
- return a._timeStamp <= b._timeStamp;
- }
- friend bool operator > (UTCTimeStamp a, UTCTimeStamp b) {
- return a._timeStamp > b._timeStamp;
- }
- friend bool operator >= (UTCTimeStamp a, UTCTimeStamp b) {
- return a._timeStamp >= b._timeStamp;
- }
- TimeStamp time_since_epoch() const { return _timeStamp - ZERO._timeStamp; }
- std::string toString() const { return _timeStamp.toString(); };
-private:
- TimeStamp _timeStamp;
-};
-
class SteadyTimeStamp {
public:
static const SteadyTimeStamp ZERO;
@@ -125,21 +87,15 @@ public:
friend bool operator > (SteadyTimeStamp a, SteadyTimeStamp b) {
return a._timeStamp > b._timeStamp;
}
- UTCTimeStamp toUTC() const;
+ std::chrono::system_clock::time_point toUTC() const;
std::string toString() const { return _timeStamp.toString(); };
private:
TimeStamp _timeStamp;
};
-std::ostream & operator << (std::ostream & os, UTCTimeStamp ts);
+std::ostream & operator << (std::ostream & os, std::chrono::system_clock::time_point ts);
std::ostream & operator << (std::ostream & os, SteadyTimeStamp ts);
-class ClockSystem
-{
-public:
- static UTCTimeStamp now();
-};
-
class ClockSteady
{
public:
diff --git a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp
index ea3d2c335fb..99d4651d13f 100644
--- a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp
+++ b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp
@@ -31,6 +31,7 @@ typedef search::attribute::BasicType AVBasicType;
typedef search::attribute::CollectionType AVCollectionType;
using searchcorespi::IFlushTarget;
using searchcorespi::FlushStats;
+using std::chrono::duration_cast;
using namespace std::literals;
typedef std::shared_ptr<Gate> GateSP;
@@ -500,37 +501,38 @@ Test::requireThatOnlyOneFlusherCanRunAtTheSameTime()
void
Test::requireThatLastFlushTimeIsReported()
{
+ using seconds = std::chrono::seconds;
BaseFixture f;
FastOS_StatInfo stat;
{ // no meta info file yet
AttributeManagerFixture amf(f);
AttributeManager &am = amf._m;
AttributeVector::SP av = amf.addAttribute("a9");
- EXPECT_EQUAL(fastos::UTCTimeStamp::ZERO, am.getFlushable("a9")->getLastFlushTime());
+ EXPECT_EQUAL(vespalib::system_time(), am.getFlushable("a9")->getLastFlushTime());
}
{ // no snapshot flushed yet
AttributeManagerFixture amf(f);
AttributeManager &am = amf._m;
AttributeVector::SP av = amf.addAttribute("a9");
IFlushTarget::SP ft = am.getFlushable("a9");
- EXPECT_EQUAL(fastos::UTCTimeStamp::ZERO, ft->getLastFlushTime());
+ EXPECT_EQUAL(vespalib::system_time(), ft->getLastFlushTime());
ft->initFlush(200)->run();
EXPECT_TRUE(FastOS_File::Stat("flush/a9/snapshot-200", &stat));
- EXPECT_EQUAL(stat._modifiedTime, ft->getLastFlushTime().time_since_epoch().time());
+ EXPECT_EQUAL(seconds(stat._modifiedTime), duration_cast<seconds>(ft->getLastFlushTime().time_since_epoch()));
}
{ // snapshot flushed
AttributeManagerFixture amf(f);
AttributeManager &am = amf._m;
amf.addAttribute("a9");
IFlushTarget::SP ft = am.getFlushable("a9");
- EXPECT_EQUAL(stat._modifiedTime, ft->getLastFlushTime().time_since_epoch().time());
+ EXPECT_EQUAL(seconds(stat._modifiedTime), duration_cast<seconds>(ft->getLastFlushTime().time_since_epoch()));
{ // updated flush time after nothing to flush
std::this_thread::sleep_for(8000ms);
- fastos::TimeStamp now = fastos::ClockSystem::now().time_since_epoch();
+ std::chrono::seconds now = duration_cast<seconds>(vespalib::system_clock::now().time_since_epoch());
Executor::Task::UP task = ft->initFlush(200);
- EXPECT_TRUE(task.get() == NULL);
- EXPECT_LESS(stat._modifiedTime, ft->getLastFlushTime().time_since_epoch().time());
- EXPECT_APPROX(now.time(), ft->getLastFlushTime().time_since_epoch().time(), 8);
+ EXPECT_FALSE(task);
+ EXPECT_LESS(seconds(stat._modifiedTime), ft->getLastFlushTime().time_since_epoch());
+ EXPECT_APPROX(now.count(), duration_cast<seconds>(ft->getLastFlushTime().time_since_epoch()).count(), 8);
}
}
}
diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
index dfac2edad61..fdb7488bf65 100644
--- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp
@@ -46,7 +46,7 @@ using document::BucketId;
using document::Document;
using document::DocumentId;
using document::test::makeBucketSpace;
-using fastos::ClockSystem;
+using vespalib::system_clock;
using fastos::TimeStamp;
using proton::bucketdb::BucketCreateNotifier;
using proton::matching::ISessionCachePruner;
diff --git a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp
index c18d393b98f..b5bcd65cd33 100644
--- a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp
+++ b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp
@@ -279,7 +279,7 @@ public:
: SimpleTarget(name, Type::OTHER, flushedSerial, proceedImmediately)
{ }
- Time getLastFlushTime() const override { return fastos::ClockSystem::now(); }
+ Time getLastFlushTime() const override { return vespalib::system_clock::now(); }
SerialNum getFlushedSerialNum() const override {
LOG(info, "SimpleTarget(%s)::getFlushedSerialNum() = %" PRIu64, getName().c_str(), _flushedSerial);
diff --git a/searchcore/src/tests/proton/flushengine/shrink_lid_space_flush_target/shrink_lid_space_flush_target_test.cpp b/searchcore/src/tests/proton/flushengine/shrink_lid_space_flush_target/shrink_lid_space_flush_target_test.cpp
index 376f37a512e..964cd47afa5 100644
--- a/searchcore/src/tests/proton/flushengine/shrink_lid_space_flush_target/shrink_lid_space_flush_target_test.cpp
+++ b/searchcore/src/tests/proton/flushengine/shrink_lid_space_flush_target/shrink_lid_space_flush_target_test.cpp
@@ -57,7 +57,7 @@ struct Fixture
IFlushTarget::Type::GC,
IFlushTarget::Component::ATTRIBUTE,
10,
- fastos::UTCTimeStamp::ZERO,
+ vespalib::system_time(),
_lidSpace))
{
}
diff --git a/searchcore/src/tests/proton/index/indexmanager_test.cpp b/searchcore/src/tests/proton/index/indexmanager_test.cpp
index 1941e82a2db..7542ef24c52 100644
--- a/searchcore/src/tests/proton/index/indexmanager_test.cpp
+++ b/searchcore/src/tests/proton/index/indexmanager_test.cpp
@@ -20,6 +20,7 @@
#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
+#include <vespa/vespalib/util/time.h>
#include <set>
#include <thread>
@@ -50,11 +51,11 @@ using std::string;
using vespalib::BlockingThreadStackExecutor;
using vespalib::ThreadStackExecutor;
using vespalib::makeLambdaTask;
+using std::chrono::duration_cast;
using namespace proton;
using namespace searchcorespi;
using namespace searchcorespi::index;
-using namespace std::chrono_literals;
namespace {
@@ -266,6 +267,7 @@ readDiskIds(const string &dir, const string &type)
TEST_F(IndexManagerTest, require_that_memory_index_is_flushed)
{
+ using seconds = std::chrono::seconds;
FastOS_StatInfo stat;
{
addDocument(docid);
@@ -275,12 +277,12 @@ TEST_F(IndexManagerTest, require_that_memory_index_is_flushed)
EXPECT_EQ(1u, sources->getSourceId(0));
IndexFlushTarget target(_index_manager->getMaintainer());
- EXPECT_EQ(fastos::UTCTimeStamp::ZERO, target.getLastFlushTime());
+ EXPECT_EQ(vespalib::system_time(), target.getLastFlushTime());
vespalib::Executor::Task::UP flushTask;
runAsMaster([&]() { flushTask = target.initFlush(1); });
flushTask->run();
EXPECT_TRUE(FastOS_File::Stat("test_data/index.flush.1", &stat));
- EXPECT_EQ(stat._modifiedTime, target.getLastFlushTime().time_since_epoch().time());
+ EXPECT_EQ(seconds(stat._modifiedTime), duration_cast<seconds>(target.getLastFlushTime().time_since_epoch()));
sources = get_source_collection();
EXPECT_EQ(2u, sources->getSourceCount());
@@ -298,17 +300,17 @@ TEST_F(IndexManagerTest, require_that_memory_index_is_flushed)
{ // verify last flush time when loading disk index
resetIndexManager();
IndexFlushTarget target(_index_manager->getMaintainer());
- EXPECT_EQ(stat._modifiedTime, target.getLastFlushTime().time_since_epoch().time());
+ EXPECT_EQ(seconds(stat._modifiedTime), duration_cast<seconds>(target.getLastFlushTime().time_since_epoch()));
// updated serial number & flush time when nothing to flush
std::this_thread::sleep_for(8s);
- fastos::TimeStamp now = fastos::ClockSystem::now().time_since_epoch();
+ std::chrono::seconds now = duration_cast<seconds>(vespalib::system_clock::now().time_since_epoch());
vespalib::Executor::Task::UP task;
runAsMaster([&]() { task = target.initFlush(2); });
- EXPECT_TRUE(task.get() == nullptr);
+ EXPECT_FALSE(task);
EXPECT_EQ(2u, target.getFlushedSerialNum());
- EXPECT_LT(stat._modifiedTime, target.getLastFlushTime().time_since_epoch().time());
- EXPECT_NEAR(now.time(), target.getLastFlushTime().time_since_epoch().time(), 8);
+ EXPECT_LT(seconds(stat._modifiedTime), duration_cast<seconds>(target.getLastFlushTime().time_since_epoch()));
+ EXPECT_NEAR(now.count(), duration_cast<seconds>(target.getLastFlushTime().time_since_epoch()).count(), 8);
}
}
diff --git a/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp b/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp
index a1693832506..41eda598726 100644
--- a/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp
+++ b/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp
@@ -5,9 +5,10 @@
#include <vespa/searchcore/proton/flushengine/tls_stats_map.h>
#include <vespa/searchcore/proton/test/dummy_flush_target.h>
#include <vespa/searchcore/proton/server/memoryflush.h>
+#include <vespa/fastos/timestamp.h>
using fastos::TimeStamp;
-using fastos::UTCTimeStamp;
+using vespalib::system_time;
using fastos::SteadyTimeStamp;
using search::SerialNum;
using namespace proton;
@@ -44,12 +45,12 @@ private:
MemoryGain _memoryGain;
DiskGain _diskGain;
SerialNum _flushedSerial;
- UTCTimeStamp _lastFlushTime;
+ system_time _lastFlushTime;
bool _urgentFlush;
public:
MyFlushTarget(const vespalib::string &name, MemoryGain memoryGain,
DiskGain diskGain, SerialNum flushedSerial,
- UTCTimeStamp lastFlushTime, bool urgentFlush) :
+ system_time lastFlushTime, bool urgentFlush) :
test::DummyFlushTarget(name),
_memoryGain(memoryGain),
_diskGain(diskGain),
@@ -62,7 +63,7 @@ public:
virtual MemoryGain getApproxMemoryGain() const override { return _memoryGain; }
virtual DiskGain getApproxDiskGain() const override { return _diskGain; }
virtual SerialNum getFlushedSerialNum() const override { return _flushedSerial; }
- virtual UTCTimeStamp getLastFlushTime() const override { return _lastFlushTime; }
+ virtual system_time getLastFlushTime() const override { return _lastFlushTime; }
virtual bool needUrgentFlush() const override { return _urgentFlush; }
};
@@ -113,6 +114,8 @@ public:
}
};
+using minutes = std::chrono::minutes;
+using seconds = std::chrono::seconds;
ContextBuilder::ContextBuilder()
: _list(), _handler(new MyFlushHandler("myhandler"))
@@ -122,23 +125,23 @@ ContextBuilder::~ContextBuilder() = default;
MyFlushTarget::SP
createTargetM(const vespalib::string &name, MemoryGain memoryGain)
{
- return std::make_shared<MyFlushTarget>(name, memoryGain, DiskGain(),SerialNum(), UTCTimeStamp::ZERO, false);
+ return std::make_shared<MyFlushTarget>(name, memoryGain, DiskGain(),SerialNum(), system_time(), false);
}
MyFlushTarget::SP
createTargetD(const vespalib::string &name, DiskGain diskGain, SerialNum serial = 0)
{
- return std::make_shared<MyFlushTarget>(name, MemoryGain(), diskGain, serial, UTCTimeStamp::ZERO, false);
+ return std::make_shared<MyFlushTarget>(name, MemoryGain(), diskGain, serial, system_time(), false);
}
MyFlushTarget::SP
-createTargetS(const vespalib::string &name, SerialNum serial, UTCTimeStamp timeStamp = UTCTimeStamp::ZERO)
+createTargetS(const vespalib::string &name, SerialNum serial, system_time timeStamp = system_time())
{
return std::make_shared<MyFlushTarget>(name, MemoryGain(), DiskGain(), serial, timeStamp, false);
}
MyFlushTarget::SP
-createTargetT(const vespalib::string &name, UTCTimeStamp lastFlushTime, SerialNum serial = 0)
+createTargetT(const vespalib::string &name, system_time lastFlushTime, SerialNum serial = 0)
{
return std::make_shared<MyFlushTarget>(name, MemoryGain(), DiskGain(), serial, lastFlushTime, false);
}
@@ -146,7 +149,7 @@ createTargetT(const vespalib::string &name, UTCTimeStamp lastFlushTime, SerialNu
MyFlushTarget::SP
createTargetF(const vespalib::string &name, bool urgentFlush)
{
- return std::make_shared<MyFlushTarget>(name, MemoryGain(), DiskGain(), SerialNum(), UTCTimeStamp::ZERO, urgentFlush);
+ return std::make_shared<MyFlushTarget>(name, MemoryGain(), DiskGain(), SerialNum(), system_time(), urgentFlush);
}
bool
@@ -169,12 +172,12 @@ requireThatWeCanOrderByMemoryGain()
.add(createTargetM("t4", MemoryGain(20, 0)))
.add(createTargetM("t3", MemoryGain(15, 0)));
{ // target t4 has memoryGain >= maxMemoryGain
- MemoryFlush flush({1000, 20 * gibi, 1.0, 20, 1.0, TimeStamp(TimeStamp::MINUTE)});
+ MemoryFlush flush({1000, 20 * gibi, 1.0, 20, 1.0, minutes(1)});
EXPECT_TRUE(assertOrder(StringList().add("t4").add("t3").add("t2").add("t1"),
flush.getFlushTargets(cb.list(), cb.tlsStats())));
}
{ // trigger totalMemoryGain >= globalMaxMemory
- MemoryFlush flush({50, 20 * gibi, 1.0, 1000, 1.0, TimeStamp(TimeStamp::MINUTE)});
+ MemoryFlush flush({50, 20 * gibi, 1.0, 1000, 1.0, minutes(1)});
EXPECT_TRUE(assertOrder(StringList().add("t4").add("t3").add("t2").add("t1"),
flush.getFlushTargets(cb.list(), cb.tlsStats())));
}
@@ -193,13 +196,13 @@ requireThatWeCanOrderByDiskGainWithLargeValues()
.add(createTargetD("t3", DiskGain(before, 50 * milli))); // gain 50M
{ // target t4 has diskGain > bloatValue
// t4 gain: 55M / 100M = 0.55 -> bloat factor 0.54 to trigger
- MemoryFlush flush({1000, 20 * gibi, 10.0, 1000, 0.54, TimeStamp(TimeStamp::MINUTE)});
+ MemoryFlush flush({1000, 20 * gibi, 10.0, 1000, 0.54, minutes(1)});
EXPECT_TRUE(assertOrder(StringList().add("t4").add("t3").add("t2").add("t1"),
flush.getFlushTargets(cb.list(), cb.tlsStats())));
}
{ // trigger totalDiskGain > totalBloatValue
// total gain: 160M / 4 * 100M = 0.4 -> bloat factor 0.39 to trigger
- MemoryFlush flush({1000, 20 * gibi, 0.39, 1000, 10.0, TimeStamp(TimeStamp::MINUTE)});
+ MemoryFlush flush({1000, 20 * gibi, 0.39, 1000, 10.0, minutes(1)});
EXPECT_TRUE(assertOrder(StringList().add("t4").add("t3").add("t2").add("t1"),
flush.getFlushTargets(cb.list(), cb.tlsStats())));
}
@@ -217,13 +220,13 @@ requireThatWeCanOrderByDiskGainWithSmallValues()
// target bloat value calculation uses min 100M disk size
{ // target t4 has diskGain > bloatValue
// t4 gain: 55 / 100M = 0.0000055 -> bloat factor 0.0000054 to trigger
- MemoryFlush flush({1000, 20 * gibi, 10.0, 1000, 0.00000054, TimeStamp(TimeStamp::MINUTE)});
+ MemoryFlush flush({1000, 20 * gibi, 10.0, 1000, 0.00000054, minutes(1)});
EXPECT_TRUE(assertOrder(StringList().add("t4").add("t3").add("t2").add("t1"),
flush.getFlushTargets(cb.list(), cb.tlsStats())));
}
{ // trigger totalDiskGain > totalBloatValue
// total gain: 160 / 100M = 0.0000016 -> bloat factor 0.0000015 to trigger
- MemoryFlush flush({1000, 20 * gibi, 0.0000015, 1000, 10.0, TimeStamp(TimeStamp::MINUTE)});
+ MemoryFlush flush({1000, 20 * gibi, 0.0000015, 1000, 10.0, minutes(1)});
EXPECT_TRUE(assertOrder(StringList().add("t4").add("t3").add("t2").add("t1"),
flush.getFlushTargets(cb.list(), cb.tlsStats())));
}
@@ -232,21 +235,21 @@ requireThatWeCanOrderByDiskGainWithSmallValues()
void
requireThatWeCanOrderByAge()
{
- UTCTimeStamp now(fastos::ClockSystem::now());
- UTCTimeStamp start(now - TimeStamp(20 * TimeStamp::SEC));
+ system_time now(vespalib::system_clock::now());
+ system_time start(now - seconds(20));
ContextBuilder cb;
- cb.add(createTargetT("t2", now - TimeStamp(10 * TimeStamp::SEC)))
- .add(createTargetT("t1", now - TimeStamp(5 * TimeStamp::SEC)))
- .add(createTargetT("t4", UTCTimeStamp::ZERO))
- .add(createTargetT("t3", now - TimeStamp(15 * TimeStamp::SEC)));
+ cb.add(createTargetT("t2", now - seconds(10)))
+ .add(createTargetT("t1", now - seconds(5)))
+ .add(createTargetT("t4", system_time()))
+ .add(createTargetT("t3", now - seconds(15)));
{ // all targets have timeDiff >= maxTimeGain
- MemoryFlush flush({1000, 20 * gibi, 1.0, 1000, 1.0, TimeStamp(2 * TimeStamp::SEC)}, start);
+ MemoryFlush flush({1000, 20 * gibi, 1.0, 1000, 1.0, seconds(2)}, start);
EXPECT_TRUE(assertOrder(StringList().add("t4").add("t3").add("t2").add("t1"),
flush.getFlushTargets(cb.list(), cb.tlsStats())));
}
{ // no targets have timeDiff >= maxTimeGain
- MemoryFlush flush({1000, 20 * gibi, 1.0, 1000, 1.0, TimeStamp(30 * TimeStamp::SEC)}, start);
+ MemoryFlush flush({1000, 20 * gibi, 1.0, 1000, 1.0, seconds(30)}, start);
EXPECT_TRUE(assertOrder(StringList(), flush.getFlushTargets(cb.list(), cb.tlsStats())));
}
}
@@ -254,24 +257,24 @@ requireThatWeCanOrderByAge()
void
requireThatWeCanOrderByTlsSize()
{
- UTCTimeStamp now(fastos::ClockSystem::now());
- UTCTimeStamp start = now - TimeStamp(20 * TimeStamp::SEC);
+ system_time now(vespalib::system_clock::now());
+ system_time start = now - seconds(20);
ContextBuilder cb;
IFlushHandler::SP handler1(std::make_shared<MyFlushHandler>("handler1"));
IFlushHandler::SP handler2(std::make_shared<MyFlushHandler>("handler2"));
cb.addTls("handler1", {20 * gibi, 1001, 2000 });
cb.addTls("handler2", { 5 * gibi, 1001, 2000 });
- cb.add(std::make_shared<FlushContext>(handler1, createTargetT("t2", now - TimeStamp(10 * TimeStamp::SEC), 1900), 2000)).
- add(std::make_shared<FlushContext>(handler2, createTargetT("t1", now - TimeStamp(5 * TimeStamp::SEC), 1000), 2000)).
- add(std::make_shared<FlushContext>(handler1, createTargetT("t4", UTCTimeStamp::ZERO, 1000), 2000)).
- add(std::make_shared<FlushContext>(handler2, createTargetT("t3", now - TimeStamp(15 * TimeStamp::SEC), 1900), 2000));
+ cb.add(std::make_shared<FlushContext>(handler1, createTargetT("t2", now - seconds(10), 1900), 2000)).
+ add(std::make_shared<FlushContext>(handler2, createTargetT("t1", now - seconds(5), 1000), 2000)).
+ add(std::make_shared<FlushContext>(handler1, createTargetT("t4", system_time(), 1000), 2000)).
+ add(std::make_shared<FlushContext>(handler2, createTargetT("t3", now - seconds(15), 1900), 2000));
{ // sum of tls sizes above limit, trigger sort order based on tls size
- MemoryFlush flush({1000, 3 * gibi, 1.0, 1000, 1.0, TimeStamp(2 * TimeStamp::SEC)}, start);
+ MemoryFlush flush({1000, 3 * gibi, 1.0, 1000, 1.0, seconds(2)}, start);
EXPECT_TRUE(assertOrder(StringList().add("t4").add("t1").add("t2").add("t3"),
flush.getFlushTargets(cb.list(), cb.tlsStats())));
}
{ // sum of tls sizes below limit
- MemoryFlush flush({1000, 30 * gibi, 1.0, 1000, 1.0, TimeStamp(30 * TimeStamp::SEC)}, start);
+ MemoryFlush flush({1000, 30 * gibi, 1.0, 1000, 1.0, seconds(30)}, start);
EXPECT_TRUE(assertOrder(StringList(), flush.getFlushTargets(cb.list(), cb.tlsStats())));
}
}
@@ -284,38 +287,38 @@ requireThatWeHandleLargeSerialNumbersWhenOrderingByTlsSize()
SerialNum firstSerial = 10;
SerialNum lastSerial = uint32_max + 10;
builder.addTls("myhandler", {uint32_max, firstSerial, lastSerial});
- builder.add(createTargetT("t1", UTCTimeStamp::ZERO, uint32_max + 5), lastSerial);
- builder.add(createTargetT("t2", UTCTimeStamp::ZERO, uint32_max - 5), lastSerial);
+ builder.add(createTargetT("t1", system_time(), uint32_max + 5), lastSerial);
+ builder.add(createTargetT("t2", system_time(), uint32_max - 5), lastSerial);
uint64_t maxMemoryGain = 10;
- MemoryFlush flush({maxMemoryGain, 1000, 0, maxMemoryGain, 0, TimeStamp()}, UTCTimeStamp::ZERO);
+ MemoryFlush flush({maxMemoryGain, 1000, 0, maxMemoryGain, 0, vespalib::duration(0)}, system_time());
EXPECT_TRUE(assertOrder(StringList().add("t2").add("t1"), flush.getFlushTargets(builder.list(), builder.tlsStats())));
}
void
requireThatOrderTypeIsPreserved()
{
- UTCTimeStamp now(fastos::ClockSystem::now());
- UTCTimeStamp ts2 = now - TimeStamp(20 * TimeStamp::SEC);
+ system_time now(vespalib::system_clock::now());
+ system_time ts2 = now - seconds(20);
{ // MAXAGE VS DISKBLOAT
ContextBuilder cb;
cb.add(createTargetT("t2", ts2, 5), 14)
.add(createTargetD("t1", DiskGain(100 * milli, 80 * milli), 5));
- MemoryFlush flush({1000, 20 * gibi, 1.0, 1000, 0.19, TimeStamp(30 * TimeStamp::SEC)});
+ MemoryFlush flush({1000, 20 * gibi, 1.0, 1000, 0.19, seconds(30)});
EXPECT_TRUE(assertOrder(StringList().add("t1").add("t2"), flush.getFlushTargets(cb.list(), cb.tlsStats())));
}
{ // DISKBLOAT VS MEMORY
ContextBuilder cb;
cb.add(createTargetD("t2", DiskGain(100 * milli, 80 * milli)))
.add(createTargetM("t1", MemoryGain(100, 80)));
- MemoryFlush flush({1000, 20 * gibi, 1.0, 20, 0.19, TimeStamp(30 * TimeStamp::SEC)});
+ MemoryFlush flush({1000, 20 * gibi, 1.0, 20, 0.19, seconds(30)});
EXPECT_TRUE(assertOrder(StringList().add("t1").add("t2"), flush.getFlushTargets(cb.list(), cb.tlsStats())));
}
{ // urgent flush
ContextBuilder cb;
cb.add(createTargetF("t2", false))
.add(createTargetF("t1", true));
- MemoryFlush flush({1000, 20 * gibi, 1.0, 1000, 1.0, TimeStamp(30 * TimeStamp::SEC)});
+ MemoryFlush flush({1000, 20 * gibi, 1.0, 1000, 1.0, seconds(30)});
EXPECT_TRUE(assertOrder(StringList().add("t1").add("t2"), flush.getFlushTargets(cb.list(), cb.tlsStats())));
}
}
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp
index 56b53a46693..ae4b1419165 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp
@@ -31,7 +31,7 @@ AttributeDirectory::AttributeDirectory(const std::shared_ptr<AttributeDiskLayout
const vespalib::string &name)
: _diskLayout(diskLayout),
_name(name),
- _lastFlushTime(0),
+ _lastFlushTime(vespalib::system_time()),
_writer(nullptr),
_mutex(),
_cv(),
@@ -75,14 +75,14 @@ AttributeDirectory::getFlushedSerialNum() const
return bestSnap.valid ? bestSnap.syncToken : 0;
}
-fastos::UTCTimeStamp
+vespalib::system_time
AttributeDirectory::getLastFlushTime() const
{
return _lastFlushTime;
}
void
-AttributeDirectory::setLastFlushTime(fastos::UTCTimeStamp lastFlushTime)
+AttributeDirectory::setLastFlushTime(vespalib::system_time lastFlushTime)
{
_lastFlushTime = lastFlushTime;
}
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h
index 24d922418b8..f759154eefe 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h
+++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h
@@ -3,6 +3,7 @@
#pragma once
#include <vespa/vespalib/stllike/string.h>
+#include <vespa/vespalib/util/time.h>
#include <vespa/searchlib/common/indexmetainfo.h>
#include <vespa/searchlib/common/serialnum.h>
#include <vespa/fastos/timestamp.h>
@@ -26,7 +27,7 @@ public:
private:
std::weak_ptr<AttributeDiskLayout> _diskLayout;
const vespalib::string _name;
- fastos::UTCTimeStamp _lastFlushTime;
+ vespalib::system_time _lastFlushTime;
Writer *_writer; // current writer
mutable std::mutex _mutex;
std::condition_variable _cv;
@@ -34,7 +35,7 @@ private:
void saveSnapInfo();
vespalib::string getSnapshotDir(SerialNum serialNum);
- void setLastFlushTime(fastos::UTCTimeStamp lastFlushTime);
+ void setLastFlushTime(vespalib::system_time lastFlushTime);
void createInvalidSnapshot(SerialNum serialNum);
void markValidSnapshot(SerialNum serialNum);
void invalidateOldSnapshots(SerialNum serialNum);
@@ -64,7 +65,7 @@ public:
~Writer();
// methods called when saving an attribute.
- void setLastFlushTime(fastos::UTCTimeStamp lastFlushTime) { _dir.setLastFlushTime(lastFlushTime); }
+ void setLastFlushTime(vespalib::system_time lastFlushTime) { _dir.setLastFlushTime(lastFlushTime); }
void createInvalidSnapshot(SerialNum serialNum) { _dir.createInvalidSnapshot(serialNum); }
void markValidSnapshot(SerialNum serialNum) { _dir.markValidSnapshot(serialNum); }
vespalib::string getSnapshotDir(SerialNum serialNum) { return _dir.getSnapshotDir(serialNum); }
@@ -80,7 +81,7 @@ public:
std::unique_ptr<Writer> getWriter();
std::unique_ptr<Writer> tryGetWriter();
SerialNum getFlushedSerialNum() const;
- fastos::UTCTimeStamp getLastFlushTime() const;
+ vespalib::system_time getLastFlushTime() const;
bool empty() const;
vespalib::string getAttributeFileName(SerialNum serialNum);
};
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp b/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp
index 0e0e96aa871..ee1c06ef7c1 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp
@@ -209,9 +209,9 @@ FlushableAttribute::internalInitFlush(SerialNum currentSerial)
return Task::UP();
}
if (syncToken <= getFlushedSerialNum()) {
- writer->setLastFlushTime(fastos::ClockSystem::now());
+ writer->setLastFlushTime(vespalib::system_clock::now());
LOG(debug,"No attribute vector to flush. Update flush time to current: lastFlushTime(%f)",
- getLastFlushTime().time_since_epoch().sec());
+ vespalib::to_s(getLastFlushTime().time_since_epoch()));
return Task::UP();
}
return std::make_unique<Flusher>(*this, syncToken, *writer);
diff --git a/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp b/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp
index ed5ce24143d..28d11f14489 100644
--- a/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp
@@ -6,6 +6,7 @@
#include <vespa/fastos/file.h>
#include <vespa/searchcore/config/config-hwinfo.h>
#include <vespa/vespalib/io/fileutil.h>
+#include <vespa/vespalib//util/time.h>
#include <filesystem>
#include <thread>
#include <vespa/log/log.h>
@@ -98,7 +99,7 @@ double measureDiskWriteSpeed(const vespalib::string &path,
Clock::time_point after = Clock::now();
testFile.Close();
vespalib::unlink(fileName);
- double elapsed = std::chrono::duration<double>(after - before).count();
+ double elapsed = vespalib::to_s(after - before);
double diskWriteSpeed = diskWriteLen / elapsed / 1024 / 1024;
return diskWriteSpeed;
}
diff --git a/searchcore/src/vespa/searchcore/proton/docsummary/summarycompacttarget.cpp b/searchcore/src/vespa/searchcore/proton/docsummary/summarycompacttarget.cpp
index 07f6c530a2e..79f32d60056 100644
--- a/searchcore/src/vespa/searchcore/proton/docsummary/summarycompacttarget.cpp
+++ b/searchcore/src/vespa/searchcore/proton/docsummary/summarycompacttarget.cpp
@@ -64,7 +64,7 @@ SummaryCompactTarget::getApproxDiskGain() const
IFlushTarget::Time
SummaryCompactTarget::getLastFlushTime() const
{
- return fastos::ClockSystem::now();
+ return vespalib::system_clock::now();
}
SerialNum
diff --git a/searchcore/src/vespa/searchcore/proton/docsummary/summarymanager.cpp b/searchcore/src/vespa/searchcore/proton/docsummary/summarymanager.cpp
index 74d107814fd..444a14db81c 100644
--- a/searchcore/src/vespa/searchcore/proton/docsummary/summarymanager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/docsummary/summarymanager.cpp
@@ -50,7 +50,7 @@ class ShrinkSummaryLidSpaceFlushTarget : public ShrinkLidSpaceFlushTarget
public:
ShrinkSummaryLidSpaceFlushTarget(const vespalib::string &name, Type type, Component component,
- SerialNum flushedSerialNum, fastos::UTCTimeStamp lastFlushTime,
+ SerialNum flushedSerialNum, vespalib::system_time lastFlushTime,
searchcorespi::index::IThreadService & summaryService,
std::shared_ptr<ICompactableLidSpace> target);
~ShrinkSummaryLidSpaceFlushTarget() override;
@@ -59,7 +59,7 @@ public:
ShrinkSummaryLidSpaceFlushTarget::
ShrinkSummaryLidSpaceFlushTarget(const vespalib::string &name, Type type, Component component,
- SerialNum flushedSerialNum, fastos::UTCTimeStamp lastFlushTime,
+ SerialNum flushedSerialNum, vespalib::system_time lastFlushTime,
searchcorespi::index::IThreadService & summaryService,
std::shared_ptr<ICompactableLidSpace> target)
: ShrinkLidSpaceFlushTarget(name, type, component, flushedSerialNum, lastFlushTime, std::move(target)),
@@ -194,7 +194,7 @@ createShrinkLidSpaceFlushTarget(searchcorespi::index::IThreadService & summarySe
IFlushTarget::Type::GC,
IFlushTarget::Component::DOCUMENT_STORE,
docStore->lastSyncToken(),
- fastos::UTCTimeStamp(docStore->getLastFlushTime()),
+ vespalib::system_time(docStore->getLastFlushTime()),
summaryService,
docStore);
}
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp
index 71274bf444e..ad3a56b3d56 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp
@@ -221,9 +221,9 @@ DocumentMetaStoreFlushTarget::initFlush(SerialNum currentSerial)
return Task::UP();
}
if (syncToken <= getFlushedSerialNum()) {
- writer->setLastFlushTime(fastos::ClockSystem::now());
+ writer->setLastFlushTime(vespalib::system_clock::now());
LOG(debug, "No document meta store to flush. Update flush time to current: lastFlushTime(%f)",
- getLastFlushTime().time_since_epoch().sec());
+ vespalib::to_s(getLastFlushTime().time_since_epoch()));
return Task::UP();
}
return std::make_unique<Flusher>(*this, syncToken, *writer);
diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flush_engine_explorer.cpp b/searchcore/src/vespa/searchcore/proton/flushengine/flush_engine_explorer.cpp
index ebb7ad5ecd2..5baccda279c 100644
--- a/searchcore/src/vespa/searchcore/proton/flushengine/flush_engine_explorer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/flushengine/flush_engine_explorer.cpp
@@ -20,7 +20,7 @@ convertToSlime(const FlushEngine::FlushMetaSet &flushingTargets, Cursor &array)
for (const auto &target : flushingTargets) {
Cursor &object = array.addObject();
object.setString("name", target.getName());
- object.setString("startTime", target.getStart().toString());
+ object.setString("startTime", fastos::TimeStamp::asString(target.getStart()));
fastos::TimeStamp elapsedTime = target.elapsed();
object.setDouble("elapsedTime", elapsedTime.sec());
}
@@ -38,7 +38,7 @@ sortTargetList(FlushContext::List &allTargets)
void
convertToSlime(const FlushContext::List &allTargets,
- const fastos::UTCTimeStamp &now,
+ const vespalib::system_time &now,
Cursor &array)
{
for (const auto &ctx : allTargets) {
@@ -48,9 +48,9 @@ convertToSlime(const FlushContext::List &allTargets,
object.setLong("flushedSerialNum", target->getFlushedSerialNum());
object.setLong("memoryGain", target->getApproxMemoryGain().gain());
object.setLong("diskGain", target->getApproxDiskGain().gain());
- object.setString("lastFlushTime", target->getLastFlushTime().toString());
- fastos::TimeStamp timeSinceLastFlush = now - target->getLastFlushTime();
- object.setDouble("timeSinceLastFlush", timeSinceLastFlush.sec());
+ object.setString("lastFlushTime", fastos::TimeStamp::asString(target->getLastFlushTime()));
+ vespalib::duration timeSinceLastFlush = now - target->getLastFlushTime();
+ object.setDouble("timeSinceLastFlush", vespalib::to_s(timeSinceLastFlush));
object.setBool("needUrgentFlush", target->needUrgentFlush());
}
}
@@ -67,7 +67,7 @@ FlushEngineExplorer::get_state(const Inserter &inserter, bool full) const
{
Cursor &object = inserter.insertObject();
if (full) {
- fastos::UTCTimeStamp now = fastos::ClockSystem::now();
+ vespalib::system_time now = vespalib::system_clock::now();
convertToSlime(_engine.getCurrentlyFlushingSet(), object.setArray("flushingTargets"));
FlushContext::List allTargets = _engine.getTargetList(true);
sortTargetList(allTargets);
diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h
index 97ba51a1b97..0a4fcabb746 100644
--- a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h
+++ b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h
@@ -6,6 +6,8 @@
#include <vespa/searchcore/proton/common/handlermap.hpp>
#include <vespa/searchcore/proton/common/doctypename.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
+#include <vespa/vespalib/util/time.h>
+#include <vespa/fastos/timestamp.h>
#include <vespa/fastos/thread.h>
#include <set>
#include <mutex>
@@ -23,7 +25,7 @@ public:
FlushMeta(const vespalib::string & name, uint32_t id);
~FlushMeta();
const vespalib::string & getName() const { return _name; }
- fastos::UTCTimeStamp getStart() const { return fastos::ClockSystem::now() - elapsed(); }
+ vespalib::system_time getStart() const { return vespalib::system_clock::now() - vespalib::duration(elapsed()); }
fastos::TimeStamp elapsed() const { return _stopWatch.elapsed(); }
uint32_t getId() const { return _id; }
bool operator < (const FlushMeta & rhs) const { return _id < rhs._id; }
diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.cpp b/searchcore/src/vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.cpp
index 03a905a18ca..e7e005e2d95 100644
--- a/searchcore/src/vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.cpp
+++ b/searchcore/src/vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.cpp
@@ -2,6 +2,7 @@
#include "shrink_lid_space_flush_target.h"
#include <vespa/searchlib/common/i_compactable_lid_space.h>
+#include <vespa/fastos/timestamp.h>
namespace proton {
@@ -31,7 +32,7 @@ void
ShrinkLidSpaceFlushTarget::Flusher::run()
{
_target._flushedSerialNum = _flushSerialNum;
- _target._lastFlushTime = fastos::ClockSystem::now();
+ _target._lastFlushTime = vespalib::system_clock::now();
}
search::SerialNum
@@ -90,11 +91,11 @@ IFlushTarget::Task::UP
ShrinkLidSpaceFlushTarget::initFlush(SerialNum currentSerial)
{
if (currentSerial < _flushedSerialNum) {
- _lastFlushTime = fastos::ClockSystem::now();
+ _lastFlushTime = vespalib::system_clock::now();
return IFlushTarget::Task::UP();
} else if (!_target->canShrinkLidSpace()) {
_flushedSerialNum = currentSerial;
- _lastFlushTime = fastos::ClockSystem::now();
+ _lastFlushTime = vespalib::system_clock::now();
return IFlushTarget::Task::UP();
} else {
return std::make_unique<Flusher>(*this, currentSerial);
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 152411f9b70..1976bf8252f 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/session_manager_explorer.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/session_manager_explorer.cpp
@@ -30,8 +30,8 @@ public:
for (const auto &session: sessions) {
Cursor &entry = array.addObject();
entry.setString("id", session.id);
- entry.setString("created", session.created.toUTC().toString());
- entry.setString("doom", session.doom.toUTC().toString());
+ entry.setString("created", fastos::TimeStamp::asString(session.created.toUTC()));
+ entry.setString("doom", fastos::TimeStamp::asString(session.doom.toUTC()));
}
}
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/maintenance_jobs_injector.cpp b/searchcore/src/vespa/searchcore/proton/server/maintenance_jobs_injector.cpp
index 6b130dfa144..b9a5bb65e45 100644
--- a/searchcore/src/vespa/searchcore/proton/server/maintenance_jobs_injector.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/maintenance_jobs_injector.cpp
@@ -10,7 +10,7 @@
#include "pruneremoveddocumentsjob.h"
#include "sample_attribute_usage_job.h"
-using fastos::ClockSystem;
+using vespalib::system_clock;
using fastos::TimeStamp;
namespace proton {
diff --git a/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.cpp b/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.cpp
index 3aeb79b51a1..c67a43e9edd 100644
--- a/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.cpp
@@ -147,9 +147,7 @@ MemoryFlushConfigUpdater::convertConfig(const ProtonConfig::Flush::Memory &confi
config.diskbloatfactor,
eachMaxMemory,
config.each.diskbloatfactor,
- static_cast<long>
- (config.maxage.time) *
- fastos::TimeStamp::NANO);
+ vespalib::from_s(config.maxage.time));
}
} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp b/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp
index 86e818e0fe3..9fa90e50fdf 100644
--- a/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp
@@ -4,6 +4,7 @@
#include <vespa/searchcore/proton/flushengine/tls_stats_map.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/stllike/hash_set.h>
+#include <vespa/vespalib/util/time.h>
#include <algorithm>
#include <vespa/log/log.h>
@@ -56,7 +57,7 @@ MemoryFlush::Config::Config()
globalDiskBloatFactor(0.2),
maxMemoryGain(1000*1024*1024ul),
diskBloatFactor(0.2),
- maxTimeGain(fastos::TimeStamp::MINUTE*60*24)
+ maxTimeGain(std::chrono::hours(24))
{ }
@@ -65,7 +66,7 @@ MemoryFlush::Config::Config(uint64_t maxGlobalMemory_in,
double globalDiskBloatFactor_in,
uint64_t maxMemoryGain_in,
double diskBloatFactor_in,
- fastos::TimeStamp maxTimeGain_in)
+ vespalib::duration maxTimeGain_in)
: maxGlobalMemory(maxGlobalMemory_in),
maxGlobalTlsSize(maxGlobalTlsSize_in),
globalDiskBloatFactor(globalDiskBloatFactor_in),
@@ -74,7 +75,7 @@ MemoryFlush::Config::Config(uint64_t maxGlobalMemory_in,
maxTimeGain(maxTimeGain_in)
{ }
-MemoryFlush::MemoryFlush(const Config &config, fastos::UTCTimeStamp startTime)
+MemoryFlush::MemoryFlush(const Config &config, vespalib::system_time startTime)
: _lock(),
_config(config),
_startTime(startTime)
@@ -82,7 +83,7 @@ MemoryFlush::MemoryFlush(const Config &config, fastos::UTCTimeStamp startTime)
MemoryFlush::MemoryFlush()
- : MemoryFlush(Config(), fastos::ClockSystem::now())
+ : MemoryFlush(Config(), vespalib::system_clock::now())
{ }
MemoryFlush::~MemoryFlush() = default;
@@ -133,14 +134,14 @@ MemoryFlush::getFlushTargets(const FlushContext::List &targetList,
uint64_t totalTlsSize(0);
const Config config(getConfig());
vespalib::hash_set<const void *> visitedHandlers;
- fastos::UTCTimeStamp now(fastos::ClockSystem::now());
+ vespalib::system_time now(vespalib::system_clock::now());
LOG(debug,
"getFlushTargets(): globalMaxMemory(%" PRIu64 "), maxGlobalTlsSize(%" PRIu64 "), globalDiskBloatFactor(%f), "
"maxMemoryGain(%" PRIu64 "), diskBloatFactor(%f), maxTimeGain(%f), startTime(%f)",
config.maxGlobalMemory, config.maxGlobalTlsSize, config.globalDiskBloatFactor,
config.maxMemoryGain, config.diskBloatFactor,
- config.maxTimeGain.sec(),
- _startTime.time_since_epoch().sec());
+ vespalib::to_s(config.maxTimeGain),
+ vespalib::to_s(_startTime.time_since_epoch()));
for (size_t i(0), m(targetList.size()); i < m; i++) {
const IFlushTarget & target(*targetList[i]->getTarget());
const IFlushHandler & handler(*targetList[i]->getHandler());
@@ -150,8 +151,8 @@ MemoryFlush::getFlushTargets(const FlushContext::List &targetList,
SerialNum localLastSerial = targetList[i]->getLastSerial();
int64_t serialDiff = getSerialDiff(localLastSerial, target);
vespalib::string name(getName(handler, target));
- fastos::UTCTimeStamp lastFlushTime = target.getLastFlushTime();
- fastos::TimeStamp timeDiff(now - (lastFlushTime > fastos::UTCTimeStamp::ZERO ? lastFlushTime : _startTime));
+ vespalib::system_time lastFlushTime = target.getLastFlushTime();
+ vespalib::duration timeDiff(now - (lastFlushTime > vespalib::system_time() ? lastFlushTime : _startTime));
totalMemory += mgain;
const flushengine::TlsStats &tlsStats = tlsStatsMap.getTlsStats(handler.getName());
if (visitedHandlers.insert(&handler).second) {
@@ -183,9 +184,9 @@ MemoryFlush::getFlushTargets(const FlushContext::List &targetList,
target.getFlushedSerialNum(),
localLastSerial,
serialDiff,
- lastFlushTime.time_since_epoch().sec(),
- now.time_since_epoch().sec(),
- timeDiff.sec(),
+ vespalib::to_s(lastFlushTime.time_since_epoch()),
+ vespalib::to_s(now.time_since_epoch()),
+ vespalib::to_s(timeDiff),
getOrderName(order).c_str());
}
if (!targetList.empty()) {
diff --git a/searchcore/src/vespa/searchcore/proton/server/memoryflush.h b/searchcore/src/vespa/searchcore/proton/server/memoryflush.h
index 532abe939cb..82cf3397ef0 100644
--- a/searchcore/src/vespa/searchcore/proton/server/memoryflush.h
+++ b/searchcore/src/vespa/searchcore/proton/server/memoryflush.h
@@ -2,6 +2,7 @@
#pragma once
#include <vespa/searchcore/proton/flushengine/iflushstrategy.h>
+#include <vespa/vespalib/util/time.h>
#include <mutex>
namespace proton {
@@ -25,14 +26,14 @@ public:
double diskBloatFactor;
/// Maximum age of unflushed data.
- fastos::TimeStamp maxTimeGain;
+ vespalib::duration maxTimeGain;
Config();
Config(uint64_t maxGlobalMemory_in,
uint64_t maxGlobalTlsSize_in,
double globalDiskBloatFactor_in,
uint64_t maxMemoryGain_in,
double diskBloatFactor_in,
- fastos::TimeStamp maxTimeGain_in);
+ vespalib::duration maxTimeGain_in);
};
enum OrderType { DEFAULT, MAXAGE, DISKBLOAT, TLSSIZE, MEMORY };
@@ -42,7 +43,7 @@ private:
mutable std::mutex _lock;
Config _config;
/// The time when the strategy was started.
- fastos::UTCTimeStamp _startTime;
+ vespalib::system_time _startTime;
class CompareTarget
{
@@ -62,8 +63,8 @@ public:
using SP = std::shared_ptr<MemoryFlush>;
MemoryFlush();
- explicit MemoryFlush(const Config &config) : MemoryFlush(config, fastos::ClockSystem::now()) { }
- MemoryFlush(const Config &config, fastos::UTCTimeStamp startTime);
+ explicit MemoryFlush(const Config &config) : MemoryFlush(config, vespalib::system_clock::now()) { }
+ MemoryFlush(const Config &config, vespalib::system_time startTime);
~MemoryFlush();
FlushContext::List
diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
index b85a1e00574..48cede5943d 100644
--- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp
@@ -270,7 +270,7 @@ Proton::init(const BootstrapConfig::SP & configSnapshot)
switch (flush.strategy) {
case ProtonConfig::Flush::Strategy::MEMORY: {
auto memoryFlush = std::make_shared<MemoryFlush>(
- MemoryFlushConfigUpdater::convertConfig(flush.memory, hwInfo.memory()), fastos::ClockSystem::now());
+ MemoryFlushConfigUpdater::convertConfig(flush.memory, hwInfo.memory()), vespalib::system_clock::now());
_memoryFlushConfigUpdater = std::make_unique<MemoryFlushConfigUpdater>(memoryFlush, flush.memory, hwInfo.memory());
_diskMemUsageSampler->notifier().addDiskMemUsageListener(_memoryFlushConfigUpdater.get());
strategy = memoryFlush;
diff --git a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp
index 8bf96b4d370..8be58311798 100644
--- a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp
@@ -5,6 +5,7 @@
#include "ifrozenbuckethandler.h"
#include <vespa/searchcore/proton/feedoperation/pruneremoveddocumentsoperation.h>
#include <vespa/searchcore/proton/documentmetastore/i_document_meta_store.h>
+#include <vespa/vespalib/util/time.h>
#include <vespa/log/log.h>
LOG_SETUP(".proton.server.pruneremoveddocumentsjob");
@@ -65,9 +66,9 @@ bool
PruneRemovedDocumentsJob::run()
{
uint64_t tshz = 1000000;
- fastos::UTCTimeStamp now = fastos::ClockSystem::now();
+ vespalib::system_time now = vespalib::system_clock::now();
const Timestamp ageLimit(static_cast<Timestamp::Type>
- ((now.time_since_epoch().sec() - _cfgAgeLimit) * tshz));
+ ((vespalib::to_s(now.time_since_epoch()) - _cfgAgeLimit) * tshz));
DocId lid(_nextLid);
const DocId olid(lid);
const DocId docIdLimit(_metaStore.getCommittedDocIdLimit());
diff --git a/searchcore/src/vespa/searchcore/proton/test/dummy_document_store.h b/searchcore/src/vespa/searchcore/proton/test/dummy_document_store.h
index 2eee9b5dd8e..152320f684e 100644
--- a/searchcore/src/vespa/searchcore/proton/test/dummy_document_store.h
+++ b/searchcore/src/vespa/searchcore/proton/test/dummy_document_store.h
@@ -28,7 +28,7 @@ struct DummyDocumentStore : public search::IDocumentStore
void compact(uint64_t) override {}
uint64_t lastSyncToken() const override { return 0; }
uint64_t tentativeLastSyncToken() const override { return 0; }
- fastos::UTCTimeStamp getLastFlushTime() const override { return fastos::UTCTimeStamp::ZERO; }
+ vespalib::system_time getLastFlushTime() const override { return vespalib::system_time(); }
uint32_t getDocIdLimit() const override { return 0; }
size_t memoryUsed() const override { return 0; }
size_t memoryMeta() const override { return 0; }
diff --git a/searchcorespi/src/vespa/searchcorespi/flush/iflushtarget.h b/searchcorespi/src/vespa/searchcorespi/flush/iflushtarget.h
index 6d3313b4cf2..31707643649 100644
--- a/searchcorespi/src/vespa/searchcorespi/flush/iflushtarget.h
+++ b/searchcorespi/src/vespa/searchcorespi/flush/iflushtarget.h
@@ -3,7 +3,7 @@
#include "flushstats.h"
#include "flushtask.h"
-#include <vespa/fastos/timestamp.h>
+#include <vespa/vespalib/util/time.h>
#include <vector>
namespace searchcorespi {
@@ -60,7 +60,7 @@ public:
using MemoryGain = Gain<int64_t>;
using DiskGain = Gain<int64_t>;
using SerialNum = search::SerialNum;
- using Time = fastos::UTCTimeStamp;
+ using Time = vespalib::system_time;
/**
* Convenience typedefs.
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexfusiontarget.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexfusiontarget.cpp
index a9b4531fe93..b538e817cf8 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexfusiontarget.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexfusiontarget.cpp
@@ -74,7 +74,7 @@ IndexFusionTarget::needUrgentFlush() const
IFlushTarget::Time
IndexFusionTarget::getLastFlushTime() const
{
- return fastos::ClockSystem::now();
+ return vespalib::system_clock::now();
}
IFlushTarget::SerialNum
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
index e2ab5f5ff1f..0ca6d299288 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
@@ -19,6 +19,7 @@
#include <vespa/vespalib/util/closuretask.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/lambdatask.h>
+#include <vespa/vespalib/util/time.h>
#include <sstream>
#include <vespa/log/log.h>
@@ -617,7 +618,7 @@ IndexMaintainer::doneFlush(FlushArgs *args, IDiskIndex::SP *disk_index) {
return false; // Must retry operation
}
_flush_serial_num = std::max(_flush_serial_num, args->flush_serial_num);
- fastos::UTCTimeStamp timeStamp = search::FileKit::getModificationTime((*disk_index)->getIndexDir());
+ vespalib::system_time timeStamp = search::FileKit::getModificationTime((*disk_index)->getIndexDir());
_lastFlushTime = timeStamp > _lastFlushTime ? timeStamp : _lastFlushTime;
const uint32_t old_id = args->old_absolute_id - _last_fusion_id;
replaceSource(old_id, *disk_index);
@@ -941,10 +942,10 @@ IndexMaintainer::initFlush(SerialNum serialNum, searchcorespi::FlushStats * stat
// No memory index to flush, it was empty
LockGuard lock(_state_lock);
_flush_serial_num = _current_serial_num;
- _lastFlushTime = fastos::ClockSystem::now();
+ _lastFlushTime = vespalib::system_clock::now();
LOG(debug, "No memory index to flush. Update serial number and flush time to current: "
"flushSerialNum(%" PRIu64 "), lastFlushTime(%f)",
- _flush_serial_num, _lastFlushTime.time_since_epoch().sec());
+ _flush_serial_num, vespalib::to_s(_lastFlushTime.time_since_epoch()));
return FlushTask::UP();
}
SerialNum realSerialNum = args.flush_serial_num;
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h
index a1bf676e48f..671f87ff35b 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h
@@ -94,7 +94,7 @@ class IndexMaintainer : public IIndexManager,
bool _flush_empty_current_index;
SerialNum _current_serial_num;// Protected by IUL
SerialNum _flush_serial_num; // Protected by SL
- fastos::UTCTimeStamp _lastFlushTime; // Protected by SL
+ vespalib::system_time _lastFlushTime; // Protected by SL
// Extra frozen memory indexes. This list is empty unless new
// memory index has been added by force (due to config change or
// data structure limitations).
@@ -335,7 +335,7 @@ public:
uint32_t getNumFrozenMemoryIndexes() const;
uint32_t getMaxFrozenMemoryIndexes() const { return _maxFrozen; }
- fastos::UTCTimeStamp getLastFlushTime() const { return _lastFlushTime; }
+ vespalib::system_time getLastFlushTime() const { return _lastFlushTime; }
// Implements IIndexManager
void putDocument(uint32_t lid, const Document &doc, SerialNum serialNum) override;
diff --git a/searchlib/src/tests/docstore/document_store/document_store_test.cpp b/searchlib/src/tests/docstore/document_store/document_store_test.cpp
index 6ea5176f4f3..86c6d3ad883 100644
--- a/searchlib/src/tests/docstore/document_store/document_store_test.cpp
+++ b/searchlib/src/tests/docstore/document_store/document_store_test.cpp
@@ -27,7 +27,7 @@ struct NullDataStore : IDataStore {
size_t getDiskBloat() const override { return 0; }
uint64_t lastSyncToken() const override { return 0; }
uint64_t tentativeLastSyncToken() const override { return 0; }
- fastos::UTCTimeStamp getLastFlushTime() const override { return fastos::UTCTimeStamp::ZERO; }
+ vespalib::system_time getLastFlushTime() const override { return vespalib::system_time(); }
void accept(IDataStoreVisitor &, IDataStoreVisitorProgress &, bool) override { }
double getVisitCost() const override { return 1.0; }
DataStoreStorageStats getStorageStats() const override {
diff --git a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp
index 9ec5cc8857b..f92f5fd9581 100644
--- a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp
+++ b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp
@@ -757,18 +757,18 @@ TEST("requireThatSyncTokenIsUpdatedAfterFlush") {
TEST("requireThatFlushTimeIsAvailableAfterFlush") {
TmpDirectory testDir("flushtime");
- fastos::UTCTimeStamp before(fastos::ClockSystem::now());
+ vespalib::system_time before(vespalib::system_clock::now());
DummyFileHeaderContext fileHeaderContext;
LogDataStore::Config config;
vespalib::ThreadStackExecutor executor(1, 128*1024);
MyTlSyncer tlSyncer;
LogDataStore store(executor, testDir.getDir(), config, GrowStrategy(),
TuneFileSummary(), fileHeaderContext, tlSyncer, nullptr);
- EXPECT_EQUAL(0, store.getLastFlushTime().time_since_epoch().time());
+ EXPECT_EQUAL(0s, std::chrono::duration_cast<std::chrono::seconds>(store.getLastFlushTime().time_since_epoch()));
uint64_t flushToken = store.initFlush(5);
EXPECT_EQUAL(5u, flushToken);
store.flush(flushToken);
- fastos::UTCTimeStamp after(fastos::ClockSystem::now());
+ vespalib::system_time after(vespalib::system_clock::now());
// the file name of the dat file is 'magic', using the clock instead of stating the file
EXPECT_LESS_EQUAL(before, store.getLastFlushTime());
EXPECT_GREATER_EQUAL(after, store.getLastFlushTime());
diff --git a/searchlib/src/vespa/searchlib/docstore/documentstore.cpp b/searchlib/src/vespa/searchlib/docstore/documentstore.cpp
index a180a303780..4c4405fabb0 100644
--- a/searchlib/src/vespa/searchlib/docstore/documentstore.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/documentstore.cpp
@@ -274,7 +274,7 @@ DocumentStore::tentativeLastSyncToken() const
return _backingStore.tentativeLastSyncToken();
}
-fastos::UTCTimeStamp
+vespalib::system_time
DocumentStore::getLastFlushTime() const
{
return _backingStore.getLastFlushTime();
diff --git a/searchlib/src/vespa/searchlib/docstore/documentstore.h b/searchlib/src/vespa/searchlib/docstore/documentstore.h
index 8bdba21f8d5..b8895f951bb 100644
--- a/searchlib/src/vespa/searchlib/docstore/documentstore.h
+++ b/searchlib/src/vespa/searchlib/docstore/documentstore.h
@@ -75,7 +75,7 @@ public:
void compact(uint64_t syncToken) override;
uint64_t lastSyncToken() const override;
uint64_t tentativeLastSyncToken() const override;
- fastos::UTCTimeStamp getLastFlushTime() const override;
+ vespalib::system_time getLastFlushTime() const override;
uint32_t getDocIdLimit() const override { return _backingStore.getDocIdLimit(); }
size_t memoryUsed() const override { return _backingStore.memoryUsed(); }
size_t getDiskFootprint() const override { return _backingStore.getDiskFootprint(); }
diff --git a/searchlib/src/vespa/searchlib/docstore/filechunk.cpp b/searchlib/src/vespa/searchlib/docstore/filechunk.cpp
index 94214ad7d84..d21278e2f84 100644
--- a/searchlib/src/vespa/searchlib/docstore/filechunk.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/filechunk.cpp
@@ -293,7 +293,7 @@ FileChunk::getLastPersistedSerialNum() const
return _lastPersistedSerialNum;
}
-fastos::UTCTimeStamp
+vespalib::system_time
FileChunk::getModificationTime() const
{
return _modificationTime;
diff --git a/searchlib/src/vespa/searchlib/docstore/filechunk.h b/searchlib/src/vespa/searchlib/docstore/filechunk.h
index 2e47f010fc3..5e3723c9522 100644
--- a/searchlib/src/vespa/searchlib/docstore/filechunk.h
+++ b/searchlib/src/vespa/searchlib/docstore/filechunk.h
@@ -12,6 +12,7 @@
#include <vespa/vespalib/util/sync.h>
#include <vespa/vespalib/stllike/hash_map.h>
#include <vespa/vespalib/util/generationhandler.h>
+#include <vespa/vespalib/util/time.h>
#include <vespa/fastos/timestamp.h>
class FastOS_FileInterface;
@@ -159,7 +160,7 @@ public:
size_t getErasedBytes() const { return _erasedBytes; }
uint64_t getLastPersistedSerialNum() const;
uint32_t getDocIdLimit() const { return _docIdLimit; }
- virtual fastos::UTCTimeStamp getModificationTime() const;
+ virtual vespalib::system_time getModificationTime() const;
virtual bool frozen() const { return true; }
const vespalib::string & getName() const { return _name; }
void compact(const IGetLid & iGetLid);
@@ -249,7 +250,7 @@ protected:
uint32_t _idxHeaderLen;
uint64_t _lastPersistedSerialNum;
uint32_t _docIdLimit; // Limit when the file was created. Stored in idx file header.
- fastos::UTCTimeStamp _modificationTime;
+ vespalib::system_time _modificationTime;
};
} // namespace search
diff --git a/searchlib/src/vespa/searchlib/docstore/idatastore.h b/searchlib/src/vespa/searchlib/docstore/idatastore.h
index f0545ce1d9b..2ca693dde95 100644
--- a/searchlib/src/vespa/searchlib/docstore/idatastore.h
+++ b/searchlib/src/vespa/searchlib/docstore/idatastore.h
@@ -7,6 +7,7 @@
#include <vespa/searchlib/common/i_compactable_lid_space.h>
#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/util/memoryusage.h>
+#include <vespa/vespalib/util/time.h>
#include <vector>
namespace vespalib { class DataBuffer; }
@@ -145,7 +146,7 @@ public:
* or 0 if no flush has been performed yet.
* @return Time of last flush.
**/
- virtual fastos::UTCTimeStamp getLastFlushTime() const = 0;
+ virtual vespalib::system_time getLastFlushTime() const = 0;
/**
* Visit all data found in data store.
diff --git a/searchlib/src/vespa/searchlib/docstore/idocumentstore.h b/searchlib/src/vespa/searchlib/docstore/idocumentstore.h
index fc91d95b5a6..cb739888e54 100644
--- a/searchlib/src/vespa/searchlib/docstore/idocumentstore.h
+++ b/searchlib/src/vespa/searchlib/docstore/idocumentstore.h
@@ -130,7 +130,7 @@ public:
* or 0 if no flush has been performed yet.
* @return Time of last flush.
**/
- virtual fastos::UTCTimeStamp getLastFlushTime() const = 0;
+ virtual vespalib::system_time getLastFlushTime() const = 0;
/**
* Get the number of entries (including removed IDs
diff --git a/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp b/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp
index 95c02e57dd1..8fd5dc8ec24 100644
--- a/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/logdatastore.cpp
@@ -247,15 +247,15 @@ LogDataStore::tentativeLastSyncToken() const
return getActive(guard).getSerialNum();
}
-fastos::UTCTimeStamp
+vespalib::system_time
LogDataStore::getLastFlushTime() const
{
if (lastSyncToken() == 0) {
- return fastos::UTCTimeStamp::ZERO;
+ return vespalib::system_time();
}
LockGuard guard(_updateLock);
- fastos::UTCTimeStamp timeStamp(getActive(guard).getModificationTime());
- if (timeStamp == fastos::UTCTimeStamp::ZERO) {
+ vespalib::system_time timeStamp(getActive(guard).getModificationTime());
+ if (timeStamp == vespalib::system_time()) {
const FileChunk * prev = getPrevActive(guard);
if (prev != nullptr) {
timeStamp = prev->getModificationTime();
@@ -656,7 +656,7 @@ LogDataStore::createWritableFile(FileId fileId, SerialNum serialNum, NameId name
FileChunk::UP
LogDataStore::createWritableFile(FileId fileId, SerialNum serialNum)
{
- return createWritableFile(fileId, serialNum, NameId(fastos::ClockSystem::now().time_since_epoch()));
+ return createWritableFile(fileId, serialNum, NameId(vespalib::system_clock::now().time_since_epoch().count()));
}
namespace {
diff --git a/searchlib/src/vespa/searchlib/docstore/logdatastore.h b/searchlib/src/vespa/searchlib/docstore/logdatastore.h
index 9ea1403fbe6..6217576172c 100644
--- a/searchlib/src/vespa/searchlib/docstore/logdatastore.h
+++ b/searchlib/src/vespa/searchlib/docstore/logdatastore.h
@@ -102,7 +102,7 @@ public:
size_t memoryMeta() const override;
uint64_t lastSyncToken() const override;
uint64_t tentativeLastSyncToken() const override;
- fastos::UTCTimeStamp getLastFlushTime() const override;
+ vespalib::system_time getLastFlushTime() const override;
size_t getDiskFootprint() const override;
size_t getDiskHeaderFootprint() const override;
size_t getDiskBloat() const override;
diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
index d0fada0f498..e802ec0a326 100644
--- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.cpp
@@ -524,7 +524,7 @@ WriteableFileChunk::fileWriter(const uint32_t firstChunkId)
}
}
-fastos::UTCTimeStamp
+vespalib::system_time
WriteableFileChunk::getModificationTime() const
{
LockGuard guard(_lock);
@@ -832,7 +832,7 @@ WriteableFileChunk::flushPendingChunks(uint64_t serialNum) {
if (frozen())
return;
uint64_t datFileLen = _dataFile.getSize();
- fastos::UTCTimeStamp timeStamp(fastos::ClockSystem::now());
+ vespalib::system_time timeStamp(vespalib::system_clock::now());
if (needFlushPendingChunks(serialNum, datFileLen)) {
timeStamp = unconditionallyFlushPendingChunks(flushGuard, serialNum, datFileLen);
}
@@ -840,7 +840,7 @@ WriteableFileChunk::flushPendingChunks(uint64_t serialNum) {
_modificationTime = std::max(timeStamp, _modificationTime);
}
-fastos::UTCTimeStamp
+vespalib::system_time
WriteableFileChunk::unconditionallyFlushPendingChunks(const vespalib::LockGuard &flushGuard, uint64_t serialNum, uint64_t datFileLen)
{
(void) flushGuard;
@@ -870,7 +870,7 @@ WriteableFileChunk::unconditionallyFlushPendingChunks(const vespalib::LockGuard
os.write(os2.c_str(), os2.size());
}
}
- fastos::UTCTimeStamp timeStamp(fastos::ClockSystem::now());
+ vespalib::system_time timeStamp(vespalib::system_clock::now());
auto idxFile = openIdx();
idxFile->SetPosition(idxFile->GetSize());
ssize_t wlen = idxFile->Write2(os.c_str(), os.size());
diff --git a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h
index 927ce524850..6d870cae019 100644
--- a/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h
+++ b/searchlib/src/vespa/searchlib/docstore/writeablefilechunk.h
@@ -57,7 +57,7 @@ public:
uint64_t getSerialNum() const { return _serialNum; }
void setSerialNum(uint64_t serialNum) { _serialNum = std::max(_serialNum, serialNum); }
- fastos::UTCTimeStamp getModificationTime() const override;
+ vespalib::system_time getModificationTime() const override;
void freeze();
size_t getDiskFootprint() const override;
size_t getMemoryFootprint() const override;
@@ -90,7 +90,7 @@ private:
void writeDataHeader(const common::FileHeaderContext &fileHeaderContext);
bool needFlushPendingChunks(uint64_t serialNum, uint64_t datFileLen);
bool needFlushPendingChunks(const vespalib::MonitorGuard & guard, uint64_t serialNum, uint64_t datFileLen);
- fastos::UTCTimeStamp unconditionallyFlushPendingChunks(const vespalib::LockGuard & flushGuard, uint64_t serialNum, uint64_t datFileLen);
+ vespalib::system_time unconditionallyFlushPendingChunks(const vespalib::LockGuard & flushGuard, uint64_t serialNum, uint64_t datFileLen);
static void insertChunks(ProcessedChunkMap & orderedChunks, ProcessedChunkQ & newChunks, const uint32_t nextChunkId);
static ProcessedChunkQ fetchNextChain(ProcessedChunkMap & orderedChunks, const uint32_t firstChunkId);
ChunkMeta computeChunkMeta(const vespalib::LockGuard & guard,
diff --git a/searchlib/src/vespa/searchlib/util/filekit.cpp b/searchlib/src/vespa/searchlib/util/filekit.cpp
index 9230b66867c..4a48609ac9c 100644
--- a/searchlib/src/vespa/searchlib/util/filekit.cpp
+++ b/searchlib/src/vespa/searchlib/util/filekit.cpp
@@ -1,6 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/searchlib/util/filekit.h>
+#include "filekit.h"
#include <vespa/vespalib/util/error.h>
#include <vespa/fastos/file.h>
@@ -90,14 +90,14 @@ FileKit::removeStamp(const vespalib::string &name)
}
-fastos::UTCTimeStamp
+vespalib::system_time
FileKit::getModificationTime(const vespalib::string &name)
{
FastOS_StatInfo statInfo;
if (FastOS_File::Stat(name.c_str(), &statInfo)) {
- return fastos::UTCTimeStamp(statInfo._modifiedTimeNS);
+ return vespalib::system_time(vespalib::duration(statInfo._modifiedTimeNS));
}
- return fastos::UTCTimeStamp();
+ return vespalib::system_time();
}
diff --git a/searchlib/src/vespa/searchlib/util/filekit.h b/searchlib/src/vespa/searchlib/util/filekit.h
index fc9d8cc84be..c33930ce1d4 100644
--- a/searchlib/src/vespa/searchlib/util/filekit.h
+++ b/searchlib/src/vespa/searchlib/util/filekit.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 search {
@@ -20,7 +20,7 @@ public:
* Returns the modification time of the given file/directory,
* or time stamp 0 if stating of file/directory fails.
**/
- static fastos::UTCTimeStamp getModificationTime(const vespalib::string &name);
+ static vespalib::system_time getModificationTime(const vespalib::string &name);
};
}
diff --git a/staging_vespalib/src/tests/benchmark/testbase.cpp b/staging_vespalib/src/tests/benchmark/testbase.cpp
index bad2bdf0546..e3f1434c7d6 100644
--- a/staging_vespalib/src/tests/benchmark/testbase.cpp
+++ b/staging_vespalib/src/tests/benchmark/testbase.cpp
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "testbase.h"
#include <vespa/fastos/timestamp.h>
+#include <vespa/vespalib/util/time.h>
#include <cassert>
#include <vespa/log/log.h>
@@ -165,12 +166,12 @@ size_t ReturnByValueMultiVectorString::onRun()
size_t ClockSystem::onRun()
{
- fastos::UTCTimeStamp start(fastos::ClockSystem::now());
- fastos::UTCTimeStamp end(start);
+ vespalib::system_time start(vespalib::system_clock::now());
+ vespalib::system_time end(start);
for (size_t i=0; i < 1000; i++) {
- end = fastos::ClockSystem::now();
+ end = vespalib::system_clock::now();
}
- return (start - end).ns();
+ return (start - end).count();
}
size_t ClockREALTIME::onRun()