diff --git a/configs/milvus.yaml b/configs/milvus.yaml index 741ff71fe2..4158a0c6c5 100644 --- a/configs/milvus.yaml +++ b/configs/milvus.yaml @@ -1127,6 +1127,7 @@ common: sync: taskPoolReleaseTimeoutSeconds: 60 # The maximum time to wait for the task to finish and release resources in the pool enabledOptimizeExpr: true # Indicates whether to enable optimize expr + enableDriverPrefetch: false # Indicates whether to enable query driver prefetch in segcore. enabledJSONShredding: true # Indicates sealedsegment whether to enable JSON key stats enabledGrowingSegmentJSONShredding: false # Indicates growingsegment whether to enable JSON key stats enableConfigParamTypeCheck: true # Indicates whether to enable config param type check diff --git a/internal/core/src/common/Common.cpp b/internal/core/src/common/Common.cpp index caae2041c3..3e9ee267fb 100644 --- a/internal/core/src/common/Common.cpp +++ b/internal/core/src/common/Common.cpp @@ -34,6 +34,7 @@ std::atomic DELETE_DUMP_BATCH_SIZE(DEFAULT_DELETE_DUMP_BATCH_SIZE); std::atomic ENABLE_LATEST_DELETE_SNAPSHOT_OPTIMIZATION( DEFAULT_ENABLE_LATEST_DELETE_SNAPSHOT_OPTIMIZATION); std::atomic OPTIMIZE_EXPR_ENABLED(DEFAULT_OPTIMIZE_EXPR_ENABLED); +std::atomic ENABLE_DRIVER_PREFETCH(DEFAULT_ENABLE_DRIVER_PREFETCH); std::atomic JSON_KEY_STATS_ENABLED(DEFAULT_JSON_KEY_STATS_ENABLED); @@ -82,6 +83,13 @@ SetDefaultOptimizeExprEnable(bool val) { OPTIMIZE_EXPR_ENABLED.load()); } +void +SetDefaultDriverPrefetchEnable(bool val) { + ENABLE_DRIVER_PREFETCH.store(val); + LOG_INFO("set default driver prefetch enabled: {}", + ENABLE_DRIVER_PREFETCH.load()); +} + void SetDefaultJSONKeyStatsEnable(bool val) { JSON_KEY_STATS_ENABLED.store(val); diff --git a/internal/core/src/common/Common.h b/internal/core/src/common/Common.h index 88c57d5410..45dc587efd 100644 --- a/internal/core/src/common/Common.h +++ b/internal/core/src/common/Common.h @@ -30,6 +30,7 @@ extern std::atomic EXEC_EVAL_EXPR_BATCH_SIZE; extern std::atomic DELETE_DUMP_BATCH_SIZE; extern std::atomic ENABLE_LATEST_DELETE_SNAPSHOT_OPTIMIZATION; extern std::atomic OPTIMIZE_EXPR_ENABLED; +extern std::atomic ENABLE_DRIVER_PREFETCH; extern std::atomic JSON_KEY_STATS_ENABLED; extern std::atomic GROWING_JSON_KEY_STATS_ENABLED; extern std::atomic CONFIG_PARAM_TYPE_CHECK_ENABLED; @@ -50,6 +51,9 @@ SetDefaultDeleteDumpBatchSize(int64_t val); void SetDefaultOptimizeExprEnable(bool val); +void +SetDefaultDriverPrefetchEnable(bool val); + void SetDefaultJSONKeyStatsEnable(bool val); diff --git a/internal/core/src/common/Consts.h b/internal/core/src/common/Consts.h index 18dab141aa..57183e8ef5 100644 --- a/internal/core/src/common/Consts.h +++ b/internal/core/src/common/Consts.h @@ -112,6 +112,7 @@ const std::string JSON_CAST_TYPE = "json_cast_type"; const std::string JSON_PATH = "json_path"; const std::string JSON_CAST_FUNCTION = "json_cast_function"; const bool DEFAULT_OPTIMIZE_EXPR_ENABLED = true; +const bool DEFAULT_ENABLE_DRIVER_PREFETCH = true; const int64_t DEFAULT_CONVERT_OR_TO_IN_NUMERIC_LIMIT = 150; const int64_t DEFAULT_JSON_INDEX_MEMORY_BUDGET = 16777216; // bytes, 16MB const bool DEFAULT_JSON_KEY_STATS_ENABLED = true; diff --git a/internal/core/src/common/init_c.cpp b/internal/core/src/common/init_c.cpp index 9fb28192bd..862629bd7f 100644 --- a/internal/core/src/common/init_c.cpp +++ b/internal/core/src/common/init_c.cpp @@ -91,6 +91,11 @@ SetDefaultOptimizeExprEnable(bool val) { milvus::SetDefaultOptimizeExprEnable(val); } +void +SetDefaultDriverPrefetchEnable(bool val) { + milvus::SetDefaultDriverPrefetchEnable(val); +} + void SetDefaultJSONKeyStatsEnable(bool val) { milvus::SetDefaultJSONKeyStatsEnable(val); diff --git a/internal/core/src/common/init_c.h b/internal/core/src/common/init_c.h index c2b7c6e00f..add02dae0e 100644 --- a/internal/core/src/common/init_c.h +++ b/internal/core/src/common/init_c.h @@ -55,6 +55,9 @@ SetDefaultDeleteDumpBatchSize(int64_t val); void SetDefaultOptimizeExprEnable(bool val); +void +SetDefaultDriverPrefetchEnable(bool val); + void SetDefaultJSONKeyStatsEnable(bool val); diff --git a/internal/core/src/exec/Driver.cpp b/internal/core/src/exec/Driver.cpp index 1ffbeb35a3..fc52e40e74 100644 --- a/internal/core/src/exec/Driver.cpp +++ b/internal/core/src/exec/Driver.cpp @@ -25,6 +25,7 @@ #include #include +#include "common/Common.h" #include "common/EasyAssert.h" #include "common/Exception.h" #include "common/Tracer.h" @@ -284,7 +285,9 @@ Driver::RunInternal(std::shared_ptr& self, RowVectorPtr& result) { try { initializeOperators(); - std::call_once(self->once_, [self]() { self->PrefetchAsync(); }); + if (ENABLE_DRIVER_PREFETCH.load(std::memory_order_relaxed)) { + std::call_once(self->once_, [self]() { self->PrefetchAsync(); }); + } int num_operators = operators_.size(); ContinueFuture future; diff --git a/internal/util/initcore/init_core.go b/internal/util/initcore/init_core.go index 1778971301..0f622b23bd 100644 --- a/internal/util/initcore/init_core.go +++ b/internal/util/initcore/init_core.go @@ -605,6 +605,15 @@ func SetupCoreConfigChangelCallback() { return nil }) + paramtable.Get().CommonCfg.EnableDriverPrefetch.RegisterCallback(func(ctx context.Context, key, oldValue, newValue string) error { + enable, err := strconv.ParseBool(newValue) + if err != nil { + return err + } + UpdateDefaultDriverPrefetchEnable(enable) + return nil + }) + paramtable.Get().CommonCfg.EnabledJSONKeyStats.RegisterCallback(func(ctx context.Context, key, oldValue, newValue string) error { enable, err := strconv.ParseBool(newValue) if err != nil { diff --git a/internal/util/initcore/query_node.go b/internal/util/initcore/query_node.go index ef6a69eaaf..4d96f33b83 100644 --- a/internal/util/initcore/query_node.go +++ b/internal/util/initcore/query_node.go @@ -140,6 +140,9 @@ func doInitQueryNodeOnce(ctx context.Context) error { cOptimizeExprEnabled := C.bool(paramtable.Get().CommonCfg.EnabledOptimizeExpr.GetAsBool()) C.SetDefaultOptimizeExprEnable(cOptimizeExprEnabled) + cDriverPrefetchEnabled := C.bool(paramtable.Get().CommonCfg.EnableDriverPrefetch.GetAsBool()) + C.SetDefaultDriverPrefetchEnable(cDriverPrefetchEnabled) + cJSONKeyStatsEnabled := C.bool(paramtable.Get().CommonCfg.EnabledJSONKeyStats.GetAsBool()) C.SetDefaultJSONKeyStatsEnable(cJSONKeyStatsEnabled) diff --git a/internal/util/initcore/util.go b/internal/util/initcore/util.go index 8950a5ad41..dc3a894078 100644 --- a/internal/util/initcore/util.go +++ b/internal/util/initcore/util.go @@ -83,6 +83,10 @@ func UpdateDefaultOptimizeExprEnable(enable bool) { C.SetDefaultOptimizeExprEnable(C.bool(enable)) } +func UpdateDefaultDriverPrefetchEnable(enable bool) { + C.SetDefaultDriverPrefetchEnable(C.bool(enable)) +} + func UpdateDefaultJSONKeyStatsEnable(enable bool) { C.SetDefaultJSONKeyStatsEnable(C.bool(enable)) } diff --git a/pkg/util/paramtable/component_param.go b/pkg/util/paramtable/component_param.go index 9a6bbff6f9..233acce98f 100644 --- a/pkg/util/paramtable/component_param.go +++ b/pkg/util/paramtable/component_param.go @@ -344,6 +344,7 @@ type commonConfig struct { SyncTaskPoolReleaseTimeoutSeconds ParamItem `refreshable:"true"` EnabledOptimizeExpr ParamItem `refreshable:"true"` + EnableDriverPrefetch ParamItem `refreshable:"true"` EnabledJSONKeyStats ParamItem `refreshable:"true"` EnabledGrowingSegmentJSONKeyStats ParamItem `refreshable:"true"` @@ -1392,6 +1393,15 @@ If enabled, IPv6 ULA/global addresses will be prioritized ahead of IPv4.`, } p.EnabledOptimizeExpr.Init(base.mgr) + p.EnableDriverPrefetch = ParamItem{ + Key: "common.enableDriverPrefetch", + Version: "3.0", + DefaultValue: "false", + Doc: "Indicates whether to enable query driver prefetch in segcore.", + Export: true, + } + p.EnableDriverPrefetch.Init(base.mgr) + p.UsingJSONStatsForQuery = ParamItem{ Key: "common.usingJSONShreddingForQuery", Version: "2.6.5",