summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@yahooinc.com>2022-08-29 11:26:23 +0000
committerHåvard Pettersen <havardpe@yahooinc.com>2022-08-29 11:27:21 +0000
commit9085b3536c241eaa83de035c9813cd889e3a6358 (patch)
tree72ced304296b13b503ddb786df4b6ed5ae30f24c
parent87c82aa9266205e676e0cd1524233f1d2ae6a557 (diff)
if a search thread has tracing, include it in the trace
-rw-r--r--searchcore/src/vespa/searchcore/proton/matching/match_master.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp b/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp
index 427d4507c43..eefb8411df2 100644
--- a/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp
+++ b/searchcore/src/vespa/searchcore/proton/matching/match_master.cpp
@@ -24,6 +24,21 @@ using vespalib::Issue;
namespace {
+struct LazyThreadTraceInserter {
+ search::engine::Trace &root_trace;
+ std::unique_ptr<vespalib::slime::Inserter> inserter;
+ LazyThreadTraceInserter(search::engine::Trace &root_trace_in)
+ : root_trace(root_trace_in), inserter() {}
+ void handle(const search::engine::Trace &thread_trace) {
+ if (thread_trace.hasTrace()) {
+ if (!inserter) {
+ inserter = std::make_unique<vespalib::slime::ArrayInserter>(root_trace.createCursor("query_execution").setArray("threads"));
+ }
+ vespalib::slime::inject(thread_trace.getRoot(), *inserter);
+ }
+ }
+};
+
struct TimedMatchLoopCommunicator final : IMatchLoopCommunicator {
IMatchLoopCommunicator &communicator;
vespalib::Timer timer;
@@ -104,17 +119,12 @@ MatchMaster::match(search::engine::Trace & trace,
double query_time_s = vespalib::to_s(query_latency_time.elapsed());
double rerank_time_s = vespalib::to_s(timedCommunicator.elapsed);
double match_time_s = 0.0;
- std::unique_ptr<vespalib::slime::Inserter> inserter;
- if (trace.shouldTrace(4)) {
- inserter = std::make_unique<vespalib::slime::ArrayInserter>(trace.createCursor("query_execution").setArray("threads"));
- }
+ LazyThreadTraceInserter inserter(trace);
for (size_t i = 0; i < threadState.size(); ++i) {
const MatchThread & matchThread = *threadState[i];
match_time_s = std::max(match_time_s, matchThread.get_match_time());
_stats.merge_partition(matchThread.get_thread_stats(), i);
- if (inserter && matchThread.getTrace().hasTrace()) {
- vespalib::slime::inject(matchThread.getTrace().getRoot(), *inserter);
- }
+ inserter.handle(matchThread.getTrace());
matchThread.get_issues().for_each_message([](const auto &msg){ Issue::report(Issue(msg)); });
}
_stats.queryLatency(query_time_s);