diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-01 05:42:38 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-03 11:39:52 +0000 |
commit | 64c08801e0ac5094fb111c5fe3ea63cc7597506d (patch) | |
tree | a34f000d2743b864e22e322d9ce94b655c86ac97 /searchlib | |
parent | 6f78fdc9750ad3ac03b14166b6838c628487458c (diff) |
Let the InvocationService drive the clock instead of having its own ticking loop.
Also use sleep_until to get intervals indendant of invoke cost as long as cost is within interval.
This also also saves a clock sample and simplifies implementation.
Diffstat (limited to 'searchlib')
4 files changed, 16 insertions, 15 deletions
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 8879d591f5a..4877072eacd 100644 --- a/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp +++ b/searchlib/src/tests/queryeval/simple_phrase/simple_phrase_test.cpp @@ -9,6 +9,7 @@ #include <vespa/searchlib/fef/matchdatalayout.h> #include <vespa/searchlib/query/tree/simplequery.h> #include <vespa/searchlib/query/weight.h> +#include <vespa/vespalib/util/testclock.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/log/log.h> @@ -211,8 +212,8 @@ void Test::requireThatIteratorHonorsFutureDoom() { test.addTerm("foo", 0).addTerm("bar", 1); test.fetchPostings(false); - vespalib::Clock clock; - vespalib::Doom futureDoom(clock, vespalib::steady_time::max()); + vespalib::TestClock clock; + vespalib::Doom futureDoom(clock.clock(), vespalib::steady_time::max()); unique_ptr<SearchIterator> search(test.createSearch(false)); static_cast<SimplePhraseSearch &>(*search).setDoom(&futureDoom); EXPECT_TRUE(!search->seek(1u)); @@ -225,8 +226,8 @@ void Test::requireThatIteratorHonorsDoom() { test.addTerm("foo", 0).addTerm("bar", 1); test.fetchPostings(false); - vespalib::Clock clock; - vespalib::Doom futureDoom(clock, vespalib::steady_time()); + vespalib::TestClock clock; + vespalib::Doom futureDoom(clock.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/sortspec/multilevelsort.cpp b/searchlib/src/tests/sortspec/multilevelsort.cpp index 576e1d1336c..88b105ec80c 100644 --- a/searchlib/src/tests/sortspec/multilevelsort.cpp +++ b/searchlib/src/tests/sortspec/multilevelsort.cpp @@ -7,6 +7,7 @@ #include <vespa/searchlib/attribute/attributecontext.h> #include <vespa/searchlib/attribute/attributemanager.h> #include <vespa/searchlib/uca/ucaconverter.h> +#include <vespa/vespalib/util/testclock.h> #include <vespa/vespalib/testkit/testapp.h> #include <vespa/log/log.h> LOG_SETUP("multilevelsort_test"); @@ -14,13 +15,9 @@ LOG_SETUP("multilevelsort_test"); using namespace search; typedef FastS_SortSpec::VectorRef VectorRef; -typedef IntegerAttributeTemplate<uint8_t> Uint8; typedef IntegerAttributeTemplate<int8_t> Int8; -typedef IntegerAttributeTemplate<uint16_t> Uint16; typedef IntegerAttributeTemplate<int16_t> Int16; -typedef IntegerAttributeTemplate<uint32_t> Uint32; typedef IntegerAttributeTemplate<int32_t> Int32; -typedef IntegerAttributeTemplate<uint64_t> Uint64; typedef IntegerAttributeTemplate<int64_t> Int64; typedef FloatingPointAttributeTemplate<float> Float; typedef FloatingPointAttributeTemplate<double> Double; @@ -239,8 +236,8 @@ MultilevelSortTest::sortAndCheck(const std::vector<Spec> &spec, uint32_t num, hits[i]._rankValue = getRandomValue<uint32_t>(); } - vespalib::Clock clock; - vespalib::Doom doom(clock, vespalib::steady_time::max()); + vespalib::TestClock clock; + vespalib::Doom doom(clock.clock(), vespalib::steady_time::max()); search::uca::UcaConverterFactory ucaFactory; FastS_SortSpec sorter(7, doom, ucaFactory, _sortMethod); // init sorter with sort data @@ -396,8 +393,8 @@ TEST("require that all sort methods behave the same") } TEST("test that [docid] translates to [lid][paritionid]") { - vespalib::Clock clock; - vespalib::Doom doom(clock, vespalib::steady_time::max()); + vespalib::TestClock clock; + vespalib::Doom doom(clock.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/queryeval/fake_requestcontext.cpp b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp index ea4cbf84550..a123d3f6cd1 100644 --- a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.cpp @@ -1,12 +1,14 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "fake_requestcontext.h" +#include <vespa/vespalib/util/testclock.h> + namespace search::queryeval { FakeRequestContext::FakeRequestContext(attribute::IAttributeContext * context, vespalib::steady_time softDoom, vespalib::steady_time hardDoom) - : _clock(), - _doom(_clock, softDoom, hardDoom, false), + : _clock(std::make_unique<vespalib::TestClock>()), + _doom(_clock->clock(), softDoom, hardDoom, false), _attributeContext(context), _query_tensor_name(), _query_tensor(), diff --git a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h index 25a4fa559e0..a492f055cdb 100644 --- a/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h +++ b/searchlib/src/vespa/searchlib/queryeval/fake_requestcontext.h @@ -13,6 +13,7 @@ #include <vespa/vespalib/util/doom.h> #include <limits> +namespace vespalib { class TestClock; } namespace search::queryeval { class FakeRequestContext : public IRequestContext @@ -47,7 +48,7 @@ public: const search::attribute::AttributeBlueprintParams& get_attribute_blueprint_params() const override; private: - vespalib::Clock _clock; + std::unique_ptr<vespalib::TestClock> _clock; const vespalib::Doom _doom; attribute::IAttributeContext *_attributeContext; vespalib::string _query_tensor_name; |