aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore
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 /searchcore
parente4b328f4ee05b55131420df7f6b5a3685d5dffa5 (diff)
Replace UTCTimeStamp with std::chrono::system_clock::time_point
Diffstat (limited to 'searchcore')
-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
24 files changed, 124 insertions, 111 deletions
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; }