summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2023-01-20 11:08:50 +0100
committerGitHub <noreply@github.com>2023-01-20 11:08:50 +0100
commitf01c1607b1637eecb40a45c32b851ebeec539fe7 (patch)
tree968667276d8390d48042870f5275721363d437f9 /searchlib
parent9282b27525bacb596a06a878d3043bbd9c77d777 (diff)
parent79ff30cd9ec64651af8deda8f6800c1234e79449 (diff)
Merge pull request #25639 from vespa-engine/havardpe/extend-search-protocol
separate profiling depth parameters
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/protobuf/search_protocol.proto13
-rw-r--r--searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp23
-rw-r--r--searchlib/src/vespa/searchlib/engine/proto_converter.cpp13
-rw-r--r--searchlib/src/vespa/searchlib/engine/request.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/engine/trace.cpp6
-rw-r--r--searchlib/src/vespa/searchlib/engine/trace.h20
6 files changed, 67 insertions, 10 deletions
diff --git a/searchlib/src/protobuf/search_protocol.proto b/searchlib/src/protobuf/search_protocol.proto
index 1be68abad04..916788796b8 100644
--- a/searchlib/src/protobuf/search_protocol.proto
+++ b/searchlib/src/protobuf/search_protocol.proto
@@ -24,7 +24,18 @@ message SearchRequest {
bytes grouping_blob = 15; // serialized opaquely like now, to be changed later
string geo_location = 16; // to be moved into query_tree
bytes query_tree_blob = 17; // serialized opaquely like now, to be changed later
- int32 profile_depth = 18;
+ int32 profile_depth = 18; // new meaning: default ProfilingParams.depth
+ Profiling profiling = 19;
+}
+
+message Profiling {
+ ProfilingParams match = 1;
+ ProfilingParams first_phase = 2;
+ ProfilingParams second_phase = 3;
+}
+
+message ProfilingParams {
+ int32 depth = 1;
}
message TensorProperty {
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 bd40a4566cd..ad20684bd04 100644
--- a/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp
+++ b/searchlib/src/tests/engine/proto_converter/proto_converter_test.cpp
@@ -69,7 +69,28 @@ TEST_F(SearchRequestTest, require_that_trace_level_is_converted) {
TEST_F(SearchRequestTest, require_that_profile_depth_is_converted) {
proto.set_profile_depth(7);
convert();
- EXPECT_EQ(request.trace().getProfileDepth(), 7);
+ EXPECT_EQ(request.trace().match_profile_depth(), 7);
+ EXPECT_EQ(request.trace().first_phase_profile_depth(), 7);
+ EXPECT_EQ(request.trace().second_phase_profile_depth(), 7);
+}
+
+TEST_F(SearchRequestTest, require_that_profiling_params_are_converted) {
+ proto.mutable_profiling()->mutable_match()->set_depth(4);
+ proto.mutable_profiling()->mutable_first_phase()->set_depth(5);
+ proto.mutable_profiling()->mutable_second_phase()->set_depth(6);
+ convert();
+ EXPECT_EQ(request.trace().match_profile_depth(), 4);
+ EXPECT_EQ(request.trace().first_phase_profile_depth(), 5);
+ EXPECT_EQ(request.trace().second_phase_profile_depth(), 6);
+}
+
+TEST_F(SearchRequestTest, require_that_profile_depth_is_fallback) {
+ proto.mutable_profiling()->mutable_first_phase()->set_depth(5);
+ proto.set_profile_depth(7);
+ convert();
+ EXPECT_EQ(request.trace().match_profile_depth(), 7);
+ EXPECT_EQ(request.trace().first_phase_profile_depth(), 5);
+ EXPECT_EQ(request.trace().second_phase_profile_depth(), 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 842ced502c6..ae00889850b 100644
--- a/searchlib/src/vespa/searchlib/engine/proto_converter.cpp
+++ b/searchlib/src/vespa/searchlib/engine/proto_converter.cpp
@@ -69,7 +69,18 @@ ProtoConverter::search_request_from_proto(const ProtoSearchRequest &proto, Searc
request.maxhits = proto.hits();
request.setTimeout(1ms * proto.timeout());
request.trace().setLevel(proto.trace_level());
- request.trace().setProfileDepth(proto.profile_depth());
+ if (int32_t value = proto.profile_depth(); value != 0) {
+ request.trace().profile_depth(value);
+ }
+ if (int32_t value = proto.profiling().match().depth(); value != 0) {
+ request.trace().match_profile_depth(value);
+ }
+ if (int32_t value = proto.profiling().first_phase().depth(); value != 0) {
+ request.trace().first_phase_profile_depth(value);
+ }
+ if (int32_t value = proto.profiling().second_phase().depth(); value != 0) {
+ request.trace().second_phase_profile_depth(value);
+ }
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());
diff --git a/searchlib/src/vespa/searchlib/engine/request.cpp b/searchlib/src/vespa/searchlib/engine/request.cpp
index d88d3740f07..e4ab55fcacf 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, 0)
+ _trace(_relativeTime, 0)
{
}
diff --git a/searchlib/src/vespa/searchlib/engine/trace.cpp b/searchlib/src/vespa/searchlib/engine/trace.cpp
index 649823e7ec1..27e652db651 100644
--- a/searchlib/src/vespa/searchlib/engine/trace.cpp
+++ b/searchlib/src/vespa/searchlib/engine/trace.cpp
@@ -26,13 +26,15 @@ Trace::constructTraces() const {
_traces = & root().setArray("traces");
}
-Trace::Trace(const RelativeTime & relativeTime, uint32_t level, uint32_t profileDepth)
+Trace::Trace(const RelativeTime & relativeTime, uint32_t level)
: _trace(),
_root(nullptr),
_traces(nullptr),
_relativeTime(relativeTime),
_level(level),
- _profileDepth(profileDepth)
+ _match_profile_depth(0),
+ _first_phase_profile_depth(0),
+ _second_phase_profile_depth(0)
{
}
diff --git a/searchlib/src/vespa/searchlib/engine/trace.h b/searchlib/src/vespa/searchlib/engine/trace.h
index a9107787bc5..a76313ca5a5 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, uint32_t profileDepth);
+ Trace(const RelativeTime & relativeTime, uint32_t traceLevel);
~Trace();
/**
@@ -90,8 +90,18 @@ 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; }
+ Trace &match_profile_depth(int32_t depth) { _match_profile_depth = depth; return *this; }
+ Trace &first_phase_profile_depth(int32_t depth) { _first_phase_profile_depth = depth; return *this; }
+ Trace &second_phase_profile_depth(int32_t depth) { _second_phase_profile_depth = depth; return *this; }
+ Trace &profile_depth(int32_t depth) {
+ match_profile_depth(depth);
+ first_phase_profile_depth(depth);
+ second_phase_profile_depth(depth);
+ return *this;
+ }
+ int32_t match_profile_depth() const { return _match_profile_depth; }
+ int32_t first_phase_profile_depth() const { return _first_phase_profile_depth; }
+ int32_t second_phase_profile_depth() const { return _second_phase_profile_depth; }
const RelativeTime & getRelativeTime() const { return _relativeTime; }
private:
vespalib::Slime & slime() const {
@@ -120,7 +130,9 @@ private:
mutable Cursor * _traces;
const RelativeTime & _relativeTime;
uint32_t _level;
- uint32_t _profileDepth;
+ int32_t _match_profile_depth;
+ int32_t _first_phase_profile_depth;
+ int32_t _second_phase_profile_depth;
};
}