aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-04-27 18:36:06 +0200
committergjoranv <gv@verizonmedia.com>2022-06-08 11:45:21 +0200
commitbe5c208bc697db8bdc3c3549cc3f07e8d8f0cd47 (patch)
tree3e7bd228351a38fbf9067339e6c4f863eeee8b5c /container-search/src/main/java
parent3afcbd7b97a2d348e96dcfc6d79748b248956e9b (diff)
GC deprecated statistics module
Diffstat (limited to 'container-search/src/main/java')
-rw-r--r--container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java153
-rw-r--r--container-search/src/main/java/com/yahoo/search/statistics/PeakQpsSearcher.java231
-rw-r--r--container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java144
3 files changed, 0 insertions, 528 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java
index 3eadf29489e..2c26a302ece 100644
--- a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java
+++ b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java
@@ -3,14 +3,11 @@ package com.yahoo.search.handler;
import ai.vespa.cloud.ZoneInfo;
import com.yahoo.collections.Tuple2;
-import com.yahoo.component.ComponentId;
import com.yahoo.component.ComponentSpecification;
import com.yahoo.component.Vtag;
import com.yahoo.component.annotation.Inject;
import com.yahoo.component.chain.Chain;
import com.yahoo.component.provider.ComponentRegistry;
-import com.yahoo.container.QrSearchersConfig;
-import com.yahoo.container.core.ChainsConfig;
import com.yahoo.container.core.ContainerHttpConfig;
import com.yahoo.container.handler.threadpool.ContainerThreadPool;
import com.yahoo.container.jdisc.AclMapping;
@@ -20,11 +17,9 @@ import com.yahoo.container.jdisc.HttpResponse;
import com.yahoo.container.jdisc.LoggingRequestHandler;
import com.yahoo.container.jdisc.RequestHandlerSpec;
import com.yahoo.container.jdisc.VespaHeaders;
-import com.yahoo.container.logging.AccessLog;
import com.yahoo.io.IOUtils;
import com.yahoo.jdisc.Metric;
import com.yahoo.jdisc.Request;
-import com.yahoo.language.Linguistics;
import com.yahoo.language.process.Embedder;
import com.yahoo.language.provider.DefaultEmbedderProvider;
import com.yahoo.net.HostName;
@@ -36,12 +31,9 @@ import com.yahoo.processing.request.CompoundName;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
-import com.yahoo.search.config.IndexInfoConfig;
import com.yahoo.search.query.context.QueryContext;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfile;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry;
-import com.yahoo.search.query.profile.config.QueryProfileConfigurer;
-import com.yahoo.search.query.profile.config.QueryProfilesConfig;
import com.yahoo.search.query.properties.DefaultProperties;
import com.yahoo.search.query.ranking.SoftTimeout;
import com.yahoo.search.result.ErrorMessage;
@@ -52,8 +44,6 @@ import com.yahoo.search.statistics.ElapsedTime;
import com.yahoo.slime.Inspector;
import com.yahoo.slime.ObjectTraverser;
import com.yahoo.slime.SlimeUtils;
-import com.yahoo.statistics.Statistics;
-import com.yahoo.vespa.configdefinition.SpecialtokensConfig;
import com.yahoo.yolean.Exceptions;
import com.yahoo.yolean.trace.TraceNode;
@@ -130,119 +120,6 @@ public class SearchHandler extends LoggingRequestHandler {
zoneInfo);
}
- /**
- * @deprecated Use the @Inject annotated constructor instead.
- */
- @Deprecated // Vespa 8
- public SearchHandler(Metric metric,
- ContainerThreadPool threadpool,
- CompiledQueryProfileRegistry queryProfileRegistry,
- ContainerHttpConfig config,
- Embedder embedder,
- ExecutionFactory executionFactory) {
- this(metric, threadpool.executor(), queryProfileRegistry, embedder, executionFactory,
- config.numQueriesToTraceOnDebugAfterConstruction(),
- config.hostResponseHeaderKey().equals("") ? Optional.empty() : Optional.of(config.hostResponseHeaderKey()),
- ZoneInfo.defaultInfo());
- }
-
- /**
- * @deprecated Use the @Inject annotated constructor instead.
- */
- @Deprecated // Vespa 8
- public SearchHandler(Statistics statistics,
- Metric metric,
- ContainerThreadPool threadpool,
- CompiledQueryProfileRegistry queryProfileRegistry,
- ContainerHttpConfig config,
- Embedder embedder,
- ExecutionFactory executionFactory) {
- this(metric, threadpool.executor(), queryProfileRegistry, embedder, executionFactory,
- config.numQueriesToTraceOnDebugAfterConstruction(),
- config.hostResponseHeaderKey().equals("") ? Optional.empty() : Optional.of(config.hostResponseHeaderKey()),
- ZoneInfo.defaultInfo());
- }
-
- /**
- * @deprecated Use the @Inject annotated constructor instead.
- */
- @Deprecated // Vespa 8
- public SearchHandler(Statistics statistics,
- Metric metric,
- ContainerThreadPool threadpool,
- AccessLog ignored,
- CompiledQueryProfileRegistry queryProfileRegistry,
- ContainerHttpConfig config,
- ExecutionFactory executionFactory) {
- this(statistics, metric, threadpool.executor(), ignored, queryProfileRegistry, config, executionFactory);
- }
-
- /**
- * @deprecated Use the @Inject annotated constructor instead.
- */
- @Deprecated // Vespa 8
- public SearchHandler(Statistics statistics,
- Metric metric,
- Executor executor,
- AccessLog ignored,
- CompiledQueryProfileRegistry queryProfileRegistry,
- ContainerHttpConfig containerHttpConfig,
- ExecutionFactory executionFactory) {
- this(metric, executor, queryProfileRegistry, Embedder.throwsOnUse, executionFactory,
- containerHttpConfig.numQueriesToTraceOnDebugAfterConstruction(),
- containerHttpConfig.hostResponseHeaderKey().equals("") ? Optional.empty()
- : Optional.of(containerHttpConfig.hostResponseHeaderKey()),
- ZoneInfo.defaultInfo());
- }
-
- /**
- * @deprecated Use the @Inject annotated constructor instead.
- */
- @Deprecated // Vespa 8
- public SearchHandler(Statistics statistics,
- Metric metric,
- Executor executor,
- AccessLog ignored,
- QueryProfilesConfig queryProfileConfig,
- ContainerHttpConfig containerHttpConfig,
- ExecutionFactory executionFactory) {
- this(metric, executor, QueryProfileConfigurer.createFromConfig(queryProfileConfig).compile(),
- Embedder.throwsOnUse, executionFactory,
- containerHttpConfig.numQueriesToTraceOnDebugAfterConstruction(),
- containerHttpConfig.hostResponseHeaderKey().equals("") ? Optional.empty()
- : Optional.of( containerHttpConfig.hostResponseHeaderKey()),
- ZoneInfo.defaultInfo());
- }
-
- /**
- * @deprecated Use the @Inject annotated constructor instead.
- */
- @Deprecated // Vespa 8
- public SearchHandler(Statistics statistics,
- Metric metric,
- Executor executor,
- AccessLog ignored,
- CompiledQueryProfileRegistry queryProfileRegistry,
- ExecutionFactory executionFactory,
- Optional<String> hostResponseHeaderKey) {
- this(metric, executor, queryProfileRegistry, toRegistry(Embedder.throwsOnUse),
- executionFactory, 0, hostResponseHeaderKey,
- ZoneInfo.defaultInfo());
- }
-
- private SearchHandler(Metric metric,
- Executor executor,
- CompiledQueryProfileRegistry queryProfileRegistry,
- Embedder embedder,
- ExecutionFactory executionFactory,
- long numQueriesToTraceOnDebugAfterStartup,
- Optional<String> hostResponseHeaderKey,
- ZoneInfo zoneInfo) {
- this(metric, executor, queryProfileRegistry, toRegistry(embedder),
- executionFactory, numQueriesToTraceOnDebugAfterStartup, hostResponseHeaderKey,
- ZoneInfo.defaultInfo());
- }
-
private SearchHandler(Metric metric,
Executor executor,
CompiledQueryProfileRegistry queryProfileRegistry,
@@ -266,30 +143,6 @@ public class SearchHandler extends LoggingRequestHandler {
this.zoneInfo = zoneInfo;
}
- /** @deprecated use the other constructor */
- @Deprecated // TODO: Remove on Vespa 8
- public SearchHandler(ChainsConfig chainsConfig,
- IndexInfoConfig indexInfo,
- QrSearchersConfig clusters,
- SpecialtokensConfig specialtokens,
- Statistics statistics,
- Linguistics linguistics,
- Metric metric,
- ComponentRegistry<Renderer> renderers,
- Executor executor,
- AccessLog accessLog,
- QueryProfilesConfig queryProfileConfig,
- ComponentRegistry<Searcher> searchers,
- ContainerHttpConfig containerHttpConfig) {
- this(statistics,
- metric,
- executor,
- accessLog,
- queryProfileConfig,
- containerHttpConfig,
- new ExecutionFactory(chainsConfig, indexInfo, clusters, searchers, specialtokens, linguistics, renderers, executor));
- }
-
Metric metric() { return metric; }
private static int examineExecutor(Executor executor) {
@@ -716,12 +569,6 @@ public class SearchHandler extends LoggingRequestHandler {
return Collections.unmodifiableMap(map);
}
- private static ComponentRegistry<Embedder> toRegistry(Embedder embedder) {
- ComponentRegistry<Embedder> emb = new ComponentRegistry<>();
- emb.register(new ComponentId(Embedder.defaultEmbedderId), embedder);
- return emb;
- }
-
}
diff --git a/container-search/src/main/java/com/yahoo/search/statistics/PeakQpsSearcher.java b/container-search/src/main/java/com/yahoo/search/statistics/PeakQpsSearcher.java
deleted file mode 100644
index 2823a7d74e1..00000000000
--- a/container-search/src/main/java/com/yahoo/search/statistics/PeakQpsSearcher.java
+++ /dev/null
@@ -1,231 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.search.statistics;
-
-import com.yahoo.collections.Tuple2;
-import com.yahoo.concurrent.ThreadLocalDirectory;
-import com.yahoo.search.Query;
-import com.yahoo.search.Result;
-import com.yahoo.search.Searcher;
-import com.yahoo.processing.request.CompoundName;
-import com.yahoo.search.result.Hit;
-import com.yahoo.search.searchchain.Execution;
-import com.yahoo.statistics.Callback;
-import com.yahoo.statistics.Handle;
-import com.yahoo.statistics.Statistics;
-import com.yahoo.statistics.Value;
-
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.Deque;
-import java.util.List;
-import java.util.ListIterator;
-
-/**
- * Aggregate peak qps and expose through meta hits and/or log events.
- *
- * @author Steinar Knutsen
- * @deprecated Will be removed on Vespa 8
- */
-@Deprecated
-public class PeakQpsSearcher extends Searcher {
-
- private final ThreadLocalDirectory<Deque<QueryRatePerSecond>, Long> directory;
- private final Value qpsStatistics;
- private final CompoundName propertyName;
- private final boolean useMetaHit;
-
- /**
- * Meta hit which carries the peak qps and mean qps since the last time this
- * data was requested. The URI is always "meta:qps". The data is stored as
- * Number subclasses in the fields named by the fields PEAK_QPS and MEAN_QPS
- * in the QpsHit class.
- */
- public static class QpsHit extends Hit {
-
- /** The name of the field containing mean QPS since the last measurement. */
- public static final String MEAN_QPS = "mean_qps";
-
- /** The name of the field containing peak QPS since the last measurement. */
- public static final String PEAK_QPS = "peak_qps";
- public static final String SCHEME = "meta";
-
- public QpsHit(Integer peakQps, Double meanQps) {
- super(SCHEME + ":qps");
- setField(PEAK_QPS, peakQps);
- setField(MEAN_QPS, meanQps);
- }
-
- public boolean isMeta() {
- return true;
- }
-
- @Override
- public String toString() {
- return "QPS hit: Peak QPS " + getField(PEAK_QPS) + ", mean QPS " + getField(MEAN_QPS) + ".";
- }
-
- }
-
- static class QueryRatePerSecond {
- long when;
- int howMany;
-
- QueryRatePerSecond(long when) {
- this.when = when;
- this.howMany = 0;
- }
-
- void add(int x) {
- howMany += x;
- }
-
- void increment() {
- howMany += 1;
- }
-
- @Override
- public String toString() {
- return "QueryRatePerSecond(" + when + ": " + howMany + ")";
- }
- }
-
- static class QueryRate implements
- ThreadLocalDirectory.Updater<Deque<QueryRatePerSecond>, Long> {
- @Override
- public Deque<QueryRatePerSecond> update(Deque<QueryRatePerSecond> current, Long when) {
- QueryRatePerSecond last = current.peekLast();
- if (last == null || last.when != when) {
- last = new QueryRatePerSecond(when);
- current.addLast(last);
- }
- last.increment();
- return current;
- }
-
- @Override
- public Deque<QueryRatePerSecond> createGenerationInstance(Deque<QueryRatePerSecond> previous) {
- if (previous == null) {
- return new ArrayDeque<>();
- } else {
- return new ArrayDeque<>(previous.size());
- }
- }
- }
-
- private class Fetcher implements Callback {
- @Override
- public void run(Handle h, boolean firstRun) {
- List<Deque<QueryRatePerSecond>> data = directory.fetch();
- List<QueryRatePerSecond> chewed = merge(data);
- for (QueryRatePerSecond qps : chewed) {
- qpsStatistics.put(qps.howMany);
- }
- }
- }
-
- public PeakQpsSearcher(MeasureQpsConfig config, Statistics manager) {
- directory = createDirectory();
- MeasureQpsConfig.Outputmethod.Enum method = config.outputmethod();
- if (method == MeasureQpsConfig.Outputmethod.METAHIT) {
- useMetaHit = true;
- propertyName = new CompoundName(config.queryproperty());
- qpsStatistics = null;
- } else if (method == MeasureQpsConfig.Outputmethod.STATISTICS) {
- String event = config.eventname();
- if (event == null || event.isEmpty()) {
- event = getId().getName();
- event = event.replace('.', '_');
- }
- qpsStatistics = new Value(event, manager, new Value.Parameters()
- .setAppendChar('_').setLogMax(true).setLogMean(true)
- .setLogMin(false).setLogRaw(false).setNameExtension(true)
- .setCallback(new Fetcher()));
- useMetaHit = false;
- propertyName = null;
- } else {
- throw new IllegalStateException("Config definition out of sync with implementation." +
- " No way to create output for method " + method + ".");
- }
- }
-
- static ThreadLocalDirectory<Deque<QueryRatePerSecond>, Long> createDirectory() {
- return new ThreadLocalDirectory<>(new QueryRate());
- }
-
- static List<QueryRatePerSecond> merge(List<Deque<QueryRatePerSecond>> measurements) {
- List<QueryRatePerSecond> rates = new ArrayList<>();
- while (measurements.size() > 0) {
- Deque<Deque<QueryRatePerSecond>> consumeFrom = new ArrayDeque<>(measurements.size());
- long current = Long.MAX_VALUE;
- for (ListIterator<Deque<QueryRatePerSecond>> i = measurements.listIterator(); i.hasNext();) {
- Deque<QueryRatePerSecond> deck = i.next();
- if (deck.size() == 0) {
- i.remove();
- continue;
- }
- QueryRatePerSecond threadData = deck.peekFirst();
- if (threadData.when < current) {
- consumeFrom.clear();
- current = threadData.when;
- consumeFrom.add(deck);
- } else if (threadData.when == current) {
- consumeFrom.add(deck);
- }
- }
- if (consumeFrom.size() > 0) {
- rates.add(consume(consumeFrom));
- }
- }
- return rates;
- }
-
- private static QueryRatePerSecond consume(Deque<Deque<QueryRatePerSecond>> consumeFrom) {
- Deque<QueryRatePerSecond> valueQueue = consumeFrom.pop();
- QueryRatePerSecond value = valueQueue.pop();
- QueryRatePerSecond thisSecond = new QueryRatePerSecond(value.when);
- thisSecond.add(value.howMany);
- while (consumeFrom.size() > 0) {
- valueQueue = consumeFrom.pop();
- value = valueQueue.pop();
- thisSecond.add(value.howMany);
- }
- return thisSecond;
-
- }
-
- @Override
- public Result search(Query query, Execution execution) {
- Result r;
- long when = query.getStartTime() / 1000L;
- Hit meta = null;
- directory.update(when);
- if (useMetaHit) {
- if (query.properties().getBoolean(propertyName, false)) {
- List<QueryRatePerSecond> l = merge(directory.fetch());
- Tuple2<Integer, Double> maxAndMean = maxAndMean(l);
- meta = new QpsHit(maxAndMean.first, maxAndMean.second);
- }
- }
- r = execution.search(query);
- if (meta != null) {
- r.hits().add(meta);
- }
- return r;
- }
-
- private Tuple2<Integer, Double> maxAndMean(List<QueryRatePerSecond> l) {
- int max = Integer.MIN_VALUE;
- double sum = 0.0d;
- if (l.size() == 0) {
- return new Tuple2<>(0, 0.0);
- }
- for (QueryRatePerSecond qps : l) {
- sum += qps.howMany;
- if (qps.howMany > max) {
- max = qps.howMany;
- }
- }
- return new Tuple2<>(max, sum / (double) l.size());
- }
-
-}
diff --git a/container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java b/container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java
deleted file mode 100644
index 5d036b8fa20..00000000000
--- a/container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java
+++ /dev/null
@@ -1,144 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.search.statistics;
-
-import com.yahoo.component.ComponentId;
-import com.yahoo.component.chain.dependencies.Before;
-import com.yahoo.search.statistics.TimingSearcherConfig.Timer;
-import com.yahoo.prelude.Ping;
-import com.yahoo.prelude.Pong;
-import com.yahoo.search.Query;
-import com.yahoo.search.Result;
-import com.yahoo.search.cluster.PingableSearcher;
-import com.yahoo.search.searchchain.Execution;
-import com.yahoo.search.statistics.TimeTracker.Activity;
-import com.yahoo.statistics.Statistics;
-import com.yahoo.statistics.Value;
-
-/**
- * A searcher which is intended to be useful as a general probe for
- * measuring time consumption a search chain.
- *
- * @author Steinar Knutsen
- * @deprecated Will be removed on Vespa 8
- */
-@Before("rawQuery")
-@Deprecated
-public class TimingSearcher extends PingableSearcher {
-
- private Value measurements;
- private final boolean measurePing;
- private final boolean measureSearch;
- private final boolean measureFill;
- private static final Parameters defaultParameters = new Parameters(null, Activity.SEARCH);
-
- public static class Parameters {
- final String eventName;
- final Activity pathToSample;
-
- public Parameters(String eventName, Activity pathToSample) {
- super();
- this.eventName = eventName;
- this.pathToSample = pathToSample;
- }
- }
-
- TimingSearcher(ComponentId id, Parameters setUp, Statistics manager) {
- super(id);
- if (setUp == null) {
- setUp = defaultParameters;
- }
- String eventName = setUp.eventName;
- if (eventName == null || "".equals(eventName)) {
- eventName = id.getName();
- }
- measurements = new Value(eventName, manager, new Value.Parameters()
- .setNameExtension(true).setLogMax(true).setLogMin(true)
- .setLogMean(true).setLogSum(true).setLogInsertions(true)
- .setAppendChar('_'));
-
- measurePing = setUp.pathToSample == Activity.PING;
- measureSearch = setUp.pathToSample == Activity.SEARCH;
- measureFill = setUp.pathToSample == Activity.FILL;
- }
-
- public TimingSearcher(ComponentId id, TimingSearcherConfig config, Statistics manager) {
- this(id, buildParameters(config, id.getName()), manager);
- }
-
- private static Parameters buildParameters(
- TimingSearcherConfig config, String searcherName) {
- for (int i = 0; i < config.timer().size(); ++i) {
- Timer t = config.timer(i);
- if (t.name().equals(searcherName)) {
- return buildParameters(t);
- }
- }
- return null;
- }
-
- private static Parameters buildParameters(Timer t) {
- Activity m;
- Timer.Measure.Enum toSample = t.measure();
- if (toSample == Timer.Measure.FILL) {
- m = Activity.FILL;
- } else if (toSample == Timer.Measure.PING) {
- m = Activity.PING;
- } else {
- m = Activity.SEARCH;
- }
- return new Parameters(t.eventname(), m);
- }
-
- private long preMeasure(boolean doIt) {
- if (doIt) {
- return System.currentTimeMillis();
- } else {
- return 0L;
- }
- }
-
- private void postMeasure(boolean doIt, long start) {
- if (doIt) {
- long elapsed = System.currentTimeMillis() - start;
- measurements.put(elapsed);
- }
- }
-
- @Override
- public void fill(Result result, String summaryClass, Execution execution) {
- long start = preMeasure(measureFill);
- super.fill(result, summaryClass, execution);
- postMeasure(measureFill, start);
- }
-
- @Override
- public Pong ping(Ping ping, Execution execution) {
- long start = preMeasure(measurePing);
- Pong pong = execution.ping(ping);
- postMeasure(measurePing, start);
- return pong;
- }
-
- @Override
- public Result search(Query query, Execution execution) {
- long start = preMeasure(measureSearch);
- Result result = execution.search(query);
- postMeasure(measureSearch, start);
- return result;
- }
-
- /**
- * This method is only included for testing.
- */
- public void setMeasurements(Value measurements) {
- this.measurements = measurements;
- }
-
- @Override
- public void deconstruct() {
- // avoid dangling, duplicate loggers
- measurements.cancel();
- super.deconstruct();
- }
-
-}