diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-08-25 11:59:29 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-08-25 11:59:29 +0200 |
commit | 895e5881213da925d71a6d0ad8feffc92acaa96e (patch) | |
tree | 73f2f4eed40c6c29e747272fc6bda2ae91c95191 /container-search/src/main/java/com/yahoo/search | |
parent | bf81a11f33d4c687e6446b67b1e26a67c1bd59b7 (diff) |
Wire in query parameter profileDepth to control how deep down in the depency tree
profiling shall go.
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search')
5 files changed, 16 insertions, 11 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/Query.java b/container-search/src/main/java/com/yahoo/search/Query.java index 3a2bccf017e..6930e648ffa 100644 --- a/container-search/src/main/java/com/yahoo/search/Query.java +++ b/container-search/src/main/java/com/yahoo/search/Query.java @@ -687,6 +687,7 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { public void attachContext(Query query) throws IllegalStateException { query.getTrace().setLevel(getTrace().getLevel()); query.getTrace().setExplainLevel(getTrace().getExplainLevel()); + query.getTrace().setProfileDepth(getTrace().getProfileDepth()); if (context == null) return; if (query.getContext(false) != null) { // If we added the other query's context info as a subnode in this @@ -851,8 +852,7 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { public boolean equals(Object other) { if (this == other) return true; - if ( ! (other instanceof Query)) return false; - Query q = (Query) other; + if ( ! (other instanceof Query q)) return false; if (getOffset() != q.getOffset()) return false; if (getHits() != q.getHits()) return false; @@ -929,7 +929,6 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { /** * Prepares this for binary serialization. - * * This must be invoked after all changes have been made to this query before it is passed * on to a receiving backend. Calling it is somewhat expensive, so it should only happen once. * If a prepared query is cloned, it stays prepared. diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java b/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java index 345c621ae24..8df825cf108 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java @@ -33,11 +33,9 @@ import java.util.Set; /** * A dispatcher communicates with search nodes to perform queries and fill hits. - * * This class allocates {@link SearchInvoker} and {@link FillInvoker} objects based * on query properties and general system status. The caller can then use the provided * invocation object to execute the search or fill. - * * This class is multithread safe. * * @author bratseth @@ -142,8 +140,8 @@ public class Dispatcher extends AbstractComponent { * Will run important code in order to trigger JIT compilation and avoid cold start issues. * Currently warms up lz4 compression code. */ - private static long warmup(double seconds) { - return new Compressor().warmup(seconds); + private static void warmup(double seconds) { + new Compressor().warmup(seconds); } /** Returns the search cluster this dispatches to */ diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/ProtobufSerialization.java b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/ProtobufSerialization.java index 154defe7eb2..e5fa37e7a65 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/ProtobufSerialization.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/ProtobufSerialization.java @@ -81,6 +81,7 @@ public class ProtobufSerialization { } builder.setTraceLevel(getTraceLevelForBackend(query)); + builder.setProfileDepth(query.getTrace().getProfileDepth()); mergeToSearchRequestFromRanking(query.getRanking(), builder); @@ -283,8 +284,7 @@ public class ProtobufSerialization { if (hit.getRelevance() != null) { hitBuilder.setRelevance(hit.getRelevance().getScore()); } - if (hit instanceof FastHit) { - FastHit fhit = (FastHit) hit; + if (hit instanceof FastHit fhit) { hitBuilder.setGlobalId(ByteString.copyFrom(fhit.getRawGlobalId())); } builder.addHits(hitBuilder); diff --git a/container-search/src/main/java/com/yahoo/search/query/Trace.java b/container-search/src/main/java/com/yahoo/search/query/Trace.java index 9f056b14c21..246c77e6c50 100644 --- a/container-search/src/main/java/com/yahoo/search/query/Trace.java +++ b/container-search/src/main/java/com/yahoo/search/query/Trace.java @@ -34,6 +34,7 @@ public class Trace implements Cloneable { public static final String TRACE = "trace"; public static final String LEVEL = "level"; public static final String EXPLAIN_LEVEL = "explainLevel"; + public static final String PROFILE_DEPTH = "profileDepth"; public static final String TIMESTAMPS = "timestamps"; public static final String QUERY = "query"; @@ -43,6 +44,7 @@ public class Trace implements Cloneable { argumentType.setBuiltin(true); argumentType.addField(new FieldDescription(LEVEL, "integer", "tracelevel traceLevel")); argumentType.addField(new FieldDescription(EXPLAIN_LEVEL, "integer", "explainlevel explainLevel")); + argumentType.addField(new FieldDescription(PROFILE_DEPTH, "integer", "profiledepth profileDepth")); argumentType.addField(new FieldDescription(TIMESTAMPS, "boolean")); argumentType.addField(new FieldDescription(QUERY, "boolean")); argumentType.freeze(); @@ -54,6 +56,7 @@ public class Trace implements Cloneable { private int level = 0; private int explainLevel = 0; + private int profileDepth = 0; private boolean timestamps = false; private boolean query = true; @@ -70,6 +73,10 @@ public class Trace implements Cloneable { public void setExplainLevel(int explainLevel) { this.explainLevel = explainLevel; } public int getExplainLevel() { return explainLevel; } + /** Sets the profiling depth. Profiling enabled if non-zero. Higher numbers means increasingly more detail. */ + public void setProfileDepth(int profileDepth) { this.profileDepth = profileDepth; } + public int getProfileDepth() { return profileDepth; } + /** Returns whether trace entries should have a timestamp. Default is false. */ public boolean getTimestamps() { return timestamps; } public void setTimestamps(boolean timestamps) { this.timestamps = timestamps; } @@ -212,8 +219,7 @@ public class Trace implements Cloneable { @Override public boolean equals(Object o) { if (o == this ) return true; - if ( ! (o instanceof Trace)) return false; - Trace other = (Trace)o; + if ( ! (o instanceof Trace other)) return false; if (other.level != this.level) return false; if (other.explainLevel != this.explainLevel) return false; if (other.timestamps != this.timestamps) return false; diff --git a/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java b/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java index 160a039fe2d..085a6382a13 100644 --- a/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java +++ b/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java @@ -312,6 +312,8 @@ public class QueryProperties extends Properties { query.getTrace().setLevel(asInteger(value, 0)); if (key.last().equals(Trace.EXPLAIN_LEVEL)) query.getTrace().setExplainLevel(asInteger(value, 0)); + if (key.last().equals(Trace.PROFILE_DEPTH)) + query.getTrace().setProfileDepth(asInteger(value, 0)); if (key.last().equals(Trace.TIMESTAMPS)) query.getTrace().setTimestamps(asBoolean(value, false)); if (key.last().equals(Trace.QUERY)) |