|
11 | 11 | import org.opensearch.OpenSearchParseException;
|
12 | 12 | import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
|
13 | 13 | import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse;
|
14 |
| -import org.opensearch.transport.client.Client; |
15 | 14 | import org.opensearch.cluster.metadata.IndexMetadata;
|
16 | 15 | import org.opensearch.cluster.service.ClusterService;
|
17 | 16 | import org.opensearch.common.Booleans;
|
|
28 | 27 | import org.opensearch.knn.quantization.models.quantizationState.QuantizationStateCacheManager;
|
29 | 28 | import org.opensearch.monitor.jvm.JvmInfo;
|
30 | 29 | import org.opensearch.monitor.os.OsProbe;
|
| 30 | +import org.opensearch.transport.client.Client; |
31 | 31 |
|
32 | 32 | import java.security.InvalidParameterException;
|
33 | 33 | import java.util.Arrays;
|
@@ -96,6 +96,7 @@ public class KNNSettings {
|
96 | 96 | public static final String KNN_DERIVED_SOURCE_ENABLED = "index.knn.derived_source.enabled";
|
97 | 97 | public static final String KNN_INDEX_REMOTE_VECTOR_BUILD = "index.knn.remote_index_build.enabled";
|
98 | 98 | public static final String KNN_REMOTE_VECTOR_REPO = "knn.remote_index_build.vector_repo";
|
| 99 | + public static final String KNN_REMOTE_VECTOR_BUILD_THRESHOLD = "knn.remote_index_build.size_threshold"; |
99 | 100 |
|
100 | 101 | /**
|
101 | 102 | * Default setting values
|
@@ -126,6 +127,8 @@ public class KNNSettings {
|
126 | 127 | // 10% of the JVM heap
|
127 | 128 | public static final Integer KNN_DEFAULT_QUANTIZATION_STATE_CACHE_EXPIRY_TIME_MINUTES = 60;
|
128 | 129 | public static final boolean KNN_DISK_VECTOR_SHARD_LEVEL_RESCORING_DISABLED_VALUE = false;
|
| 130 | + // TODO: Tune this default value based on benchmarking |
| 131 | + public static final ByteSizeValue KNN_REMOTE_VECTOR_BUILD_THRESHOLD_DEFAULT_VALUE = new ByteSizeValue(50, ByteSizeUnit.MB); |
129 | 132 |
|
130 | 133 | /**
|
131 | 134 | * Settings Definition
|
@@ -388,6 +391,15 @@ public class KNNSettings {
|
388 | 391 | */
|
389 | 392 | public static final Setting<String> KNN_REMOTE_VECTOR_REPO_SETTING = Setting.simpleString(KNN_REMOTE_VECTOR_REPO, Dynamic, NodeScope);
|
390 | 393 |
|
| 394 | + /** |
| 395 | + * Cluster level setting which indicates the size threshold above which remote vector builds will be enabled. |
| 396 | + */ |
| 397 | + public static final Setting<ByteSizeValue> KNN_REMOTE_VECTOR_BUILD_THRESHOLD_SETTING = Setting.byteSizeSetting( |
| 398 | + KNN_REMOTE_VECTOR_BUILD_THRESHOLD, |
| 399 | + KNN_REMOTE_VECTOR_BUILD_THRESHOLD_DEFAULT_VALUE, |
| 400 | + Dynamic, |
| 401 | + NodeScope |
| 402 | + ); |
391 | 403 | /**
|
392 | 404 | * Dynamic settings
|
393 | 405 | */
|
@@ -550,6 +562,10 @@ private Setting<?> getSetting(String key) {
|
550 | 562 | return KNN_REMOTE_VECTOR_REPO_SETTING;
|
551 | 563 | }
|
552 | 564 |
|
| 565 | + if (KNN_REMOTE_VECTOR_BUILD_THRESHOLD.equals(key)) { |
| 566 | + return KNN_REMOTE_VECTOR_BUILD_THRESHOLD_SETTING; |
| 567 | + } |
| 568 | + |
553 | 569 | throw new IllegalArgumentException("Cannot find setting by key [" + key + "]");
|
554 | 570 | }
|
555 | 571 |
|
@@ -577,7 +593,8 @@ public List<Setting<?>> getSettings() {
|
577 | 593 | KNN_DISK_VECTOR_SHARD_LEVEL_RESCORING_DISABLED_SETTING,
|
578 | 594 | KNN_DERIVED_SOURCE_ENABLED_SETTING,
|
579 | 595 | KNN_INDEX_REMOTE_VECTOR_BUILD_SETTING,
|
580 |
| - KNN_REMOTE_VECTOR_REPO_SETTING |
| 596 | + KNN_REMOTE_VECTOR_REPO_SETTING, |
| 597 | + KNN_REMOTE_VECTOR_BUILD_THRESHOLD_SETTING |
581 | 598 | );
|
582 | 599 | return Stream.concat(settings.stream(), Stream.concat(getFeatureFlags().stream(), dynamicCacheSettings.values().stream()))
|
583 | 600 | .collect(Collectors.toList());
|
@@ -657,6 +674,10 @@ public static boolean isShardLevelRescoringDisabledForDiskBasedVector(String ind
|
657 | 674 | .getAsBoolean(KNN_DISK_VECTOR_SHARD_LEVEL_RESCORING_DISABLED, false);
|
658 | 675 | }
|
659 | 676 |
|
| 677 | + public static ByteSizeValue getKnnRemoteVectorBuildThreshold() { |
| 678 | + return KNNSettings.state().getSettingValue(KNNSettings.KNN_REMOTE_VECTOR_BUILD_THRESHOLD); |
| 679 | + } |
| 680 | + |
660 | 681 | public void initialize(Client client, ClusterService clusterService) {
|
661 | 682 | this.client = client;
|
662 | 683 | this.clusterService = clusterService;
|
|
0 commit comments