diff options
16 files changed, 57 insertions, 16 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java index 3b4bc1c2c5c..4e47409a7a0 100644 --- a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java +++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java @@ -59,6 +59,7 @@ public interface ModelContext { boolean useAdaptiveDispatch(); // TODO: Remove temporary default implementation default Optional<TlsSecrets> tlsSecrets() { return Optional.empty(); } + default boolean enableGroupingSessionCache() { return false; } } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java index 73a401e6a2a..303052d011f 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java @@ -50,11 +50,13 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat private ContainerModelEvaluation modelEvaluation; private Optional<TlsSecrets> tlsSecrets; + private final boolean enableGroupingSessionCache; public ApplicationContainerCluster(AbstractConfigProducer<?> parent, String subId, String name, DeployState deployState) { super(parent, subId, name, deployState); this.tlsSecrets = deployState.tlsSecrets(); + this.enableGroupingSessionCache = deployState.getProperties().enableGroupingSessionCache(); restApiGroup = new ConfigProducerGroup<>(this, "rest-api"); servletGroup = new ConfigProducerGroup<>(this, "servlet"); @@ -158,4 +160,7 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat return tlsSecrets; } + public boolean enableGroupingSessionCache() { + return enableGroupingSessionCache; + } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java index d2f7c5e4549..c973aef77e4 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java @@ -1,21 +1,20 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.container.search; +import com.yahoo.container.QrSearchersConfig; import com.yahoo.container.bundle.BundleInstantiationSpecification; import com.yahoo.osgi.provider.model.ComponentModel; import com.yahoo.prelude.fastsearch.FS4ResourcePool; import com.yahoo.prelude.semantics.SemanticRulesConfig; +import com.yahoo.search.config.IndexInfoConfig; +import com.yahoo.search.pagetemplates.PageTemplatesConfig; +import com.yahoo.search.query.profile.config.QueryProfilesConfig; +import com.yahoo.vespa.configdefinition.IlscriptsConfig; import com.yahoo.vespa.model.container.ApplicationContainerCluster; -import com.yahoo.vespa.model.container.ContainerCluster; import com.yahoo.vespa.model.container.component.Component; import com.yahoo.vespa.model.container.component.ContainerSubsystem; import com.yahoo.vespa.model.container.search.searchchain.LocalProvider; import com.yahoo.vespa.model.container.search.searchchain.SearchChains; -import com.yahoo.search.config.IndexInfoConfig; -import com.yahoo.vespa.configdefinition.IlscriptsConfig; -import com.yahoo.container.QrSearchersConfig; -import com.yahoo.search.query.profile.config.QueryProfilesConfig; -import com.yahoo.search.pagetemplates.PageTemplatesConfig; import com.yahoo.vespa.model.search.AbstractSearchCluster; import com.yahoo.vespa.model.search.Dispatch; import com.yahoo.vespa.model.search.IndexedSearchCluster; @@ -41,6 +40,7 @@ public class ContainerSearch extends ContainerSubsystem<SearchChains> private final List<AbstractSearchCluster> systems = new LinkedList<>(); private final Options options; + private final boolean enableGroupingSessionCache; private QueryProfiles queryProfiles; private SemanticRules semanticRules; @@ -52,6 +52,7 @@ public class ContainerSearch extends ContainerSubsystem<SearchChains> // TODO: Should be added to container instead of cluster to get proper configId for qr config. cluster.addComponent(getFS4ResourcePool()); + this.enableGroupingSessionCache = cluster.enableGroupingSessionCache(); } private static Component<?, ComponentModel> getFS4ResourcePool() { @@ -98,7 +99,10 @@ public class ContainerSearch extends ContainerSubsystem<SearchChains> @Override public void getConfig(QueryProfilesConfig.Builder builder) { - if (queryProfiles!=null) queryProfiles.getConfig(builder); + if (queryProfiles!=null) { + queryProfiles.getConfig(builder); + builder.enableGroupingSessionCache(enableGroupingSessionCache); + } } @Override diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/empty.cfg b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/empty.cfg index e69de29bb2d..13153de1644 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/empty.cfg +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/empty.cfg @@ -0,0 +1 @@ +enableGroupingSessionCache false
\ No newline at end of file diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/explicit-reference-override.cfg b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/explicit-reference-override.cfg index 99e2e3c5dcb..b62e00a2ad5 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/explicit-reference-override.cfg +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/explicit-reference-override.cfg @@ -10,4 +10,5 @@ queryprofile[1].property[0].value "a.b" queryprofile[1].property[0].overridable "" queryprofile[1].reference[0].name "a" queryprofile[1].reference[0].value "a1" -queryprofile[1].reference[0].overridable ""
\ No newline at end of file +queryprofile[1].reference[0].overridable "" +enableGroupingSessionCache false
\ No newline at end of file diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/newsbe-query-profiles-simple.cfg b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/newsbe-query-profiles-simple.cfg index 196b6c3513a..65b4258f174 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/newsbe-query-profiles-simple.cfg +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/newsbe-query-profiles-simple.cfg @@ -16,4 +16,5 @@ queryprofile[0].queryprofilevariant[0].fordimensionvalues[0] "yahoo" queryprofile[0].queryprofilevariant[0].fordimensionvalues[1] "uk" queryprofile[0].queryprofilevariant[0].fordimensionvalues[2] "sc" queryprofile[0].queryprofilevariant[0].property[0].name "scthumbnail.sourcecountry" -queryprofile[0].queryprofilevariant[0].property[0].value "uk"
\ No newline at end of file +queryprofile[0].queryprofilevariant[0].property[0].value "uk" +enableGroupingSessionCache false
\ No newline at end of file diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/newsfe-query-profiles-simple.cfg b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/newsfe-query-profiles-simple.cfg index 461f9b606c6..b416abf7c67 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/newsfe-query-profiles-simple.cfg +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/newsfe-query-profiles-simple.cfg @@ -23,4 +23,5 @@ queryprofile[1].id "default" queryprofile[1].type "" queryprofile[1].reference[0].name "source.news" queryprofile[1].reference[0].value "backend/news" -queryprofile[1].reference[0].overridable ""
\ No newline at end of file +queryprofile[1].reference[0].overridable "" +enableGroupingSessionCache false
\ No newline at end of file diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/query-profile-variants-configuration.cfg b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/query-profile-variants-configuration.cfg index c86bba23286..352966d0d8b 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/query-profile-variants-configuration.cfg +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/query-profile-variants-configuration.cfg @@ -38,4 +38,5 @@ queryprofile[2].id "wparent2" queryprofile[2].type "" queryprofile[2].property[0].name "a" queryprofile[2].property[0].value "a1" -queryprofile[2].property[0].overridable ""
\ No newline at end of file +queryprofile[2].property[0].overridable "" +enableGroupingSessionCache false
\ No newline at end of file diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/query-profile-variants2-configuration.cfg b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/query-profile-variants2-configuration.cfg index c915cd2efd0..0f644cbb9eb 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/query-profile-variants2-configuration.cfg +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/query-profile-variants2-configuration.cfg @@ -58,4 +58,5 @@ queryprofile[3].property[1].overridable "false" queryprofile[3].queryprofilevariant[0].fordimensionvalues[0] "love" queryprofile[3].queryprofilevariant[0].fordimensionvalues[1] "default" queryprofile[3].queryprofilevariant[0].property[0].name "defaultIndex" -queryprofile[3].queryprofilevariant[0].property[0].value "default"
\ No newline at end of file +queryprofile[3].queryprofilevariant[0].property[0].value "default" +enableGroupingSessionCache false
\ No newline at end of file diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/query-profiles.cfg b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/query-profiles.cfg index 89a971adb15..4a9dabdc6ca 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/query-profiles.cfg +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/query-profiles.cfg @@ -102,4 +102,5 @@ queryprofiletype[2].field[0].name "market" queryprofiletype[2].field[0].type "string" queryprofiletype[2].field[0].overridable false queryprofiletype[2].field[0].mandatory false -queryprofiletype[2].field[0].alias ""
\ No newline at end of file +queryprofiletype[2].field[0].alias "" +enableGroupingSessionCache false
\ No newline at end of file diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/variants-of-explicit-compound-with-reference.cfg b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/variants-of-explicit-compound-with-reference.cfg index e1cca7ed232..92605f504a0 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/variants-of-explicit-compound-with-reference.cfg +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/variants-of-explicit-compound-with-reference.cfg @@ -23,4 +23,5 @@ queryprofile[2].queryprofilevariant[0].reference[0].name "a" queryprofile[2].queryprofilevariant[0].reference[0].value "a2" queryprofile[2].queryprofilevariant[1].fordimensionvalues[0] "x2" queryprofile[2].queryprofilevariant[1].property[0].name "a.b" -queryprofile[2].queryprofilevariant[1].property[0].value "a.b.x2"
\ No newline at end of file +queryprofile[2].queryprofilevariant[1].property[0].value "a.b.x2" +enableGroupingSessionCache false
\ No newline at end of file diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/variants-of-explicit-compound.cfg b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/variants-of-explicit-compound.cfg index d65b3fa5f92..1e7739d9962 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/variants-of-explicit-compound.cfg +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/test/variants-of-explicit-compound.cfg @@ -14,4 +14,5 @@ queryprofile[1].queryprofilevariant[0].property[0].name "a.b" queryprofile[1].queryprofilevariant[0].property[0].value "a.b.x1" queryprofile[1].queryprofilevariant[1].fordimensionvalues[0] "x2" queryprofile[1].queryprofilevariant[1].property[0].name "a.b" -queryprofile[1].queryprofilevariant[1].property[0].value "a.b.x2"
\ No newline at end of file +queryprofile[1].queryprofilevariant[1].property[0].value "a.b.x2" +enableGroupingSessionCache false
\ No newline at end of file diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java index d875385d14d..64148ba5de4 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java @@ -136,6 +136,7 @@ public class ModelContextImpl implements ModelContext { private final boolean useAdaptiveDispatch; private final boolean dispatchWithProtobuf; private final Optional<TlsSecrets> tlsSecrets; + private final boolean enableGroupingSessionCache; public Properties(ApplicationId applicationId, boolean multitenantFromConfig, @@ -172,6 +173,8 @@ public class ModelContextImpl implements ModelContext { this.useAdaptiveDispatch = Flags.USE_ADAPTIVE_DISPATCH.bindTo(flagSource) .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); this.tlsSecrets = tlsSecrets; + this.enableGroupingSessionCache = Flags.ENABLE_GROUPING_SESSION_CACHE.bindTo(flagSource) + .with(FetchVector.Dimension.APPLICATION_ID, applicationId.serializedForm()).value(); } @Override @@ -228,6 +231,11 @@ public class ModelContextImpl implements ModelContext { @Override public Optional<TlsSecrets> tlsSecrets() { return tlsSecrets; } + + @Override + public boolean enableGroupingSessionCache() { + return enableGroupingSessionCache; + } } } 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 8e654bf34b8..45303a3c646 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 @@ -99,6 +99,8 @@ public class SearchHandler extends LoggingRequestHandler { private final ExecutionFactory executionFactory; + private final boolean enableGroupingSessionCache; + private final class MeanConnections implements Callback { @Override @@ -122,6 +124,7 @@ public class SearchHandler extends LoggingRequestHandler { ExecutionFactory executionFactory) { super(executor, accessLog, metric, true); log.log(LogLevel.DEBUG, "SearchHandler.init " + System.identityHashCode(this)); + this.enableGroupingSessionCache = queryProfileConfig.enableGroupingSessionCache(); QueryProfileRegistry queryProfileRegistry = QueryProfileConfigurer.createFromConfig(queryProfileConfig); this.queryProfileRegistry = queryProfileRegistry.compile(); this.executionFactory = executionFactory; @@ -232,6 +235,9 @@ public class SearchHandler extends LoggingRequestHandler { CompiledQueryProfile queryProfile = queryProfileRegistry.findQueryProfile(queryProfileName); Query query = new Query(request, requestMap, queryProfile); + if (enableGroupingSessionCache) { + query.setGroupingSessionCache(true); + } boolean benchmarking = VespaHeaders.benchmarkOutput(request); boolean benchmarkCoverage = VespaHeaders.benchmarkCoverage(benchmarking, request.getJDiscRequest().headers()); diff --git a/container-search/src/main/resources/configdefinitions/query-profiles.def b/container-search/src/main/resources/configdefinitions/query-profiles.def index 20fcbda0d72..11966cae8ce 100644 --- a/container-search/src/main/resources/configdefinitions/query-profiles.def +++ b/container-search/src/main/resources/configdefinitions/query-profiles.def @@ -86,7 +86,9 @@ queryprofiletype[].field[].mandatory bool default=false # A space-separated list of aliases of this field name. Aliases are case insensitive queryprofiletype[].field[].alias string default="" - +# Temporary feature flag for enabling grouping session cache by default +# TODO Remove me once grouping session cache rollout is complete and cache is enabled by default +enableGroupingSessionCache bool default=false diff --git a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java index e1111822b90..3fdd6d8dc48 100644 --- a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java +++ b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java @@ -151,6 +151,12 @@ public class Flags { "Takes effect on deployment through controller", APPLICATION_ID); + public static final UnboundBooleanFlag ENABLE_GROUPING_SESSION_CACHE = defineFeatureFlag( + "enable-grouping-session-cache", false, + "Enable grouping session cache", + "Takes effect at redeployment", + APPLICATION_ID); + /** WARNING: public for testing: All flags should be defined in {@link Flags}. */ public static UnboundBooleanFlag defineFeatureFlag(String flagId, boolean defaultValue, String description, String modificationEffect, FetchVector.Dimension... dimensions) { |