diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-11-18 14:30:35 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-11-18 14:30:35 +0000 |
commit | a65c5f165553d4b954151e671b770706a749b727 (patch) | |
tree | 6429f124ff8b109289fdb911d74cc2128a4c8393 /searchcore | |
parent | 24be87327ebbff702d113084b0ef87fd194c0ef4 (diff) |
Specify UTC explicit
Diffstat (limited to 'searchcore')
30 files changed, 180 insertions, 268 deletions
diff --git a/searchcore/src/tests/grouping/grouping.cpp b/searchcore/src/tests/grouping/grouping.cpp index 79dba576bbd..edaa8792d6c 100644 --- a/searchcore/src/tests/grouping/grouping.cpp +++ b/searchcore/src/tests/grouping/grouping.cpp @@ -24,13 +24,6 @@ using search::attribute::test::MockAttributeContext; using proton::matching::SessionManager; using fastos::SteadyTimeStamp; -namespace fastos { - std::ostream & - operator<<(std::ostream &os, SteadyTimeStamp ts) { - return os << ts.toString(); - } -} - //----------------------------------------------------------------------------- const uint32_t NUM_DOCS = 1000; diff --git a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp index 31bf982ad70..c41ac3a3a1c 100644 --- a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp +++ b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp @@ -506,31 +506,31 @@ Test::requireThatLastFlushTimeIsReported() AttributeManagerFixture amf(f); AttributeManager &am = amf._m; AttributeVector::SP av = amf.addAttribute("a9"); - EXPECT_EQUAL(0, am.getFlushable("a9")->getLastFlushTime().time()); + EXPECT_EQUAL(fastos::UTCTimeStamp::ZERO, 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(0, ft->getLastFlushTime().time()); + EXPECT_EQUAL(fastos::UTCTimeStamp::ZERO, ft->getLastFlushTime()); ft->initFlush(200)->run(); EXPECT_TRUE(FastOS_File::Stat("flush/a9/snapshot-200", &stat)); - EXPECT_EQUAL(stat._modifiedTime, ft->getLastFlushTime().time()); + EXPECT_EQUAL(stat._modifiedTime, ft->getLastFlushTime().timeSinceEpoch().time()); } { // 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()); + EXPECT_EQUAL(stat._modifiedTime, ft->getLastFlushTime().timeSinceEpoch().time()); { // updated flush time after nothing to flush std::this_thread::sleep_for(8000ms); - fastos::TimeStamp now = fastos::ClockSystem::now(); + fastos::TimeStamp now = fastos::ClockSystem::now().timeSinceEpoch(); Executor::Task::UP task = ft->initFlush(200); EXPECT_TRUE(task.get() == NULL); - EXPECT_LESS(stat._modifiedTime, ft->getLastFlushTime().time()); - EXPECT_APPROX(now.time(), ft->getLastFlushTime().time(), 8); + EXPECT_LESS(stat._modifiedTime, ft->getLastFlushTime().timeSinceEpoch().time()); + EXPECT_APPROX(now.time(), ft->getLastFlushTime().timeSinceEpoch().time(), 8); } } } diff --git a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp index 96092625979..bfd4450b1f2 100644 --- a/searchcore/src/tests/proton/flushengine/flushengine_test.cpp +++ b/searchcore/src/tests/proton/flushengine/flushengine_test.cpp @@ -55,14 +55,14 @@ public: class SimpleGetSerialNum : public IGetSerialNum { - virtual search::SerialNum getSerialNum() const override { + search::SerialNum getSerialNum() const override { return 0u; } }; class SimpleTlsStatsFactory : public flushengine::ITlsStatsFactory { - virtual flushengine::TlsStatsMap create() override { + flushengine::TlsStatsMap create() override { vespalib::hash_map<vespalib::string, flushengine::TlsStats> map; return flushengine::TlsStatsMap(std::move(map)); } @@ -76,7 +76,7 @@ class WrappedFlushTask : public searchcorespi::FlushTask SimpleHandler &_handler; public: - virtual void run() override; + void run() override; WrappedFlushTask(searchcorespi::FlushTask::UP task, SimpleHandler &handler) : _task(std::move(task)), @@ -84,8 +84,7 @@ public: { } - virtual search::SerialNum getFlushSerial() const override - { + search::SerialNum getFlushSerial() const override { return _task->getFlushSerial(); } }; @@ -101,7 +100,7 @@ public: { } - virtual Task::UP initFlush(SerialNum currentSerial) override + Task::UP initFlush(SerialNum currentSerial) override { Task::UP task(_target->initFlush(currentSerial)); if (task) { @@ -228,11 +227,7 @@ public: _done.countDown(); } - virtual search::SerialNum - getFlushSerial() const override - { - return 0u; - } + search::SerialNum getFlushSerial() const override { return 0u; } }; class SimpleTarget : public test::DummyFlushTarget { @@ -284,22 +279,15 @@ public: : SimpleTarget(name, Type::OTHER, flushedSerial, proceedImmediately) { } - virtual Time - getLastFlushTime() const override { return fastos::ClockSystem::now(); } + Time getLastFlushTime() const override { return fastos::ClockSystem::now(); } - virtual SerialNum - getFlushedSerialNum() const override - { - LOG(info, "SimpleTarget(%s)::getFlushedSerialNum() = %" PRIu64, - getName().c_str(), _flushedSerial); + SerialNum getFlushedSerialNum() const override { + LOG(info, "SimpleTarget(%s)::getFlushedSerialNum() = %" PRIu64, getName().c_str(), _flushedSerial); return _flushedSerial; } - virtual Task::UP - initFlush(SerialNum currentSerial) override - { - LOG(info, "SimpleTarget(%s)::initFlush(%" PRIu64 ")", - getName().c_str(), currentSerial); + Task::UP initFlush(SerialNum currentSerial) override { + LOG(info, "SimpleTarget(%s)::initFlush(%" PRIu64 ")", getName().c_str(), currentSerial); _currentSerial = currentSerial; _initDone.countDown(); return std::move(_task); @@ -329,17 +317,13 @@ public: { } - virtual MemoryGain - getApproxMemoryGain() const override - { + MemoryGain getApproxMemoryGain() const override { LOG_ASSERT(_mgain == false); _mgain = true; return SimpleTarget::getApproxMemoryGain(); } - virtual search::SerialNum - getFlushedSerialNum() const override - { + search::SerialNum getFlushedSerialNum() const override { LOG_ASSERT(_serial == false); _serial = true; return SimpleTarget::getFlushedSerialNum(); @@ -358,8 +342,8 @@ public: const SimpleStrategy &_flush; }; - virtual FlushContext::List getFlushTargets(const FlushContext::List &targetList, - const flushengine::TlsStatsMap &) const override { + FlushContext::List getFlushTargets(const FlushContext::List &targetList, + const flushengine::TlsStatsMap &) const override { FlushContext::List fv(targetList); std::sort(fv.begin(), fv.end(), CompareTarget(*this)); return fv; @@ -403,8 +387,8 @@ public: class NoFlushStrategy : public SimpleStrategy { - virtual FlushContext::List getFlushTargets(const FlushContext::List &, - const flushengine::TlsStatsMap &) const override { + FlushContext::List getFlushTargets(const FlushContext::List &, + const flushengine::TlsStatsMap &) const override { return FlushContext::List(); } }; @@ -427,11 +411,7 @@ public: _list.push_back(_name); _done.countDown(); } - virtual search::SerialNum - getFlushSerial() const override - { - return 0u; - } + search::SerialNum getFlushSerial() const override { return 0u; } std::vector<vespalib::string> & _list; vespalib::Gate & _done; vespalib::string _name; 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 4f0f3c48278..376f37a512e 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, - IFlushTarget::Time(), + fastos::UTCTimeStamp::ZERO, _lidSpace)) { } diff --git a/searchcore/src/tests/proton/index/indexmanager_test.cpp b/searchcore/src/tests/proton/index/indexmanager_test.cpp index 80b1f9f0560..2f5d3e353db 100644 --- a/searchcore/src/tests/proton/index/indexmanager_test.cpp +++ b/searchcore/src/tests/proton/index/indexmanager_test.cpp @@ -277,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(0, target.getLastFlushTime().time()); + EXPECT_EQ(fastos::UTCTimeStamp::ZERO, 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()); + EXPECT_EQ(stat._modifiedTime, target.getLastFlushTime().timeSinceEpoch().time()); sources = get_source_collection(); EXPECT_EQ(2u, sources->getSourceCount()); @@ -300,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()); + EXPECT_EQ(stat._modifiedTime, target.getLastFlushTime().timeSinceEpoch().time()); // updated serial number & flush time when nothing to flush FastOS_Thread::Sleep(8000); - fastos::TimeStamp now = fastos::ClockSystem::now(); + fastos::TimeStamp now = fastos::ClockSystem::now().timeSinceEpoch(); vespalib::Executor::Task::UP task; runAsMaster([&]() { task = target.initFlush(2); }); EXPECT_TRUE(task.get() == nullptr); EXPECT_EQ(2u, target.getFlushedSerialNum()); - EXPECT_LT(stat._modifiedTime, target.getLastFlushTime().time()); - EXPECT_NEAR(now.time(), target.getLastFlushTime().time(), 8); + EXPECT_LT(stat._modifiedTime, target.getLastFlushTime().timeSinceEpoch().time()); + EXPECT_NEAR(now.time(), target.getLastFlushTime().timeSinceEpoch().time(), 8); } } diff --git a/searchcore/src/tests/proton/matching/matching_test.cpp b/searchcore/src/tests/proton/matching/matching_test.cpp index 883aa8f5aa5..83d520ea69b 100644 --- a/searchcore/src/tests/proton/matching/matching_test.cpp +++ b/searchcore/src/tests/proton/matching/matching_test.cpp @@ -60,13 +60,6 @@ using vespalib::nbostream; using vespalib::eval::TensorSpec; using vespalib::tensor::DefaultTensorEngine; -namespace fastos { - std::ostream & - operator<<(std::ostream &os, SteadyTimeStamp ts) { - return os << ts.toString(); - } -} - void inject_match_phase_limiting(Properties &setup, const vespalib::string &attribute, size_t max_hits, bool descending) { Properties cfg; diff --git a/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp b/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp index 3222d9b1190..a1693832506 100644 --- a/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp +++ b/searchcore/src/tests/proton/server/memoryflush/memoryflush_test.cpp @@ -7,12 +7,13 @@ #include <vespa/searchcore/proton/server/memoryflush.h> using fastos::TimeStamp; +using fastos::UTCTimeStamp; +using fastos::SteadyTimeStamp; using search::SerialNum; using namespace proton; using namespace searchcorespi; -namespace -{ +namespace{ static constexpr uint64_t gibi = UINT64_C(1024) * UINT64_C(1024) * UINT64_C(1024); @@ -40,15 +41,15 @@ public: class MyFlushTarget : public test::DummyFlushTarget { private: - MemoryGain _memoryGain; - DiskGain _diskGain; - SerialNum _flushedSerial; - TimeStamp _lastFlushTime; - bool _urgentFlush; + MemoryGain _memoryGain; + DiskGain _diskGain; + SerialNum _flushedSerial; + UTCTimeStamp _lastFlushTime; + bool _urgentFlush; public: MyFlushTarget(const vespalib::string &name, MemoryGain memoryGain, DiskGain diskGain, SerialNum flushedSerial, - TimeStamp lastFlushTime, bool urgentFlush) : + UTCTimeStamp lastFlushTime, bool urgentFlush) : test::DummyFlushTarget(name), _memoryGain(memoryGain), _diskGain(diskGain), @@ -61,7 +62,7 @@ public: virtual MemoryGain getApproxMemoryGain() const override { return _memoryGain; } virtual DiskGain getApproxDiskGain() const override { return _diskGain; } virtual SerialNum getFlushedSerialNum() const override { return _flushedSerial; } - virtual TimeStamp getLastFlushTime() const override { return _lastFlushTime; } + virtual UTCTimeStamp getLastFlushTime() const override { return _lastFlushTime; } virtual bool needUrgentFlush() const override { return _urgentFlush; } }; @@ -116,41 +117,36 @@ public: ContextBuilder::ContextBuilder() : _list(), _handler(new MyFlushHandler("myhandler")) {} -ContextBuilder::~ContextBuilder() {} +ContextBuilder::~ContextBuilder() = default; MyFlushTarget::SP createTargetM(const vespalib::string &name, MemoryGain memoryGain) { - return MyFlushTarget::SP(new MyFlushTarget(name, memoryGain, DiskGain(), - SerialNum(), TimeStamp(), false)); + return std::make_shared<MyFlushTarget>(name, memoryGain, DiskGain(),SerialNum(), UTCTimeStamp::ZERO, false); } MyFlushTarget::SP createTargetD(const vespalib::string &name, DiskGain diskGain, SerialNum serial = 0) { - return MyFlushTarget::SP(new MyFlushTarget(name, MemoryGain(), diskGain, - serial, TimeStamp(), false)); + return std::make_shared<MyFlushTarget>(name, MemoryGain(), diskGain, serial, UTCTimeStamp::ZERO, false); } MyFlushTarget::SP -createTargetS(const vespalib::string &name, SerialNum serial, TimeStamp timeStamp = TimeStamp()) +createTargetS(const vespalib::string &name, SerialNum serial, UTCTimeStamp timeStamp = UTCTimeStamp::ZERO) { - return MyFlushTarget::SP(new MyFlushTarget(name, MemoryGain(), DiskGain(), - serial, timeStamp, false)); + return std::make_shared<MyFlushTarget>(name, MemoryGain(), DiskGain(), serial, timeStamp, false); } MyFlushTarget::SP -createTargetT(const vespalib::string &name, TimeStamp lastFlushTime, SerialNum serial = 0) +createTargetT(const vespalib::string &name, UTCTimeStamp lastFlushTime, SerialNum serial = 0) { - return MyFlushTarget::SP(new MyFlushTarget(name, MemoryGain(), DiskGain(), - serial, lastFlushTime, false)); + return std::make_shared<MyFlushTarget>(name, MemoryGain(), DiskGain(), serial, lastFlushTime, false); } MyFlushTarget::SP createTargetF(const vespalib::string &name, bool urgentFlush) { - return MyFlushTarget::SP(new MyFlushTarget(name, MemoryGain(), DiskGain(), - SerialNum(), TimeStamp(), urgentFlush)); + return std::make_shared<MyFlushTarget>(name, MemoryGain(), DiskGain(), SerialNum(), UTCTimeStamp::ZERO, urgentFlush); } bool @@ -236,13 +232,13 @@ requireThatWeCanOrderByDiskGainWithSmallValues() void requireThatWeCanOrderByAge() { - TimeStamp now(fastos::ClockSystem::now()); - TimeStamp start(now.val() - 20 * TimeStamp::SEC); + UTCTimeStamp now(fastos::ClockSystem::now()); + UTCTimeStamp start(now - TimeStamp(20 * TimeStamp::SEC)); ContextBuilder cb; - cb.add(createTargetT("t2", TimeStamp(now.val() - 10 * TimeStamp::SEC))) - .add(createTargetT("t1", TimeStamp(now.val() - 5 * TimeStamp::SEC))) - .add(createTargetT("t4", TimeStamp())) - .add(createTargetT("t3", TimeStamp(now.val() - 15 * TimeStamp::SEC))); + 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))); { // all targets have timeDiff >= maxTimeGain MemoryFlush flush({1000, 20 * gibi, 1.0, 1000, 1.0, TimeStamp(2 * TimeStamp::SEC)}, start); @@ -258,33 +254,17 @@ requireThatWeCanOrderByAge() void requireThatWeCanOrderByTlsSize() { - TimeStamp now(fastos::ClockSystem::now()); - TimeStamp start(now.val() - 20 * TimeStamp::SEC); + UTCTimeStamp now(fastos::ClockSystem::now()); + UTCTimeStamp start = now - TimeStamp(20 * TimeStamp::SEC); 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", TimeStamp(now.val() - 10 * TimeStamp::SEC), - 1900), - 2000)). - add(std::make_shared<FlushContext> - (handler2, - createTargetT("t1", TimeStamp(now.val() - 5 * TimeStamp::SEC), - 1000), - 2000)). - add(std::make_shared<FlushContext> - (handler1, - createTargetT("t4", TimeStamp(), - 1000), - 2000)). - add(std::make_shared<FlushContext> - (handler2, - createTargetT("t3", TimeStamp(now.val() - 15 * TimeStamp::SEC), - 1900), - 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)); { // 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); EXPECT_TRUE(assertOrder(StringList().add("t4").add("t1").add("t2").add("t3"), @@ -304,22 +284,18 @@ requireThatWeHandleLargeSerialNumbersWhenOrderingByTlsSize() SerialNum firstSerial = 10; SerialNum lastSerial = uint32_max + 10; builder.addTls("myhandler", {uint32_max, firstSerial, lastSerial}); - builder.add(createTargetT("t1", TimeStamp(), uint32_max + 5), lastSerial); - builder.add(createTargetT("t2", TimeStamp(), uint32_max - 5), lastSerial); + builder.add(createTargetT("t1", UTCTimeStamp::ZERO, uint32_max + 5), lastSerial); + builder.add(createTargetT("t2", UTCTimeStamp::ZERO, uint32_max - 5), lastSerial); uint64_t maxMemoryGain = 10; - MemoryFlush flush({maxMemoryGain, 1000, 0, maxMemoryGain, 0, TimeStamp()}, TimeStamp()); - EXPECT_TRUE(assertOrder(StringList().add("t2").add("t1"), - flush.getFlushTargets(builder.list(), builder.tlsStats()))); + MemoryFlush flush({maxMemoryGain, 1000, 0, maxMemoryGain, 0, TimeStamp()}, UTCTimeStamp::ZERO); + EXPECT_TRUE(assertOrder(StringList().add("t2").add("t1"), flush.getFlushTargets(builder.list(), builder.tlsStats()))); } void requireThatOrderTypeIsPreserved() { - TimeStamp now(fastos::ClockSystem::now()); - TimeStamp ts1(now.val() - 30 * TimeStamp::SEC); - TimeStamp ts2(now.val() - 20 * TimeStamp::SEC); - TimeStamp ts3(now.val() - 10 * TimeStamp::SEC); - TimeStamp maxTimeGain(15 * TimeStamp::SEC); + UTCTimeStamp now(fastos::ClockSystem::now()); + UTCTimeStamp ts2 = now - TimeStamp(20 * TimeStamp::SEC); { // MAXAGE VS DISKBLOAT ContextBuilder cb; @@ -354,5 +330,3 @@ TEST_MAIN() TEST_DO(requireThatWeHandleLargeSerialNumbersWhenOrderingByTlsSize()); TEST_DO(requireThatOrderTypeIsPreserved()); } - - diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp index 2bbc6c99dc0..56b53a46693 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp @@ -75,14 +75,14 @@ AttributeDirectory::getFlushedSerialNum() const return bestSnap.valid ? bestSnap.syncToken : 0; } -fastos::TimeStamp +fastos::UTCTimeStamp AttributeDirectory::getLastFlushTime() const { return _lastFlushTime; } void -AttributeDirectory::setLastFlushTime(fastos::TimeStamp lastFlushTime) +AttributeDirectory::setLastFlushTime(fastos::UTCTimeStamp 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 603727dbb75..19f89466e39 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.h @@ -27,7 +27,7 @@ public: private: std::weak_ptr<AttributeDiskLayout> _diskLayout; const vespalib::string _name; - fastos::TimeStamp _lastFlushTime; + fastos::UTCTimeStamp _lastFlushTime; Writer *_writer; // current writer mutable std::mutex _mutex; std::condition_variable _cv; @@ -35,7 +35,7 @@ private: void saveSnapInfo(); vespalib::string getSnapshotDir(SerialNum serialNum); - void setLastFlushTime(fastos::TimeStamp lastFlushTime); + void setLastFlushTime(fastos::UTCTimeStamp lastFlushTime); void createInvalidSnapshot(SerialNum serialNum); void markValidSnapshot(SerialNum serialNum); void invalidateOldSnapshots(SerialNum serialNum); @@ -65,7 +65,7 @@ public: ~Writer(); // methods called when saving an attribute. - void setLastFlushTime(fastos::TimeStamp lastFlushTime) { _dir.setLastFlushTime(lastFlushTime); } + void setLastFlushTime(fastos::UTCTimeStamp 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); } @@ -81,7 +81,7 @@ public: std::unique_ptr<Writer> getWriter(); std::unique_ptr<Writer> tryGetWriter(); SerialNum getFlushedSerialNum() const; - fastos::TimeStamp getLastFlushTime() const; + fastos::UTCTimeStamp 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 378b7106610..66d1c27a5b5 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp @@ -203,21 +203,18 @@ FlushableAttribute::internalInitFlush(SerialNum currentSerial) { // Called by attribute field writer thread while document db executor waits _attr->removeAllOldGenerations(); - SerialNum syncToken = std::max(currentSerial, - _attr->getStatus().getLastSyncToken()); + SerialNum syncToken = std::max(currentSerial, _attr->getStatus().getLastSyncToken()); auto writer = _attrDir->tryGetWriter(); if (!writer) { return Task::UP(); } if (syncToken <= getFlushedSerialNum()) { writer->setLastFlushTime(fastos::ClockSystem::now()); - LOG(debug, - "No attribute vector to flush." - " Update flush time to current: lastFlushTime(%f)", - getLastFlushTime().sec()); + LOG(debug,"No attribute vector to flush. Update flush time to current: lastFlushTime(%f)", + getLastFlushTime().timeSinceEpoch().sec()); return Task::UP(); } - return Task::UP(new Flusher(*this, syncToken, *writer)); + return std::make_unique<Flusher>(*this, syncToken, *writer); } diff --git a/searchcore/src/vespa/searchcore/proton/common/commit_time_tracker.cpp b/searchcore/src/vespa/searchcore/proton/common/commit_time_tracker.cpp index 0075497ff9d..c9db3d23979 100644 --- a/searchcore/src/vespa/searchcore/proton/common/commit_time_tracker.cpp +++ b/searchcore/src/vespa/searchcore/proton/common/commit_time_tracker.cpp @@ -6,10 +6,10 @@ namespace proton { CommitTimeTracker::CommitTimeTracker(fastos::TimeStamp visibilityDelay) : _visibilityDelay(visibilityDelay), - _nextCommit(fastos::ClockSystem::now()), + _nextCommit(fastos::ClockSteady::now()), _replayDone(false) { - _nextCommit += visibilityDelay; + _nextCommit = _nextCommit + visibilityDelay; } bool @@ -19,8 +19,8 @@ CommitTimeTracker::needCommit() const if (_replayDone) { return false; // maintenance job will do forced commits now } - fastos::TimeStamp now(fastos::ClockSystem::now()); - if (now >= _nextCommit) { + fastos::SteadyTimeStamp now(fastos::ClockSteady::now()); + if (now > _nextCommit) { _nextCommit = now + _visibilityDelay; return true; } @@ -32,13 +32,11 @@ CommitTimeTracker::needCommit() const void CommitTimeTracker::setVisibilityDelay(fastos::TimeStamp visibilityDelay) { - fastos::TimeStamp now(fastos::ClockSystem::now()); - fastos::TimeStamp nextCommit = now + visibilityDelay; - if (nextCommit.val() < _nextCommit.val()) { + fastos::SteadyTimeStamp nextCommit = fastos::ClockSteady::now() + visibilityDelay; + if (nextCommit < _nextCommit) { _nextCommit = nextCommit; } _visibilityDelay = visibilityDelay; } - } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/common/commit_time_tracker.h b/searchcore/src/vespa/searchcore/proton/common/commit_time_tracker.h index 5cc082c0b19..d00152cf372 100644 --- a/searchcore/src/vespa/searchcore/proton/common/commit_time_tracker.h +++ b/searchcore/src/vespa/searchcore/proton/common/commit_time_tracker.h @@ -11,9 +11,9 @@ namespace proton { class CommitTimeTracker { private: - fastos::TimeStamp _visibilityDelay; - mutable fastos::TimeStamp _nextCommit; - bool _replayDone; + fastos::TimeStamp _visibilityDelay; + mutable fastos::SteadyTimeStamp _nextCommit; + bool _replayDone; public: CommitTimeTracker(fastos::TimeStamp visibilityDelay); diff --git a/searchcore/src/vespa/searchcore/proton/docsummary/summaryflushtarget.cpp b/searchcore/src/vespa/searchcore/proton/docsummary/summaryflushtarget.cpp index 2f7681c5909..a101ad4d83c 100644 --- a/searchcore/src/vespa/searchcore/proton/docsummary/summaryflushtarget.cpp +++ b/searchcore/src/vespa/searchcore/proton/docsummary/summaryflushtarget.cpp @@ -82,7 +82,7 @@ SummaryFlushTarget::getFlushedSerialNum() const IFlushTarget::Task::UP SummaryFlushTarget::internalInitFlush(SerialNum currentSerial) { - return Task::UP(new Flusher(_docStore, _lastStats, currentSerial)); + return std::make_unique<Flusher>(_docStore, _lastStats, currentSerial); } IFlushTarget::Task::UP SummaryFlushTarget::initFlush(SerialNum currentSerial) diff --git a/searchcore/src/vespa/searchcore/proton/docsummary/summarymanager.cpp b/searchcore/src/vespa/searchcore/proton/docsummary/summarymanager.cpp index 113855d7e2b..74d107814fd 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, Time lastFlushTime, + SerialNum flushedSerialNum, fastos::UTCTimeStamp 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, Time lastFlushTime, + SerialNum flushedSerialNum, fastos::UTCTimeStamp 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(), - docStore->getLastFlushTime(), + fastos::UTCTimeStamp(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 56ecdaa0cb0..2cadedd0f59 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp @@ -223,7 +223,7 @@ DocumentMetaStoreFlushTarget::initFlush(SerialNum currentSerial) if (syncToken <= getFlushedSerialNum()) { writer->setLastFlushTime(fastos::ClockSystem::now()); LOG(debug, "No document meta store to flush. Update flush time to current: lastFlushTime(%f)", - getLastFlushTime().sec()); + getLastFlushTime().timeSinceEpoch().sec()); return Task::UP(); } return std::make_unique<Flusher>(*this, syncToken, *writer); diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/i_bucket_handler.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/i_bucket_handler.h index 1a0b3c61c47..f96972c4562 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/i_bucket_handler.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/i_bucket_handler.h @@ -8,18 +8,12 @@ #include <vespa/searchcore/proton/bucketdb/bucketdeltapair.h> #include <vector> -namespace proton { - -namespace bucketdb -{ - -class SplitBucketSession; -class JoinBucketsSession; - +namespace proton::bucketdb { + class SplitBucketSession; + class JoinBucketsSession; } - -namespace documentmetastore { +namespace proton::documentmetastore { /** * Interface for handling bucket changes relevant to the document meta store. @@ -63,6 +57,4 @@ struct IBucketHandler }; -} // namespace documentmetastore -} // namespace proton - +} diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/i_store.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/i_store.h index 64071eef526..9e3988c76f0 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/i_store.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/i_store.h @@ -7,8 +7,7 @@ #include <vespa/document/bucket/bucketid.h> #include <persistence/spi/types.h> -namespace proton { -namespace documentmetastore { +namespace proton::documentmetastore { /** @@ -117,8 +116,7 @@ struct IStore * Removes a list of lids. * The caller must call removeBatchComplete() after documents removal is done. */ - virtual void removeBatch(const std::vector<DocId> &lidsToRemove, - const DocId docIdLimit) = 0; + virtual void removeBatch(const std::vector<DocId> &lidsToRemove, const DocId docIdLimit) = 0; /** * Signal that the removal of the documents associated with these lids is complete. @@ -138,6 +136,5 @@ struct IStore virtual bool getFreeListActive() const = 0; }; -} // namespace documentmetastore -} // namespace proton +} diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.cpp index d538c80b429..5ba6a805a8e 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.cpp @@ -13,8 +13,7 @@ LidReuseDelayerConfig::LidReuseDelayerConfig() LidReuseDelayerConfig::LidReuseDelayerConfig(const DocumentDBConfig & configSnapshot) - : _visibilityDelay(configSnapshot.getMaintenanceConfigSP()-> - getVisibilityDelay()), + : _visibilityDelay(configSnapshot.getMaintenanceConfigSP()->getVisibilityDelay()), _hasIndexedOrAttributeFields(configSnapshot.getSchemaSP()->getNumIndexFields() > 0 || configSnapshot.getSchemaSP()->getNumAttributeFields() > 0) { diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.h b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.h index bbc712339cd..a11f5ff1f24 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.h +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/lid_reuse_delayer_config.h @@ -3,11 +3,10 @@ #pragma once #include <vespa/fastos/timestamp.h> -namespace proton { -class DocumentDBConfig; +namespace proton { class DocumentDBConfig; } -namespace documentmetastore { +namespace proton::documentmetastore { /* * Class representing configuration for lid reuse delayer. @@ -24,6 +23,4 @@ public: bool hasIndexedOrAttributeFields() const { return _hasIndexedOrAttributeFields; } }; -} // namespace proton::documentmetastore - -} // namespace proton +} 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 61f332bd5fc..ebb7ad5ecd2 100644 --- a/searchcore/src/vespa/searchcore/proton/flushengine/flush_engine_explorer.cpp +++ b/searchcore/src/vespa/searchcore/proton/flushengine/flush_engine_explorer.cpp @@ -15,15 +15,13 @@ namespace proton { namespace { void -convertToSlime(const FlushEngine::FlushMetaSet &flushingTargets, - const fastos::TimeStamp &now, - Cursor &array) +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()); - fastos::TimeStamp elapsedTime = now - target.getStart(); + fastos::TimeStamp elapsedTime = target.elapsed(); object.setDouble("elapsedTime", elapsedTime.sec()); } } @@ -40,7 +38,7 @@ sortTargetList(FlushContext::List &allTargets) void convertToSlime(const FlushContext::List &allTargets, - const fastos::TimeStamp &now, + const fastos::UTCTimeStamp &now, Cursor &array) { for (const auto &ctx : allTargets) { @@ -69,8 +67,8 @@ FlushEngineExplorer::get_state(const Inserter &inserter, bool full) const { Cursor &object = inserter.insertObject(); if (full) { - fastos::TimeStamp now = fastos::ClockSystem::now(); - convertToSlime(_engine.getCurrentlyFlushingSet(), now, object.setArray("flushingTargets")); + fastos::UTCTimeStamp now = fastos::ClockSystem::now(); + convertToSlime(_engine.getCurrentlyFlushingSet(), object.setArray("flushingTargets")); FlushContext::List allTargets = _engine.getTargetList(true); sortTargetList(allTargets); convertToSlime(allTargets, now, object.setArray("allTargets")); diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp index 44406e2227a..1922b906075 100644 --- a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp +++ b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.cpp @@ -51,15 +51,15 @@ logTarget(const char * text, const FlushContext & ctx) { } -FlushEngine::FlushMeta::FlushMeta(const vespalib::string & name, fastos::TimeStamp start, uint32_t id) +FlushEngine::FlushMeta::FlushMeta(const vespalib::string & name, uint32_t id) : _name(name), - _start(start), + _stopWatch(), _id(id) { } FlushEngine::FlushMeta::~FlushMeta() = default; FlushEngine::FlushInfo::FlushInfo() - : FlushMeta("", fastos::ClockSystem::now(), 0), + : FlushMeta("", 0), _target() { } @@ -68,7 +68,7 @@ FlushEngine::FlushInfo::~FlushInfo() = default; FlushEngine::FlushInfo::FlushInfo(uint32_t taskId, const IFlushTarget::SP &target, const vespalib::string & destination) - : FlushMeta(destination, fastos::ClockSystem::now(), taskId), + : FlushMeta(destination, taskId), _target(target) { } @@ -351,7 +351,7 @@ FlushEngine::flushDone(const FlushContext &ctx, uint32_t taskId) fastos::TimeStamp duration; { std::lock_guard<std::mutex> guard(_lock); - duration = fastos::TimeStamp(fastos::ClockSystem::now()) - _flushing[taskId].getStart(); + duration = _flushing[taskId].elapsed(); } if (LOG_WOULD_LOG(event)) { FlushStats stats = ctx.getTarget()->getLastFlushStats(); diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h index c1be05ba067..38f8eabf828 100644 --- a/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h +++ b/searchcore/src/vespa/searchcore/proton/flushengine/flushengine.h @@ -20,15 +20,16 @@ class FlushEngine final : public FastOS_Runnable public: class FlushMeta { public: - FlushMeta(const vespalib::string & name, fastos::TimeStamp start, uint32_t id); + FlushMeta(const vespalib::string & name, uint32_t id); ~FlushMeta(); const vespalib::string & getName() const { return _name; } - fastos::TimeStamp getStart() const { return _start; } + fastos::UTCTimeStamp getStart() const { return fastos::ClockSystem::now() - elapsed(); } + fastos::TimeStamp elapsed() const { return _stopWatch.stop().elapsed(); } uint32_t getId() const { return _id; } bool operator < (const FlushMeta & rhs) const { return _id < rhs._id; } private: vespalib::string _name; - fastos::TimeStamp _start; + mutable fastos::StopWatch _stopWatch; uint32_t _id; }; typedef std::set<FlushMeta> FlushMetaSet; 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 d24cb77f86b..03a905a18ca 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 @@ -15,8 +15,8 @@ class ShrinkLidSpaceFlushTarget::Flusher : public FlushTask SerialNum _flushSerialNum; public: Flusher(ShrinkLidSpaceFlushTarget &target, SerialNum flushSerialNum); - virtual void run() override; - virtual search::SerialNum getFlushSerial() const override; + void run() override; + search::SerialNum getFlushSerial() const override; }; ShrinkLidSpaceFlushTarget::Flusher::Flusher(ShrinkLidSpaceFlushTarget &target, SerialNum flushSerialNum) diff --git a/searchcore/src/vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.h b/searchcore/src/vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.h index f2123bf67b4..c1ecb2c2b4a 100644 --- a/searchcore/src/vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.h +++ b/searchcore/src/vespa/searchcore/proton/flushengine/shrink_lid_space_flush_target.h @@ -42,14 +42,14 @@ public: std::shared_ptr<ICompactableLidSpace> target); // Implements IFlushTarget. - virtual MemoryGain getApproxMemoryGain() const override; - virtual DiskGain getApproxDiskGain() const override; - virtual SerialNum getFlushedSerialNum() const override; - virtual Time getLastFlushTime() const override; - virtual bool needUrgentFlush() const override; - virtual Task::UP initFlush(SerialNum currentSerial) override; - virtual searchcorespi::FlushStats getLastFlushStats() const override; - virtual uint64_t getApproxBytesToWriteToDisk() const override; + MemoryGain getApproxMemoryGain() const override; + DiskGain getApproxDiskGain() const override; + SerialNum getFlushedSerialNum() const override; + Time getLastFlushTime() const override; + bool needUrgentFlush() const override; + Task::UP initFlush(SerialNum currentSerial) override; + searchcorespi::FlushStats getLastFlushStats() const override; + uint64_t getApproxBytesToWriteToDisk() const override; }; } // namespace proton diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp index 7c581d7b01d..48599b1ecff 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp @@ -287,7 +287,7 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl _stats.add(my_stats); if (my_stats.softDoomed()) { double old = _stats.softDoomFactor(); - fastos::TimeStamp softLimit = uint64_t((1.0 - _rankSetup->getSoftTimeoutTailCost()) * request.getTimeout()); + fastos::TimeStamp softLimit = (1.0 - _rankSetup->getSoftTimeoutTailCost()) * request.getTimeout(); fastos::TimeStamp adjustedDuration = duration - my_stats.doomOvertime(); if (adjustedDuration < 0) { adjustedDuration = 0; diff --git a/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp b/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp index d3b65505277..8ea9e095385 100644 --- a/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp @@ -74,7 +74,7 @@ MemoryFlush::Config::Config(uint64_t maxGlobalMemory_in, maxTimeGain(maxTimeGain_in) { } -MemoryFlush::MemoryFlush(const Config &config, fastos::TimeStamp startTime) +MemoryFlush::MemoryFlush(const Config &config, fastos::UTCTimeStamp startTime) : _lock(), _config(config), _startTime(startTime) @@ -85,7 +85,7 @@ MemoryFlush::MemoryFlush() : MemoryFlush(Config(), fastos::ClockSystem::now()) { } -MemoryFlush::~MemoryFlush() { } +MemoryFlush::~MemoryFlush() = default; MemoryFlush::Config MemoryFlush::getConfig() const @@ -133,14 +133,14 @@ MemoryFlush::getFlushTargets(const FlushContext::List &targetList, uint64_t totalTlsSize(0); const Config config(getConfig()); vespalib::hash_set<const void *> visitedHandlers; - fastos::TimeStamp now(fastos::ClockSystem::now()); + fastos::UTCTimeStamp now(fastos::ClockSystem::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.sec()); + _startTime.timeSinceEpoch().sec()); 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 +150,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::TimeStamp lastFlushTime = target.getLastFlushTime(); - fastos::TimeStamp timeDiff(now - (lastFlushTime.val() > 0 ? lastFlushTime : _startTime)); + fastos::UTCTimeStamp lastFlushTime = target.getLastFlushTime(); + fastos::TimeStamp timeDiff(now - (lastFlushTime > fastos::UTCTimeStamp::ZERO ? lastFlushTime : _startTime)); totalMemory += mgain; const flushengine::TlsStats &tlsStats = tlsStatsMap.getTlsStats(handler.getName()); if (visitedHandlers.insert(&handler).second) { @@ -183,8 +183,8 @@ MemoryFlush::getFlushTargets(const FlushContext::List &targetList, target.getFlushedSerialNum(), localLastSerial, serialDiff, - lastFlushTime.sec(), - now.sec(), + lastFlushTime.timeSinceEpoch().sec(), + now.timeSinceEpoch().sec(), timeDiff.sec(), getOrderName(order).c_str()); } diff --git a/searchcore/src/vespa/searchcore/proton/server/memoryflush.h b/searchcore/src/vespa/searchcore/proton/server/memoryflush.h index 7e9bba59b25..532abe939cb 100644 --- a/searchcore/src/vespa/searchcore/proton/server/memoryflush.h +++ b/searchcore/src/vespa/searchcore/proton/server/memoryflush.h @@ -42,7 +42,7 @@ private: mutable std::mutex _lock; Config _config; /// The time when the strategy was started. - fastos::TimeStamp _startTime; + fastos::UTCTimeStamp _startTime; class CompareTarget { @@ -63,7 +63,7 @@ public: MemoryFlush(); explicit MemoryFlush(const Config &config) : MemoryFlush(config, fastos::ClockSystem::now()) { } - MemoryFlush(const Config &config, fastos::TimeStamp startTime); + MemoryFlush(const Config &config, fastos::UTCTimeStamp startTime); ~MemoryFlush(); FlushContext::List diff --git a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp index 96952cf9f13..b5a430b3bcb 100644 --- a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.cpp @@ -12,8 +12,7 @@ LOG_SETUP(".proton.server.pruneremoveddocumentsjob"); using document::BucketId; using storage::spi::Timestamp; -namespace proton -{ +namespace proton { PruneRemovedDocumentsJob:: PruneRemovedDocumentsJob(const Config &config, @@ -45,10 +44,8 @@ PruneRemovedDocumentsJob::flush(DocId lowLid, DocId nextLowLid, DocId docIdLimit = _metaStore.getCommittedDocIdLimit(); PruneRemovedDocumentsOperation pruneOp(docIdLimit, _subDbId); LidVectorContext::SP lvCtx(pruneOp.getLidsToRemove()); - for (std::vector<DocId>::const_iterator it = _pruneLids.begin(), - ite = _pruneLids.end(); - it != ite; ++it) { - lvCtx->addLid(*it); + for (DocId docId : _pruneLids) { + lvCtx->addLid(docId); } _pruneLids.clear(); LOG(debug, @@ -68,9 +65,9 @@ bool PruneRemovedDocumentsJob::run() { uint64_t tshz = 1000000; - fastos::TimeStamp now = fastos::ClockSystem::now(); + fastos::UTCTimeStamp now = fastos::ClockSystem::now(); const Timestamp ageLimit(static_cast<Timestamp::Type> - ((now.sec() - _cfgAgeLimit) * tshz)); + ((now.timeSinceEpoch().sec() - _cfgAgeLimit) * tshz)); DocId lid(_nextLid); const DocId olid(lid); const DocId docIdLimit(_metaStore.getCommittedDocIdLimit()); diff --git a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.h b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.h index 551cf4615b0..42c5d964aed 100644 --- a/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.h +++ b/searchcore/src/vespa/searchcore/proton/server/pruneremoveddocumentsjob.h @@ -5,8 +5,7 @@ #include "document_db_maintenance_config.h" #include <persistence/spi/types.h> -namespace proton -{ +namespace proton { struct IDocumentMetaStore; class IPruneRemovedDocumentsHandler; @@ -30,8 +29,7 @@ private: std::vector<DocId> _pruneLids; DocId _nextLid; - void - flush(DocId lowLid, DocId nextLowLid, const storage::spi::Timestamp ageLimit); + void flush(DocId lowLid, DocId nextLowLid, const storage::spi::Timestamp ageLimit); public: using Config = DocumentDBPruneRemovedDocumentsConfig; @@ -43,7 +41,7 @@ public: IFrozenBucketHandler &frozenHandler); // Implements IMaintenanceJob - virtual bool run() override; + bool run() override; }; } // namespace proton 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 a62e5e77bc1..2eee9b5dd8e 100644 --- a/searchcore/src/vespa/searchcore/proton/test/dummy_document_store.h +++ b/searchcore/src/vespa/searchcore/proton/test/dummy_document_store.h @@ -17,49 +17,47 @@ struct DummyDocumentStore : public search::IDocumentStore : _baseDir(baseDir) {} ~DummyDocumentStore() {} - virtual document::Document::UP read(search::DocumentIdT, - const document::DocumentTypeRepo &) const override { + document::Document::UP read(search::DocumentIdT, const document::DocumentTypeRepo &) const override { return document::Document::UP(); } - virtual void write(uint64_t, search::DocumentIdT, const document::Document &) override {} - virtual void write(uint64_t, search::DocumentIdT, const vespalib::nbostream &) override {} - virtual void remove(uint64_t, search::DocumentIdT) override {} - virtual void flush(uint64_t) override {} - virtual uint64_t initFlush(uint64_t) override { return 0; } - virtual void compact(uint64_t) override {} - virtual uint64_t lastSyncToken() const override { return 0; } - virtual uint64_t tentativeLastSyncToken() const override { return 0; } - virtual fastos::TimeStamp getLastFlushTime() const override { return fastos::TimeStamp(); } - virtual uint32_t getDocIdLimit() const override { return 0; } - virtual size_t memoryUsed() const override { return 0; } - virtual size_t memoryMeta() const override { return 0; } - virtual size_t getDiskFootprint() const override { return 0; } - virtual size_t getDiskBloat() const override { return 0; } - virtual size_t getMaxCompactGain() const override { return getDiskBloat(); } - virtual search::CacheStats getCacheStats() const override { return search::CacheStats(); } - virtual const vespalib::string &getBaseDir() const override { return _baseDir; } - virtual void accept(search::IDocumentStoreReadVisitor &, - search::IDocumentStoreVisitorProgress &, - const document::DocumentTypeRepo &) override {} - - virtual void accept(search::IDocumentStoreRewriteVisitor &, - search::IDocumentStoreVisitorProgress &, - const document::DocumentTypeRepo &) override {} - - virtual double getVisitCost() const override { return 1.0; } - virtual search::DataStoreStorageStats getStorageStats() const override { + void write(uint64_t, search::DocumentIdT, const document::Document &) override {} + void write(uint64_t, search::DocumentIdT, const vespalib::nbostream &) override {} + void remove(uint64_t, search::DocumentIdT) override {} + void flush(uint64_t) override {} + uint64_t initFlush(uint64_t) override { return 0; } + 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; } + uint32_t getDocIdLimit() const override { return 0; } + size_t memoryUsed() const override { return 0; } + size_t memoryMeta() const override { return 0; } + size_t getDiskFootprint() const override { return 0; } + size_t getDiskBloat() const override { return 0; } + size_t getMaxCompactGain() const override { return getDiskBloat(); } + search::CacheStats getCacheStats() const override { return search::CacheStats(); } + const vespalib::string &getBaseDir() const override { return _baseDir; } + void accept(search::IDocumentStoreReadVisitor &, + search::IDocumentStoreVisitorProgress &, + const document::DocumentTypeRepo &) override {} + void accept(search::IDocumentStoreRewriteVisitor &, + search::IDocumentStoreVisitorProgress &, + const document::DocumentTypeRepo &) override {} + + double getVisitCost() const override { return 1.0; } + search::DataStoreStorageStats getStorageStats() const override { return search::DataStoreStorageStats(0, 0, 0.0, 0, 0, 0); } - virtual vespalib::MemoryUsage getMemoryUsage() const override { return vespalib::MemoryUsage(); } - virtual std::vector<search::DataStoreFileChunkStats> getFileChunkStats() const override { + vespalib::MemoryUsage getMemoryUsage() const override { return vespalib::MemoryUsage(); } + std::vector<search::DataStoreFileChunkStats> getFileChunkStats() const override { std::vector<search::DataStoreFileChunkStats> result; return result; } - virtual void compactLidSpace(uint32_t wantedDocLidLimit) override { (void) wantedDocLidLimit; } - virtual bool canShrinkLidSpace() const override { return false; } - virtual size_t getEstimatedShrinkLidSpaceGain() const override { return 0; } - virtual void shrinkLidSpace() override {} + void compactLidSpace(uint32_t wantedDocLidLimit) override { (void) wantedDocLidLimit; } + bool canShrinkLidSpace() const override { return false; } + size_t getEstimatedShrinkLidSpaceGain() const override { return 0; } + void shrinkLidSpace() override {} }; } |