diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-03-05 12:15:01 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-03-05 12:17:05 +0000 |
commit | 4869f87c3e5e175f118a68ed24c73c1ccbb72771 (patch) | |
tree | 3e8718d491624f9bf783c2f6f65ef1684f2c0050 | |
parent | 885a066cfdddfd8c0c1edb23c754171f0d6e0ed6 (diff) |
Trace the optimized blueprint.
3 files changed, 16 insertions, 1 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_tools.h b/searchcore/src/vespa/searchcore/proton/matching/match_tools.h index 0ecf6eb5b78..dfef51bfc5e 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/match_tools.h +++ b/searchcore/src/vespa/searchcore/proton/matching/match_tools.h @@ -132,6 +132,7 @@ public: std::unique_ptr<AttributeOperationTask> createOnSummaryTask() const; const RequestContext & requestContext() const { return _requestContext; } + const Query & query() const { return _query; } }; } diff --git a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp index 382e197c16b..4ebf74c373f 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/matcher.cpp @@ -14,6 +14,7 @@ #include <vespa/searchlib/engine/searchreply.h> #include <vespa/searchlib/features/setup.h> #include <vespa/searchlib/fef/test/plugin/setup.h> +#include <vespa/vespalib/data/slime/inserter.h> #include <vespa/log/log.h> LOG_SETUP(".proton.matching.matcher"); @@ -203,6 +204,17 @@ Matcher::computeNumThreadsPerSearch(Blueprint::HitEstimate hits, const Propertie return threads; } +namespace { + void traceQuery(const SearchRequest &request, const Query & query) { + if (request.getTraceLevel() > 3) { + if (query.peekRoot()) { + vespalib::slime::ObjectInserter inserter(request.trace().createCursor("blueprint"), "optimized"); + query.peekRoot()->asSlime(inserter); + } + } + } +} + SearchReply::UP Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundle, ISearchContext &searchContext, IAttributeContext &attrContext, SessionManager &sessionMgr, @@ -240,6 +252,7 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl if (!mtf->valid()) { reply->errorCode = ECODE_QUERY_PARSE_ERROR; reply->errorMessage = "query execution failed (invalid query)"; + traceQuery(request, mtf->query()); return reply; } @@ -274,6 +287,7 @@ Matcher::match(const SearchRequest &request, vespalib::ThreadBundle &threadBundl sessionMgr.insert(std::move(session)); } reply = std::move(result->_reply); + traceQuery(request, mtf->query()); uint32_t numActiveLids = metaStore.getNumActiveLids(); // note: this is actually totalSpace+1, since 0 is reserved diff --git a/searchlib/src/vespa/searchlib/engine/request.h b/searchlib/src/vespa/searchlib/engine/request.h index 21087d4eff0..521a5be39fc 100644 --- a/searchlib/src/vespa/searchlib/engine/request.h +++ b/searchlib/src/vespa/searchlib/engine/request.h @@ -32,7 +32,7 @@ public: uint32_t getTraceLevel() const { return _traceLevel; } Request & setTraceLevel(uint32_t traceLevel) { _traceLevel = traceLevel; return *this; } - Trace & trace() { return _trace; } + Trace & trace() const { return _trace; } private: const fastos::TimeStamp _startTime; fastos::TimeStamp _timeOfDoom; |