diff options
author | HÃ¥vard Pettersen <3535158+havardpe@users.noreply.github.com> | 2022-08-26 13:06:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-26 13:06:05 +0200 |
commit | 3604078ee2f7ea417d9da734b5427beea03e5d90 (patch) | |
tree | 96910fe7ec8d0677f0a9829c3378a357d41170ae | |
parent | df36b8b28ce30d81eadf194e37ff6c8b9eed60e1 (diff) | |
parent | 87e97aeb92045bc496b91156c49cdeb306c50dc9 (diff) |
Merge pull request #23795 from vespa-engine/balder/wire-in-profile-depth
Wire in profile_depth
12 files changed, 31 insertions, 19 deletions
diff --git a/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp b/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp index be17c39f542..2120028b5ea 100644 --- a/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp +++ b/searchcore/src/tests/proton/matching/match_phase_limiter/match_phase_limiter_test.cpp @@ -291,7 +291,7 @@ TEST("require that the match phase limiter is able to pre-limit the query") { EXPECT_TRUE(limiter.is_enabled()); EXPECT_EQUAL(12u, limiter.sample_hits_per_thread(10)); RelativeTime clock(std::make_unique<CountingClock>(vespalib::count_ns(10000000s), 1700000L)); - Trace trace(clock, 7); + Trace trace(clock, 7, 0); trace.start(4, false); SearchIterator::UP search = limiter.maybe_limit(prepare(new MockSearch("search")), 0.1, 100000, trace.maybeCreateCursor(7, "limit")); limiter.updateDocIdSpaceEstimate(1000, 9000); diff --git a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp index d4de7ed6940..c03ed371c4b 100644 --- a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp +++ b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp @@ -115,7 +115,7 @@ MatchEngine::search(search::engine::SearchRequest::Source request, } if (_async) { _executor.execute(std::make_unique<SearchTask>(*this, std::move(request), client)); - return search::engine::SearchReply::UP(); + return {}; } return performSearch(std::move(request)); } @@ -131,7 +131,8 @@ MatchEngine::performSearch(search::engine::SearchRequest::Source req) const search::engine::SearchRequest * searchRequest = req.get(); if (searchRequest) { // 3 is the minimum level required for backend tracing. - searchRequest->setTraceLevel(search::fef::indexproperties::trace::Level::lookup(searchRequest->propertiesMap.modelOverrides(), searchRequest->getTraceLevel()), 3); + searchRequest->setTraceLevel(search::fef::indexproperties::trace::Level::lookup(searchRequest->propertiesMap.modelOverrides(), + searchRequest->trace().getLevel()), 3); ISearchHandler::SP searchHandler; vespalib::SimpleThreadBundle::UP threadBundle = _threadBundlePool.obtain(); { // try to find the match handler corresponding to the specified search doc type diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp index 84ff0672fa0..427d4507c43 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp @@ -95,7 +95,7 @@ MatchMaster::match(search::engine::Trace & trace, : static_cast<IMatchLoopCommunicator&>(communicator); threadState.emplace_back(std::make_unique<MatchThread>(i, threadBundle.size(), params, mtf, com, *scheduler, resultProcessor, mergeDirector, distributionKey, - trace.getRelativeTime(), trace.getLevel())); + trace.getRelativeTime(), trace.getLevel(), trace.getProfileDepth())); targets.push_back(threadState.back().get()); } resultProcessor.prepareThreadContextCreation(threadBundle.size()); diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp index a6e4e366f7f..858c25f0dd2 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.cpp @@ -396,7 +396,8 @@ MatchThread::MatchThread(size_t thread_id_in, vespalib::DualMergeDirector &md, uint32_t distributionKey, const RelativeTime & relativeTime, - uint32_t traceLevel) : + uint32_t traceLevel, + uint32_t profileDepth) : thread_id(thread_id_in), num_threads(num_threads_in), matchParams(mp), @@ -413,7 +414,7 @@ MatchThread::MatchThread(size_t thread_id_in, match_time_s(0.0), wait_time_s(0.0), match_with_ranking(mtf.has_first_phase_rank() && mp.save_rank_scores()), - trace(std::make_unique<Trace>(relativeTime, traceLevel)), + trace(std::make_unique<Trace>(relativeTime, traceLevel, profileDepth)), my_issues() { } diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_thread.h b/searchcore/src/vespa/searchcore/proton/matching/match_thread.h index 524dbfd4b39..7e74f4d4ef4 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_thread.h +++ b/searchcore/src/vespa/searchcore/proton/matching/match_thread.h @@ -128,7 +128,8 @@ public: vespalib::DualMergeDirector &md, uint32_t distributionKey, const RelativeTime & relativeTime, - uint32_t traceLevel); + uint32_t traceLevel, + uint32_t profileDepth); void run() override; const MatchingStats::Partition &get_thread_stats() const { return thread_stats; } double get_match_time() const { return match_time_s; } diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp index 4a0f4e7ae8b..e856478adfd 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.cpp @@ -182,7 +182,7 @@ MatchToolsFactory(QueryLimiter & queryLimiter, _diversityParams(), _valid(false) { - search::engine::Trace trace(root_trace.getRelativeTime(), root_trace.getLevel()); + search::engine::Trace trace(root_trace.getRelativeTime(), root_trace.getLevel(), root_trace.getProfileDepth()); trace.addEvent(4, "Start query setup"); _query.setWhiteListBlueprint(metaStore.createWhiteListBlueprint()); trace.addEvent(5, "Deserialize and build query tree"); 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 093e7831ad4..14ef77a4161 100644 --- a/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp +++ b/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp @@ -63,7 +63,13 @@ TEST_F(SearchRequestTest, require_that_timeout_is_converted) { TEST_F(SearchRequestTest, require_that_trace_level_is_converted) { proto.set_trace_level(9); convert(); - EXPECT_EQ(request.getTraceLevel(), 9); + EXPECT_EQ(request.trace().getLevel(), 9); +} + +TEST_F(SearchRequestTest, require_that_profile_depth_is_converted) { + proto.set_profile_depth(7); + convert(); + EXPECT_EQ(request.trace().getProfileDepth(), 7); } TEST_F(SearchRequestTest, require_that_sorting_is_converted) { diff --git a/searchlib/src/vespa/searchlib/engine/proto_converter.cpp b/searchlib/src/vespa/searchlib/engine/proto_converter.cpp index 4eaa5b3eb65..c6f28e8755e 100644 --- a/searchlib/src/vespa/searchlib/engine/proto_converter.cpp +++ b/searchlib/src/vespa/searchlib/engine/proto_converter.cpp @@ -57,7 +57,8 @@ ProtoConverter::search_request_from_proto(const ProtoSearchRequest &proto, Searc request.offset = proto.offset(); request.maxhits = proto.hits(); request.setTimeout(1ms * proto.timeout()); - request.setTraceLevel(proto.trace_level()); + request.trace().setLevel(proto.trace_level()); + request.trace().setProfileDepth(proto.profile_depth()); request.sortSpec = make_sort_spec(proto.sorting()); request.sessionId.assign(proto.session_key().begin(), proto.session_key().end()); request.propertiesMap.lookupCreate(MapNames::MATCH).add("documentdb.searchdoctype", proto.document_type()); @@ -114,7 +115,7 @@ ProtoConverter::search_reply_to_proto(const SearchReply &reply, ProtoSearchReply hit->set_sort_data(&reply.sortData[sort_data_offset], sort_data_size); } } - if (reply.match_features.values.size() > 0) { + if ( ! reply.match_features.values.empty()) { size_t num_match_features = reply.match_features.names.size(); assert(num_match_features * reply.hits.size() == reply.match_features.values.size()); for (const auto & name : reply.match_features.names) { diff --git a/searchlib/src/vespa/searchlib/engine/request.cpp b/searchlib/src/vespa/searchlib/engine/request.cpp index e4ab55fcacf..d88d3740f07 100644 --- a/searchlib/src/vespa/searchlib/engine/request.cpp +++ b/searchlib/src/vespa/searchlib/engine/request.cpp @@ -16,7 +16,7 @@ Request::Request(RelativeTime relativeTime, uint32_t reservePropMaps) location(), propertiesMap(reservePropMaps), stackDump(), - _trace(_relativeTime, 0) + _trace(_relativeTime, 0, 0) { } diff --git a/searchlib/src/vespa/searchlib/engine/request.h b/searchlib/src/vespa/searchlib/engine/request.h index 27ca744a982..b7a5e4f952e 100644 --- a/searchlib/src/vespa/searchlib/engine/request.h +++ b/searchlib/src/vespa/searchlib/engine/request.h @@ -31,8 +31,6 @@ public: _trace.setLevel(level); _trace.start(minLevel); } - Request & setTraceLevel(uint32_t level) { _trace.setLevel(level); return *this; } - uint32_t getTraceLevel() const { return _trace.getLevel(); } Trace & trace() const { return _trace; } private: diff --git a/searchlib/src/vespa/searchlib/engine/trace.cpp b/searchlib/src/vespa/searchlib/engine/trace.cpp index 39beffc2a0d..649823e7ec1 100644 --- a/searchlib/src/vespa/searchlib/engine/trace.cpp +++ b/searchlib/src/vespa/searchlib/engine/trace.cpp @@ -26,12 +26,13 @@ Trace::constructTraces() const { _traces = & root().setArray("traces"); } -Trace::Trace(const RelativeTime & relativeTime, uint32_t level) +Trace::Trace(const RelativeTime & relativeTime, uint32_t level, uint32_t profileDepth) : _trace(), _root(nullptr), _traces(nullptr), _relativeTime(relativeTime), - _level(level) + _level(level), + _profileDepth(profileDepth) { } diff --git a/searchlib/src/vespa/searchlib/engine/trace.h b/searchlib/src/vespa/searchlib/engine/trace.h index 709dc05d93c..a9107787bc5 100644 --- a/searchlib/src/vespa/searchlib/engine/trace.h +++ b/searchlib/src/vespa/searchlib/engine/trace.h @@ -54,7 +54,7 @@ class Trace { public: using Cursor = vespalib::slime::Cursor; - Trace(const RelativeTime & relativeTime, uint32_t traceLevel=0); + Trace(const RelativeTime & relativeTime, uint32_t traceLevel, uint32_t profileDepth); ~Trace(); /** @@ -90,6 +90,8 @@ public: bool shouldTrace(uint32_t level) const { return level <= _level; } uint32_t getLevel() const { return _level; } Trace & setLevel(uint32_t level) { _level = level; return *this; } + Trace & setProfileDepth(uint32_t depth) { _profileDepth = depth; return *this; } + uint32_t getProfileDepth() const { return _profileDepth; } const RelativeTime & getRelativeTime() const { return _relativeTime; } private: vespalib::Slime & slime() const { @@ -114,10 +116,11 @@ private: void constructTraces() const; void addTimeStamp(Cursor & trace); mutable std::unique_ptr<vespalib::Slime> _trace; - mutable Cursor * _root; - mutable Cursor * _traces; + mutable Cursor * _root; + mutable Cursor * _traces; const RelativeTime & _relativeTime; uint32_t _level; + uint32_t _profileDepth; }; } |