Skip to content

Commit

Permalink
Determine queue size based on feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorncs committed Jan 14, 2025
1 parent 5b4328c commit 36bd0d5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion config-model-api/abi-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,8 @@
"public boolean useLegacyWandQueryParsing()",
"public boolean forwardAllLogLevels()",
"public long zookeeperPreAllocSize()",
"public int distributionBitsInDev()"
"public int distributionBitsInDev()",
"public int documentV1QueueSize()"
],
"fields" : [ ]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ interface FeatureFlags {
@ModelFeatureFlag(owners = {"hmusum"}) default boolean forwardAllLogLevels() { return true; }
@ModelFeatureFlag(owners = {"hmusum"}) default long zookeeperPreAllocSize() { return 65536L; }
@ModelFeatureFlag(owners = {"hmusum"}) default int distributionBitsInDev() { return 0; }
@ModelFeatureFlag(owners = {"bjorncs"}) default int documentV1QueueSize() { return -1; }
}

/** Warning: As elsewhere in this package, do not make backwards incompatible changes that will break old config models! */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.yahoo.container.handler.metrics.PrometheusV1Handler;
import com.yahoo.container.jdisc.ContainerMbusConfig;
import com.yahoo.container.jdisc.messagebus.MbusServerProvider;
import com.yahoo.document.restapi.DocumentOperationExecutorConfig;
import com.yahoo.osgi.provider.model.ComponentModel;
import com.yahoo.search.config.QrStartConfig;
import com.yahoo.vespa.config.search.RankProfilesConfig;
Expand Down Expand Up @@ -71,6 +72,7 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat
ContainerMbusConfig.Producer,
MetricsProxyApiConfig.Producer,
ZookeeperServerConfig.Producer,
DocumentOperationExecutorConfig.Producer,
ApplicationClusterInfo {

public static final String METRICS_V2_HANDLER_CLASS = MetricsV2Handler.class.getName();
Expand Down Expand Up @@ -102,6 +104,7 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat
private int zookeeperSessionTimeoutSeconds = 30;
private final int transport_events_before_wakeup;
private final int transport_connections_per_target;
private final int documentV1QueueSize;

/** The heap size % of total memory available to the JVM process. */
private final int heapSizePercentageOfAvailableMemory;
Expand Down Expand Up @@ -145,6 +148,7 @@ public ApplicationContainerCluster(TreeConfigProducer<?> parent, String configSu
onnxModelCostCalculator = deployState.onnxModelCost().newCalculator(
deployState.getApplicationPackage(), deployState.getProperties().applicationId(), ClusterSpec.Id.from(clusterId));
logger = deployState.getDeployLogger();
documentV1QueueSize = deployState.featureFlags().documentV1QueueSize();
}

public UserConfiguredUrls userConfiguredUrls() { return userConfiguredUrls; }
Expand Down Expand Up @@ -426,6 +430,13 @@ private static boolean configureEndpoints(DeployState deployState) {
return true;
}

@Override
public void getConfig(DocumentOperationExecutorConfig.Builder builder) {
if (documentV1QueueSize >= 0) {
builder.maxThrottled(documentV1QueueSize);
}
}

public static class MbusParams {
// the amount of the maxpendingbytes to process concurrently, typically 0.2 (20%)
final Double maxConcurrentFactor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public static class FeatureFlags implements ModelContext.FeatureFlags {
private final boolean forwardAllLogLevels;
private final long zookeeperPreAllocSize;
private final int distributionBitsInDev;
private final int documentV1QueueSize;

public FeatureFlags(FlagSource source, ApplicationId appId, Version version) {
this.defaultTermwiseLimit = Flags.DEFAULT_TERM_WISE_LIMIT.bindTo(source).with(appId).with(version).value();
Expand Down Expand Up @@ -270,6 +271,7 @@ public FeatureFlags(FlagSource source, ApplicationId appId, Version version) {
this.forwardAllLogLevels = PermanentFlags.FORWARD_ALL_LOG_LEVELS.bindTo(source).with(appId).with(version).value();
this.zookeeperPreAllocSize = Flags.ZOOKEEPER_PRE_ALLOC_SIZE_KIB.bindTo(source).value();
this.distributionBitsInDev = Flags.DISTRIBUTION_BITS_IN_DEV.bindTo(source).value();
this.documentV1QueueSize = Flags.DOCUMENT_V1_QUEUE_SIZE.bindTo(source).with(appId).with(version).value();
}

@Override public int heapSizePercentage() { return heapPercentage; }
Expand Down Expand Up @@ -329,6 +331,7 @@ public FeatureFlags(FlagSource source, ApplicationId appId, Version version) {
@Override public boolean forwardAllLogLevels() { return forwardAllLogLevels; }
@Override public long zookeeperPreAllocSize() { return zookeeperPreAllocSize; }
@Override public int distributionBitsInDev() { return distributionBitsInDev; }
@Override public int documentV1QueueSize() { return documentV1QueueSize; }
}

public static class Properties implements ModelContext.Properties {
Expand Down
7 changes: 7 additions & 0 deletions flags/src/main/java/com/yahoo/vespa/flags/Flags.java
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,13 @@ public class Flags {
"Takes effect at redeployment",
INSTANCE_ID);

public static final UnboundIntFlag DOCUMENT_V1_QUEUE_SIZE = defineIntFlag(
"document-v1-queue-size", -1,
List.of("bjorncs"), "2025-01-14", "2025-12-01",
"Size of the document v1 queue. Use -1 for default as determined by 'document-operation-executor.def'",
"Takes effect at redeployment",
INSTANCE_ID);

/** WARNING: public for testing: All flags should be defined in {@link Flags}. */
public static UnboundBooleanFlag defineFeatureFlag(String flagId, boolean defaultValue, List<String> owners,
String createdAt, String expiresAt, String description,
Expand Down

0 comments on commit 36bd0d5

Please sign in to comment.