diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-12-16 15:43:32 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-16 15:43:32 -0800 |
commit | 2f8e6f0cb74ef77a645e7543975aca736f7649a9 (patch) | |
tree | 3cd1f386e75cfdefaedb1ba19f8fbdc5533fc5b7 /searchlib | |
parent | 40e8a8b4ac2a021ede5a5babd42976ab313ce0b8 (diff) | |
parent | 0da20f33e911811b72bea5de39e90d17632bf8bd (diff) |
Merge pull request #11535 from vespa-engine/balder/remove-steadytimestamp-2
Balder/remove steadytimestamp 2
Diffstat (limited to 'searchlib')
23 files changed, 123 insertions, 121 deletions
diff --git a/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp b/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp index f4de610a06d..245f082a2db 100644 --- a/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp +++ b/searchlib/src/apps/vespa-attribute-inspect/vespa-attribute-inspect.cpp @@ -165,16 +165,16 @@ LoadAttribute::Main() c.setFastSearch(doFastSearch); c.setHuge(doHuge); AttributePtr ptr = AttributeFactory::createAttribute(fileName, c); - fastos::StopWatch timer; + vespalib::Timer timer; load(ptr); - std::cout << "load time: " << timer.elapsed().sec() << " seconds " << std::endl; + std::cout << "load time: " << vespalib::to_s(timer.elapsed()) << " seconds " << std::endl; std::cout << "numDocs: " << ptr->getNumDocs() << std::endl; if (doApplyUpdate) { - timer.restart(); + timer = vespalib::Timer(); applyUpdate(ptr); - std::cout << "update time: " << timer.elapsed().sec() << " seconds " << std::endl; + std::cout << "update time: " << vespalib::to_s(timer.elapsed()) << " seconds " << std::endl; } if (doPrintContent) { @@ -191,9 +191,9 @@ LoadAttribute::Main() if (doSave) { vespalib::string saveFile = fileName + ".save"; std::cout << "saving attribute: " << saveFile << std::endl; - timer.restart(); + timer = vespalib::Timer(); ptr->save(saveFile); - std::cout << "save time: " << timer.elapsed().sec() << " seconds " << std::endl; + std::cout << "save time: " << vespalib::to_s(timer.elapsed()) << " seconds " << std::endl; } return 0; diff --git a/searchlib/src/tests/aggregator/perdocexpr.cpp b/searchlib/src/tests/aggregator/perdocexpr.cpp index c078282c442..513e94321e1 100644 --- a/searchlib/src/tests/aggregator/perdocexpr.cpp +++ b/searchlib/src/tests/aggregator/perdocexpr.cpp @@ -694,9 +694,9 @@ TEST("testDebugFunction") { DebugWaitFunctionNode n(std::move(add), 1.3, false); n.prepare(false); - fastos::StopWatch timer; + vespalib::Timer timer; n.execute(); - EXPECT_TRUE(timer.elapsed().ms() > 1000.0); + EXPECT_TRUE(timer.elapsed() > 1s); EXPECT_EQUAL(static_cast<const Int64ResultNode &>(n.getResult()).get(), 7); } { @@ -706,9 +706,9 @@ TEST("testDebugFunction") { DebugWaitFunctionNode n(std::move(add), 1.3, true); n.prepare(false); - fastos::StopWatch timer; + vespalib::Timer timer; n.execute(); - EXPECT_TRUE(timer.elapsed().ms() > 1000.0); + EXPECT_TRUE(timer.elapsed() > 1s); EXPECT_EQUAL(static_cast<const Int64ResultNode &>(n.getResult()).get(), 7); } } diff --git a/searchlib/src/tests/attribute/benchmark/attributesearcher.h b/searchlib/src/tests/attribute/benchmark/attributesearcher.h index 66bb6467194..8ff6ba46e86 100644 --- a/searchlib/src/tests/attribute/benchmark/attributesearcher.h +++ b/searchlib/src/tests/attribute/benchmark/attributesearcher.h @@ -26,7 +26,7 @@ performSearch(queryeval::SearchIterator & sb, uint32_t numDocs) class AttributeSearcherStatus { public: - double _totalSearchTime; + vespalib::duration _totalSearchTime; uint64_t _totalHitCount; uint64_t _numQueries; uint64_t _numClients; @@ -39,20 +39,20 @@ public: _numClients += status._numClients; } void printXML() const { - std::cout << "<total-search-time>" << _totalSearchTime << "</total-search-time>" << std::endl; // ms + std::cout << "<total-search-time>" << vespalib::count_ms(_totalSearchTime) << "</total-search-time>" << std::endl; // ms std::cout << "<avg-search-time>" << avgSearchTime() << "</avg-search-time>" << std::endl; // ms std::cout << "<search-throughput>" << searchThroughout() << "</search-throughput>" << std::endl; // per/sec std::cout << "<total-hit-count>" << _totalHitCount << "</total-hit-count>" << std::endl; std::cout << "<avg-hit-count>" << avgHitCount() << "</avg-hit-count>" << std::endl; } double avgSearchTime() const { - return _totalSearchTime / _numQueries; + return vespalib::count_ms(_totalSearchTime/_numQueries); } double searchThroughout() const { - return _numClients * 1000 * _numQueries / _totalSearchTime; + return _numClients * 1000 * _numQueries / (vespalib::count_ns(_totalSearchTime)/1000000.0); } double avgHitCount() const { - return _totalHitCount / static_cast<double>(_numQueries); + return _totalHitCount / double(_numQueries); } }; @@ -62,8 +62,8 @@ class AttributeSearcher : public Runnable protected: typedef AttributeVector::SP AttributePtr; - const AttributePtr & _attrPtr; - fastos::StopWatch _timer; + const AttributePtr & _attrPtr; + vespalib::Timer _timer; AttributeSearcherStatus _status; public: @@ -121,7 +121,7 @@ template <typename T> void AttributeFindSearcher<T>::doRun() { - _timer.restart(); + _timer = vespalib::Timer(); for (uint32_t i = 0; i < _status._numQueries; ++i) { // build simple term query vespalib::asciistream ss; @@ -139,7 +139,7 @@ AttributeFindSearcher<T>::doRun() _status._totalHitCount += results->getNumHits(); } - _status._totalSearchTime += _timer.elapsed().ms(); + _status._totalSearchTime += _timer.elapsed(); } @@ -198,7 +198,7 @@ public: void AttributeRangeSearcher::doRun() { - _timer.restart(); + _timer = vespalib::Timer(); RangeIterator iter(_spec); for (uint32_t i = 0; i < _status._numQueries; ++i, ++iter) { // build simple range term query @@ -217,7 +217,7 @@ AttributeRangeSearcher::doRun() _status._totalHitCount += results->getNumHits(); } - _status._totalSearchTime += _timer.elapsed().ms(); + _status._totalSearchTime += _timer.elapsed(); } @@ -240,7 +240,7 @@ public: void AttributePrefixSearcher::doRun() { - _timer.restart(); + _timer = vespalib::Timer(); for (uint32_t i = 0; i < _status._numQueries; ++i) { // build simple prefix term query buildTermQuery(_query, _attrPtr->getName(), _values[i % _values.size()].c_str(), true); @@ -256,7 +256,7 @@ AttributePrefixSearcher::doRun() _status._totalHitCount += results->getNumHits(); } - _status._totalSearchTime += _timer.elapsed().ms(); + _status._totalSearchTime += _timer.elapsed(); } } // search diff --git a/searchlib/src/tests/attribute/benchmark/attributeupdater.h b/searchlib/src/tests/attribute/benchmark/attributeupdater.h index c56c809457b..e4cfaf430d8 100644 --- a/searchlib/src/tests/attribute/benchmark/attributeupdater.h +++ b/searchlib/src/tests/attribute/benchmark/attributeupdater.h @@ -49,19 +49,19 @@ public: class AttributeUpdaterStatus { public: - double _totalUpdateTime; + vespalib::duration _totalUpdateTime; uint64_t _numDocumentUpdates; uint64_t _numValueUpdates; AttributeUpdaterStatus() : - _totalUpdateTime(0), _numDocumentUpdates(0), _numValueUpdates(0) {} + _totalUpdateTime(vespalib::duration::zero()), _numDocumentUpdates(0), _numValueUpdates(0) {} void reset() { - _totalUpdateTime = 0; + _totalUpdateTime = vespalib::duration::zero(); _numDocumentUpdates = 0; _numValueUpdates = 0; } void printXML() const { - std::cout << "<total-update-time>" << _totalUpdateTime << "</total-update-time>" << std::endl; + std::cout << "<total-update-time>" << vespalib::count_ms(_totalUpdateTime) << "</total-update-time>" << std::endl; std::cout << "<documents-updated>" << _numDocumentUpdates << "</documents-updated>" << std::endl; std::cout << "<document-update-throughput>" << documentUpdateThroughput() << "</document-update-throughput>" << std::endl; std::cout << "<avg-document-update-time>" << avgDocumentUpdateTime() << "</avg-document-update-time>" << std::endl; @@ -70,17 +70,19 @@ public: std::cout << "<avg-value-update-time>" << avgValueUpdateTime() << "</avg-value-update-time>" << std::endl; } double documentUpdateThroughput() const { - return _numDocumentUpdates * 1000 / _totalUpdateTime; + return _numDocumentUpdates * 1000 / as_ms(); } double avgDocumentUpdateTime() const { - return _totalUpdateTime / _numDocumentUpdates; + return vespalib::count_ms(_totalUpdateTime / _numDocumentUpdates); } double valueUpdateThroughput() const { - return _numValueUpdates * 1000 / _totalUpdateTime; + return _numValueUpdates * 1000 / as_ms(); } double avgValueUpdateTime() const { - return _totalUpdateTime / _numValueUpdates; + return vespalib::count_ms(_totalUpdateTime / _numValueUpdates); } +private: + double as_ms() const { return vespalib::count_ns(_totalUpdateTime)/1000000.0;} }; // AttributeVectorInstance, AttributeVectorType, AttributeVectorBufferType @@ -98,7 +100,7 @@ protected: std::vector<BT> _getBuffer; RandomGenerator & _rndGen; AttributeCommit _expected; - fastos::StopWatch _timer; + vespalib::Timer _timer; AttributeUpdaterStatus _status; AttributeValidator _validator; @@ -148,7 +150,7 @@ AttributeUpdater<Vector, T, BT>::AttributeUpdater(const AttributePtr & attrPtr, {} template <typename Vector, typename T, typename BT> -AttributeUpdater<Vector, T, BT>::~AttributeUpdater() {} +AttributeUpdater<Vector, T, BT>::~AttributeUpdater() = default; template <typename Vector, typename T, typename BT> class AttributeUpdaterThread : public AttributeUpdater<Vector, T, BT>, public Runnable @@ -173,7 +175,7 @@ AttributeUpdaterThread<Vector, T, BT>::AttributeUpdaterThread(const AttributePtr Runnable() {} template <typename Vector, typename T, typename BT> -AttributeUpdaterThread<Vector, T, BT>::~AttributeUpdaterThread() { } +AttributeUpdaterThread<Vector, T, BT>::~AttributeUpdaterThread() = default; template <typename Vector, typename T, typename BT> @@ -267,7 +269,7 @@ template <typename Vector, typename T, typename BT> void AttributeUpdater<Vector, T, BT>::populate() { - _timer.restart(); + _timer = vespalib::Timer(); for (uint32_t doc = 0; doc < _attrPtr->getNumDocs(); ++doc) { updateValues(doc); if (doc % _commitFreq == (_commitFreq - 1)) { @@ -275,7 +277,7 @@ AttributeUpdater<Vector, T, BT>::populate() } } commit(); - _status._totalUpdateTime += _timer.elapsed().ms(); + _status._totalUpdateTime += _timer.elapsed(); } @@ -283,7 +285,7 @@ template <typename Vector, typename T, typename BT> void AttributeUpdater<Vector, T, BT>::update(uint32_t numUpdates) { - _timer.restart(); + _timer = vespalib::Timer(); for (uint32_t i = 0; i < numUpdates; ++i) { uint32_t doc = getRandomDoc(); updateValues(doc); @@ -292,7 +294,7 @@ AttributeUpdater<Vector, T, BT>::update(uint32_t numUpdates) } } commit(); - _status._totalUpdateTime += _timer.elapsed().ms(); + _status._totalUpdateTime += _timer.elapsed(); } @@ -300,7 +302,7 @@ template <typename Vector, typename T, typename BT> void AttributeUpdaterThread<Vector, T, BT>::doRun() { - this->_timer.restart(); + this->_timer = vespalib::Timer(); while(!_done) { uint32_t doc = this->getRandomDoc(); this->updateValues(doc); @@ -309,9 +311,7 @@ AttributeUpdaterThread<Vector, T, BT>::doRun() } } this->commit(); - this->_status._totalUpdateTime += this->_timer.elapsed().ms(); + this->_status._totalUpdateTime += this->_timer.elapsed(); } - } // search - diff --git a/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp b/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp index 7526326b6ca..3e129457d46 100644 --- a/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp +++ b/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp @@ -46,7 +46,7 @@ TEST_F(SearchRequestTest, require_that_hits_is_converted) { TEST_F(SearchRequestTest, require_that_timeout_is_converted) { proto.set_timeout(500); convert(); - EXPECT_EQ(request.getTimeout().ms(), 500); + EXPECT_EQ(request.getTimeout(), 500ms); } TEST_F(SearchRequestTest, require_that_trace_level_is_converted) { @@ -317,7 +317,7 @@ TEST_F(DocsumRequestTest, require_that_root_slime_is_used) { TEST_F(DocsumRequestTest, require_that_timeout_is_converted) { proto.set_timeout(500); convert(); - EXPECT_EQ(request.getTimeout().ms(), 500); + EXPECT_EQ(request.getTimeout(), 500ms); } TEST_F(DocsumRequestTest, require_that_session_key_is_converted) { diff --git a/searchlib/src/tests/features/featurebenchmark.cpp b/searchlib/src/tests/features/featurebenchmark.cpp index 43b1e38f4a4..6e1c5b1487c 100644 --- a/searchlib/src/tests/features/featurebenchmark.cpp +++ b/searchlib/src/tests/features/featurebenchmark.cpp @@ -105,10 +105,10 @@ public: private: search::fef::BlueprintFactory _factory; - fastos::StopWatch _timer; - fastos::TimeStamp _sample; + vespalib::Timer _timer; + vespalib::duration _sample; - void start() { _timer.restart(); } + void start() { _timer = vespalib::Timer(); } void sample() { _sample = _timer.elapsed(); } void setupPropertyMap(Properties & props, const KeyValueVector & values); void runFieldMatch(Config & cfg); @@ -648,8 +648,8 @@ Benchmark::Main() std::cout << "feature case '" << cfg.getCase() << "' is not known" << std::endl; } - std::cout << "TET: " << _sample.ms() << " (ms)" << std::endl; - std::cout << "ETPD: " << std::fixed << std::setprecision(10) << _sample.ms() / cfg.getNumRuns() << " (ms)" << std::endl; + std::cout << "TET: " << vespalib::count_ms(_sample) << " (ms)" << std::endl; + std::cout << "ETPD: " << std::fixed << std::setprecision(10) << double(vespalib::count_ms(_sample)) / cfg.getNumRuns() << " (ms)" << std::endl; std::cout << "**** '" << cfg.getFeature() << "' ****" << std::endl; TEST_DONE(); diff --git a/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp b/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp index 8f22ab87c97..36a567e5675 100644 --- a/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp +++ b/searchlib/src/tests/groupingengine/groupingengine_benchmark.cpp @@ -277,7 +277,7 @@ Test::Main() LOG(info, "sizeof(CountAggregationResult) = %ld", sizeof(CountAggregationResult)); LOG(info, "sizeof(Int64ResultNode) = %ld", sizeof(Int64ResultNode)); - fastos::SteadyTimeStamp start(fastos::ClockSteady::now()); + vespalib::steady_time start(vespalib::steady_clock::now()); if (idType == "int") { if (aggrType == "sum") { benchmarkIntegerSum(useEngine, numDocs, numQueries, maxGroups); diff --git a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp index bf1b5352778..0743ac8408d 100644 --- a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp +++ b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp @@ -170,7 +170,7 @@ public: }; PhraseSearchTest::PhraseSearchTest(bool expiredDoom) - : _requestContext(nullptr, expiredDoom ? fastos::SteadyTimeStamp::ZERO : fastos::SteadyTimeStamp::FUTURE), + : _requestContext(nullptr, expiredDoom ? vespalib::steady_time(): vespalib::steady_time::max()), _index(), _phrase_fs(field, fieldId, phrase_handle), _phrase(_phrase_fs, _requestContext, false), @@ -199,7 +199,7 @@ void Test::requireThatIteratorHonorsFutureDoom() { test.fetchPostings(false); vespalib::Clock clock; - vespalib::Doom futureDoom(clock, fastos::SteadyTimeStamp::FUTURE); + vespalib::Doom futureDoom(clock, vespalib::steady_time::max()); unique_ptr<SearchIterator> search(test.createSearch(false)); static_cast<SimplePhraseSearch &>(*search).setDoom(&futureDoom); EXPECT_TRUE(!search->seek(1u)); @@ -213,7 +213,7 @@ void Test::requireThatIteratorHonorsDoom() { test.fetchPostings(false); vespalib::Clock clock; - vespalib::Doom futureDoom(clock, fastos::SteadyTimeStamp::ZERO); + vespalib::Doom futureDoom(clock, vespalib::steady_time()); unique_ptr<SearchIterator> search(test.createSearch(false)); static_cast<SimplePhraseSearch &>(*search).setDoom(&futureDoom); EXPECT_TRUE(!search->seek(1u)); diff --git a/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp b/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp index 7d2efc5f2bc..3b61aaaac3e 100644 --- a/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp +++ b/searchlib/src/tests/queryeval/sparse_vector_benchmark/sparse_vector_benchmark_test.cpp @@ -131,8 +131,8 @@ int Plot::_plots = 0; //----------------------------------------------------------------------------- -uint32_t default_weight = 100; -double max_time = 1000000.0; +constexpr uint32_t default_weight = 100; +constexpr vespalib::duration max_time = 1000s; //----------------------------------------------------------------------------- @@ -312,20 +312,20 @@ struct NegativeFilterAfterStrategy : FilterStrategy { //----------------------------------------------------------------------------- struct Result { - double time_ms; + vespalib::duration time; uint32_t num_hits; - Result() : time_ms(max_time), num_hits(0) {} - Result(double t, uint32_t n) : time_ms(t), num_hits(n) {} + Result() : time(max_time), num_hits(0) {} + Result(vespalib::duration t, uint32_t n) : time(t), num_hits(n) {} void combine(const Result &r) { - if (time_ms == max_time) { + if (time == max_time) { *this = r; } else { assert(num_hits == r.num_hits); - time_ms = std::min(time_ms, r.time_ms); + time = std::min(time, r.time); } } std::string toString() const { - return vespalib::make_string("%u hits, %g ms", num_hits, time_ms); + return vespalib::make_string("%u hits, %ld ms", num_hits, vespalib::count_ms(time)); } }; @@ -333,12 +333,12 @@ Result run_single_benchmark(FilterStrategy &filterStrategy, SparseVectorFactory SearchIterator::UP search(filterStrategy.createRoot(vectorFactory, childFactory, childCnt, limit)); SearchIterator &sb = *search; uint32_t num_hits = 0; - fastos::StopWatch timer; + vespalib::Timer timer; for (sb.seek(1); !sb.isAtEnd(); sb.seek(sb.getDocId() + 1)) { ++num_hits; sb.unpack(sb.getDocId()); } - return Result(timer.elapsed().ms(), num_hits); + return Result(timer.elapsed(), num_hits); } //----------------------------------------------------------------------------- @@ -371,7 +371,7 @@ public: for (int j = 0; j < 5; ++j) { result.combine(run_single_benchmark(_filterStrategy, svf, _childFactory, childCnt, _limit)); } - graph->addValue(childCnt, result.time_ms); + graph->addValue(childCnt, vespalib::count_ms(result.time)); fprintf(stderr, " %u children => %s\n", childCnt, result.toString().c_str()); } } diff --git a/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp b/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp index 65890f81e16..576c9abe249 100644 --- a/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp +++ b/searchlib/src/tests/queryeval/weak_and/wand_bench_setup.hpp @@ -187,22 +187,21 @@ struct FilterFactory : WandFactory { struct Setup { Stats stats; - double minTimeMs; - Setup() : stats(), minTimeMs(10000000.0) {} + vespalib::duration minTime; + Setup() : stats(), minTime(10000s) {} virtual ~Setup() {} virtual std::string name() const = 0; virtual SearchIterator::UP create() = 0; void perform() { SearchIterator::UP search = create(); SearchIterator &sb = *search; - fastos::StopWatch timer; + vespalib::Timer timer; for (sb.seek(1); !sb.isAtEnd(); sb.seek(sb.getDocId() + 1)) { stats.hit(); sb.unpack(sb.getDocId()); } - double ms = timer.elapsed().ms(); - if (ms < minTimeMs) { - minTimeMs = ms; + if (timer.elapsed() < minTime) { + minTime = timer.elapsed(); } } void benchmark() { @@ -213,7 +212,7 @@ struct Setup { stats.print(); } } - fprintf(stderr, "time (ms): %g\n", minTimeMs); + fprintf(stderr, "time (ms): %ld\n", vespalib::count_ms(minTime)); } }; diff --git a/searchlib/src/tests/sortspec/multilevelsort.cpp b/searchlib/src/tests/sortspec/multilevelsort.cpp index 640e6f45e80..8c4b931a265 100644 --- a/searchlib/src/tests/sortspec/multilevelsort.cpp +++ b/searchlib/src/tests/sortspec/multilevelsort.cpp @@ -241,7 +241,7 @@ MultilevelSortTest::sortAndCheck(const std::vector<Spec> &spec, uint32_t num, } vespalib::Clock clock; - vespalib::Doom doom(clock, fastos::SteadyTimeStamp::FUTURE); + vespalib::Doom doom(clock, vespalib::steady_time::max()); search::uca::UcaConverterFactory ucaFactory; FastS_SortSpec sorter(7, doom, ucaFactory, _sortMethod); // init sorter with sort data @@ -263,9 +263,9 @@ MultilevelSortTest::sortAndCheck(const std::vector<Spec> &spec, uint32_t num, } } - fastos::StopWatch timer; + vespalib::Timer timer; sorter.sortResults(hits, num, num); - LOG(info, "sort time = %ld ms", timer.elapsed().ms()); + LOG(info, "sort time = %ld ms", vespalib::count_ms(timer.elapsed())); uint32_t *offsets = new uint32_t[num + 1]; char *buf = new char[sorter.getSortDataSize(0, num)]; @@ -398,7 +398,7 @@ TEST("require that all sort methods behave the same") TEST("test that [docid] translates to [lid][paritionid]") { vespalib::Clock clock; - vespalib::Doom doom(clock, fastos::SteadyTimeStamp::FUTURE); + vespalib::Doom doom(clock, vespalib::steady_time::max()); search::uca::UcaConverterFactory ucaFactory; FastS_SortSpec asc(7, doom, ucaFactory); RankedHit hits[2] = {RankedHit(91, 0.0), RankedHit(3, 2.0)}; diff --git a/searchlib/src/vespa/searchlib/aggregation/grouping.cpp b/searchlib/src/vespa/searchlib/aggregation/grouping.cpp index 5c93fb4161c..4ad8e0089d9 100644 --- a/searchlib/src/vespa/searchlib/aggregation/grouping.cpp +++ b/searchlib/src/vespa/searchlib/aggregation/grouping.cpp @@ -115,8 +115,8 @@ Grouping::Grouping() _lastLevel(0), _levels(), _root(), - _clock(NULL), - _timeOfDoom(0) + _clock(nullptr), + _timeOfDoom(vespalib::duration::zero()) { } diff --git a/searchlib/src/vespa/searchlib/aggregation/grouping.h b/searchlib/src/vespa/searchlib/aggregation/grouping.h index 4230bd777d6..249262438da 100644 --- a/searchlib/src/vespa/searchlib/aggregation/grouping.h +++ b/searchlib/src/vespa/searchlib/aggregation/grouping.h @@ -31,7 +31,7 @@ private: GroupingLevelList _levels; // grouping parameters per level Group _root; // the grouping tree const vespalib::Clock *_clock; // An optional clock to be used for timeout handling. - fastos::SteadyTimeStamp _timeOfDoom; // Used if clock is specified. This is time when request expires. + vespalib::steady_time _timeOfDoom; // Used if clock is specified. This is time when request expires. bool hasExpired() const { return _clock->getTimeNS() > _timeOfDoom; } void aggregateWithoutClock(const RankedHit * rankedHit, unsigned int len); @@ -59,7 +59,7 @@ public: Grouping &addLevel(GroupingLevel && level) { _levels.push_back(std::move(level)); return *this; } Grouping &setRoot(const Group &root_) { _root = root_; return *this; } Grouping &setClock(const vespalib::Clock * clock) { _clock = clock; return *this; } - Grouping &setTimeOfDoom(fastos::SteadyTimeStamp timeOfDoom) { _timeOfDoom = timeOfDoom; return *this; } + Grouping &setTimeOfDoom(vespalib::steady_time timeOfDoom) { _timeOfDoom = timeOfDoom; return *this; } unsigned int getId() const { return _id; } bool valid() const { return _valid; } diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp index e79db2fae11..4c060c5fab8 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.cpp +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.cpp @@ -136,9 +136,9 @@ AttributeVector::~AttributeVector() = default; void AttributeVector::updateStat(bool force) { if (force) { onUpdateStat(); - } else if (_nextStatUpdateTime < fastos::ClockSteady::now()) { + } else if (_nextStatUpdateTime < vespalib::steady_clock::now()) { onUpdateStat(); - _nextStatUpdateTime = fastos::ClockSteady::now() + fastos::TimeStamp(5ul * fastos::TimeStamp::SEC); + _nextStatUpdateTime = vespalib::steady_clock::now() + 5s; } } diff --git a/searchlib/src/vespa/searchlib/attribute/attributevector.h b/searchlib/src/vespa/searchlib/attribute/attributevector.h index d45cd995ea5..48ef8257329 100644 --- a/searchlib/src/vespa/searchlib/attribute/attributevector.h +++ b/searchlib/src/vespa/searchlib/attribute/attributevector.h @@ -20,7 +20,7 @@ #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/address_space.h> #include <vespa/vespalib/util/rcuvector.h> -#include <vespa/fastos/timestamp.h> +#include <vespa/vespalib/util/time.h> #include <cmath> #include <mutex> #include <shared_mutex> @@ -587,7 +587,7 @@ private: uint64_t _compactLidSpaceGeneration; bool _hasEnum; bool _loaded; - fastos::SteadyTimeStamp _nextStatUpdateTime; + vespalib::steady_time _nextStatUpdateTime; ////// Locking strategy interface. only available from the Guards. /** diff --git a/searchlib/src/vespa/searchlib/engine/proto_converter.cpp b/searchlib/src/vespa/searchlib/engine/proto_converter.cpp index 2495a6e12bd..e5846734a8d 100644 --- a/searchlib/src/vespa/searchlib/engine/proto_converter.cpp +++ b/searchlib/src/vespa/searchlib/engine/proto_converter.cpp @@ -52,7 +52,7 @@ ProtoConverter::search_request_from_proto(const ProtoSearchRequest &proto, Searc { request.offset = proto.offset(); request.maxhits = proto.hits(); - request.setTimeout(fastos::TimeStamp::Seconds(0.001 * proto.timeout())); + request.setTimeout(1ms * proto.timeout()); request.setTraceLevel(proto.trace_level()); request.sortSpec = make_sort_spec(proto.sorting()); request.sessionId.assign(proto.session_key().begin(), proto.session_key().end()); @@ -111,7 +111,7 @@ ProtoConverter::search_reply_to_proto(const SearchReply &reply, ProtoSearchReply void ProtoConverter::docsum_request_from_proto(const ProtoDocsumRequest &proto, DocsumRequest &request) { - request.setTimeout(fastos::TimeStamp::Seconds(0.001 * proto.timeout())); + request.setTimeout(1ms * proto.timeout()); request.sessionId.assign(proto.session_key().begin(), proto.session_key().end()); request.propertiesMap.lookupCreate(MapNames::MATCH).add("documentdb.searchdoctype", proto.document_type()); request.resultClassName = proto.summary_class(); diff --git a/searchlib/src/vespa/searchlib/engine/proto_rpc_adapter.cpp b/searchlib/src/vespa/searchlib/engine/proto_rpc_adapter.cpp index 4fa7079fe46..4634c192a51 100644 --- a/searchlib/src/vespa/searchlib/engine/proto_rpc_adapter.cpp +++ b/searchlib/src/vespa/searchlib/engine/proto_rpc_adapter.cpp @@ -115,7 +115,7 @@ struct SearchCompletionHandler : SearchClient { encode_search_reply(msg, *req.GetReturn()); stats.reply_size = (*req.GetReturn())[2]._data._len; if (reply->request) { - stats.latency = reply->request->getTimeUsed().sec(); + stats.latency = vespalib::to_s(reply->request->getTimeUsed()); metrics.update_query_metrics(stats); } req.Return(); @@ -161,7 +161,7 @@ struct GetDocsumsCompletionHandler : DocsumClient { encode_message(msg, *req.GetReturn()); stats.reply_size = (*req.GetReturn())[2]._data._len; if (reply->request) { - stats.latency = reply->request->getTimeUsed().sec(); + stats.latency = vespalib::to_s(reply->request->getTimeUsed()); metrics.update_docsum_metrics(stats); } req.Return(); diff --git a/searchlib/src/vespa/searchlib/engine/request.cpp b/searchlib/src/vespa/searchlib/engine/request.cpp index 84615105579..cb00dfcf09b 100644 --- a/searchlib/src/vespa/searchlib/engine/request.cpp +++ b/searchlib/src/vespa/searchlib/engine/request.cpp @@ -6,7 +6,7 @@ namespace search::engine { Request::Request(RelativeTime relativeTime) : _relativeTime(std::move(relativeTime)), - _timeOfDoom(fastos::TimeStamp(fastos::TimeStamp::FUTURE)), + _timeOfDoom(vespalib::steady_time::max()), dumpFeatures(false), ranking(), location(), @@ -19,17 +19,17 @@ Request::Request(RelativeTime relativeTime) Request::~Request() = default; -void Request::setTimeout(const fastos::TimeStamp & timeout) +void Request::setTimeout(vespalib::duration timeout) { _timeOfDoom = getStartTime() + timeout; } -fastos::TimeStamp Request::getTimeUsed() const +vespalib::duration Request::getTimeUsed() const { return _relativeTime.timeSinceDawn(); } -fastos::TimeStamp Request::getTimeLeft() const +vespalib::duration Request::getTimeLeft() const { return _timeOfDoom - _relativeTime.now(); } diff --git a/searchlib/src/vespa/searchlib/engine/request.h b/searchlib/src/vespa/searchlib/engine/request.h index 4f4bf526920..ef90e38dc3d 100644 --- a/searchlib/src/vespa/searchlib/engine/request.h +++ b/searchlib/src/vespa/searchlib/engine/request.h @@ -4,7 +4,6 @@ #include "propertiesmap.h" #include "trace.h" -#include <vespa/fastos/timestamp.h> namespace search::engine { @@ -15,14 +14,14 @@ public: Request(const Request &) = delete; Request & operator =(const Request &) = delete; virtual ~Request(); - void setTimeout(const fastos::TimeStamp & timeout); - fastos::SteadyTimeStamp getStartTime() const { return _relativeTime.timeOfDawn(); } - fastos::SteadyTimeStamp getTimeOfDoom() const { return _timeOfDoom; } - fastos::TimeStamp getTimeout() const { return _timeOfDoom - getStartTime(); } - fastos::TimeStamp getTimeUsed() const; - fastos::TimeStamp getTimeLeft() const; + void setTimeout(vespalib::duration timeout); + vespalib::steady_time getStartTime() const { return _relativeTime.timeOfDawn(); } + vespalib::steady_time getTimeOfDoom() const { return _timeOfDoom; } + vespalib::duration getTimeout() const { return _timeOfDoom - getStartTime(); } + vespalib::duration getTimeUsed() const; + vespalib::duration getTimeLeft() const; const RelativeTime & getRelativeTime() const { return _relativeTime; } - bool expired() const { return getTimeLeft() <= 0l; } + bool expired() const { return getTimeLeft() <= vespalib::duration::zero(); } const vespalib::stringref getStackRef() const { return vespalib::stringref(&stackDump[0], stackDump.size()); @@ -37,8 +36,8 @@ public: Trace & trace() const { return _trace; } private: - RelativeTime _relativeTime; - fastos::SteadyTimeStamp _timeOfDoom; + RelativeTime _relativeTime; + vespalib::steady_time _timeOfDoom; public: /// Everything here should move up to private section and have accessors bool dumpFeatures; diff --git a/searchlib/src/vespa/searchlib/engine/trace.cpp b/searchlib/src/vespa/searchlib/engine/trace.cpp index ae0c6810ca1..95d6c967369 100644 --- a/searchlib/src/vespa/searchlib/engine/trace.cpp +++ b/searchlib/src/vespa/searchlib/engine/trace.cpp @@ -2,12 +2,13 @@ #include "trace.h" #include <vespa/vespalib/data/slime/slime.h> +#include <vespa/fastos/timestamp.h> namespace search::engine { -fastos::SteadyTimeStamp +vespalib::steady_time SteadyClock::now() const { - return fastos::ClockSteady::now(); + return vespalib::steady_clock::now(); } RelativeTime::RelativeTime(std::unique_ptr<Clock> clock) @@ -36,9 +37,12 @@ Trace::Trace(const RelativeTime & relativeTime, uint32_t level) } void -Trace::start(int level) { +Trace::start(int level, bool useUTC) { if (shouldTrace(level) && !hasTrace()) { - root().setString("start_time_relative", _relativeTime.timeOfDawn().toString()); + vespalib::duration since_epoch = useUTC + ? vespalib::to_utc(_relativeTime.timeOfDawn()).time_since_epoch() + : _relativeTime.timeOfDawn().time_since_epoch(); + root().setString("start_time", fastos::TimeStamp::asString(vespalib::to_s(since_epoch))); } } @@ -68,13 +72,13 @@ Trace::addEvent(uint32_t level, vespalib::stringref event) { void Trace::addTimeStamp(Cursor & trace) { - trace.setDouble("timestamp_ms", _relativeTime.timeSinceDawn()/1000000.0); + trace.setDouble("timestamp_ms", vespalib::count_ns(_relativeTime.timeSinceDawn())/1000000.0); } void Trace::done() { if (!hasTrace()) { return; } - root().setDouble("duration_ms", _relativeTime.timeSinceDawn()/1000000.0); + root().setDouble("duration_ms", vespalib::count_ns(_relativeTime.timeSinceDawn())/1000000.0); } vespalib::string diff --git a/searchlib/src/vespa/searchlib/engine/trace.h b/searchlib/src/vespa/searchlib/engine/trace.h index 0d7dc2982f1..4076f0a3daa 100644 --- a/searchlib/src/vespa/searchlib/engine/trace.h +++ b/searchlib/src/vespa/searchlib/engine/trace.h @@ -3,7 +3,7 @@ #pragma once #include <vespa/vespalib/stllike/string.h> -#include <vespa/fastos/timestamp.h> +#include <vespa/vespalib/util/time.h> namespace vespalib { class Slime; } namespace vespalib::slime { struct Cursor; } @@ -13,21 +13,21 @@ namespace search::engine { class Clock { public: virtual ~Clock() = default; - virtual fastos::SteadyTimeStamp now() const = 0; + virtual vespalib::steady_time now() const = 0; }; class SteadyClock : public Clock { public: - fastos::SteadyTimeStamp now() const override; + vespalib::steady_time now() const override; }; class CountingClock : public Clock { public: CountingClock(int64_t start, int64_t increment) : _increment(increment), _nextTime(start) { } - fastos::SteadyTimeStamp now() const override { + vespalib::steady_time now() const override { int64_t prev = _nextTime; _nextTime += _increment; - return fastos::SteadyTimeStamp(prev); + return vespalib::steady_time(vespalib::duration(prev)); } private: const int64_t _increment; @@ -37,11 +37,11 @@ private: class RelativeTime { public: RelativeTime(std::unique_ptr<Clock> clock); - fastos::SteadyTimeStamp timeOfDawn() const { return _start; } - fastos::TimeStamp timeSinceDawn() const { return _clock->now() - _start; } - fastos::SteadyTimeStamp now() const { return _clock->now(); } + vespalib::steady_time timeOfDawn() const { return _start; } + vespalib::duration timeSinceDawn() const { return _clock->now() - _start; } + vespalib::steady_time now() const { return _clock->now(); } private: - fastos::SteadyTimeStamp _start; + vespalib::steady_time _start; std::unique_ptr<Clock> _clock; }; @@ -60,7 +60,7 @@ public: * Will add start timestamp if level is high enough * @param level */ - void start(int level); + void start(int level, bool useUTC=true); /** * Will give you a trace entry. It will also add a timestamp relative to the creation of the trace. diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp index 9af6d7024a2..28af2c14781 100644 --- a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp @@ -1,10 +1,10 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/searchlib/queryeval/fake_requestcontext.h> +#include "fake_requestcontext.h" namespace search::queryeval { -FakeRequestContext::FakeRequestContext(attribute::IAttributeContext * context, fastos::SteadyTimeStamp softDoom, fastos::SteadyTimeStamp hardDoom) +FakeRequestContext::FakeRequestContext(attribute::IAttributeContext * context, vespalib::steady_time softDoom, vespalib::steady_time hardDoom) : _clock(), _doom(_clock, softDoom, hardDoom, false), _attributeContext(context), diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h index 184e0f7faf8..3de464224f9 100644 --- a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h +++ b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h @@ -17,8 +17,8 @@ class FakeRequestContext : public IRequestContext { public: FakeRequestContext(attribute::IAttributeContext * context = nullptr, - fastos::SteadyTimeStamp soft=fastos::SteadyTimeStamp::FUTURE, - fastos::SteadyTimeStamp hard=fastos::SteadyTimeStamp::FUTURE); + vespalib::steady_time soft=vespalib::steady_time::max(), + vespalib::steady_time hard=vespalib::steady_time::max()); ~FakeRequestContext(); const vespalib::Doom & getDoom() const override { return _doom; } const attribute::IAttributeVector *getAttribute(const vespalib::string &name) const override { |