summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-03-07 17:02:14 +0100
committerGitHub <noreply@github.com>2019-03-07 17:02:14 +0100
commitd33933d74fa5a5a01529a6b74f1a1a1901904449 (patch)
tree5e1180aa105c8e8215270b2e740873b59e21e15b /searchcore
parent882e4276c0fd191db0ba62f4da5e3e64ab7059ea (diff)
parent9e410bcd856284367889d288ef8ee17e0d90a569 (diff)
Merge pull request #8681 from vespa-engine/balder/trace-backend
Balder/trace backend
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp23
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_tools.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/matcher.cpp14
3 files changed, 30 insertions, 8 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp
index 8fcb30a4143..3a28eeb4dfd 100644
--- a/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matchengine/matchengine.cpp
@@ -2,9 +2,12 @@
#include "matchengine.h"
#include <vespa/searchcore/proton/common/state_reporter_utils.h>
#include <vespa/vespalib/data/slime/cursor.h>
-#include <algorithm>
+#include <vespa/vespalib/data/smart_buffer.h>
+#include <vespa/vespalib/data/slime/binary_format.h>
+#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/log/log.h>
+
LOG_SETUP(".proton.matchengine.matchengine");
namespace {
@@ -47,7 +50,6 @@ MatchEngine::MatchEngine(size_t numThreads, size_t threadsPerSearch, uint32_t di
_threadBundlePool(std::max(size_t(1), threadsPerSearch)),
_nodeUp(false)
{
- // empty
}
MatchEngine::~MatchEngine()
@@ -103,9 +105,7 @@ MatchEngine::search(search::engine::SearchRequest::Source request,
return ret;
}
- vespalib::Executor::Task::UP task;
- task.reset(new SearchTask(*this, std::move(request), client));
- _executor.execute(std::move(task));
+ _executor.execute(std::make_unique<SearchTask>(*this, std::move(request), client));
return search::engine::SearchReply::UP();
}
@@ -113,9 +113,9 @@ void
MatchEngine::performSearch(search::engine::SearchRequest::Source req,
search::engine::SearchClient &client)
{
- search::engine::SearchReply::UP ret(new search::engine::SearchReply);
+ auto ret = std::make_unique<search::engine::SearchReply>();
- if (req.get() != NULL) {
+ if (req.get()) {
ISearchHandler::SP searchHandler;
vespalib::SimpleThreadBundle::UP threadBundle = _threadBundlePool.obtain();
{ // try to find the match handler corresponding to the specified search doc type
@@ -123,7 +123,7 @@ MatchEngine::performSearch(search::engine::SearchRequest::Source req,
DocTypeName docTypeName(*req.get());
searchHandler = _handlers.getHandler(docTypeName);
}
- if (searchHandler.get() != NULL) {
+ if (searchHandler) {
ret = searchHandler->match(searchHandler, *req.get(), *threadBundle);
} else {
HandlerMap<ISearchHandler>::Snapshot::UP snapshot;
@@ -140,6 +140,13 @@ MatchEngine::performSearch(search::engine::SearchRequest::Source req,
}
ret->request = req.release();
ret->setDistributionKey(_distributionKey);
+ if (ret->request->getTraceLevel() > 0) {
+ ret->request->trace().getRoot().setLong("distribution-key", _distributionKey);
+ search::fef::Properties & trace = ret->propertiesMap.lookupCreate("trace");
+ vespalib::SmartBuffer output(4096);
+ vespalib::slime::BinaryFormat::encode(ret->request->trace().getSlime(), output);
+ trace.add("slime", output.obtain().make_stringref());
+ }
client.searchDone(std::move(ret));
}
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