aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorva-kuznecov <va-kuznecov@ydb.tech>2022-11-02 11:53:31 +0300
committerva-kuznecov <va-kuznecov@ydb.tech>2022-11-02 11:53:31 +0300
commite3ffb0af25c5c456263ecb50cd8d4cec27e37dc4 (patch)
tree1c8f7b20dd00135a661e6276d40ee916b41314f4
parentb042054901b9bb0ade441351371f4d81d2aece0b (diff)
downloadydb-e3ffb0af25c5c456263ecb50cd8d4cec27e37dc4.tar.gz
Add TableService flag for switching pattern cache
-rw-r--r--ydb/core/kqp/rm/kqp_rm.cpp14
-rw-r--r--ydb/core/kqp/ut/kqp_service_ut.cpp3
-rw-r--r--ydb/core/protos/config.proto4
3 files changed, 19 insertions, 2 deletions
diff --git a/ydb/core/kqp/rm/kqp_rm.cpp b/ydb/core/kqp/rm/kqp_rm.cpp
index 13ccc51f7c3..bfefb88c4f6 100644
--- a/ydb/core/kqp/rm/kqp_rm.cpp
+++ b/ydb/core/kqp/rm/kqp_rm.cpp
@@ -638,10 +638,24 @@ private:
LOG_D("Subscribed for config changes");
}
+ static void UpdatePatternCache(bool enable, std::shared_ptr<NMiniKQL::TComputationPatternLRUCache>& cache) {
+ if (enable) {
+ if (!cache) {
+ cache = std::make_shared<NMiniKQL::TComputationPatternLRUCache>();
+ }
+ } else {
+ cache.reset();
+ }
+ }
+
void HandleWork(NConsole::TEvConsole::TEvConfigNotificationRequest::TPtr& ev) {
auto& event = ev->Get()->Record;
Send(ev->Sender, new NConsole::TEvConsole::TEvConfigNotificationResponse(event), IEventHandle::FlagTrackDelivery, ev->Cookie);
+ const auto& tsConfig = event.MutableConfig()->GetTableServiceConfig();
+ UpdatePatternCache(tsConfig.GetEnableKqpPatternCacheLiteral(), LiteralPatternCache);
+ UpdatePatternCache(tsConfig.GetEnableKqpPatternCacheCompute(), ComputeActorPatternCache);
+
auto& config = *event.MutableConfig()->MutableTableServiceConfig()->MutableResourceManager();
#define FORCE_VALUE(name) if (!config.Has ## name ()) config.Set ## name(config.Get ## name());
diff --git a/ydb/core/kqp/ut/kqp_service_ut.cpp b/ydb/core/kqp/ut/kqp_service_ut.cpp
index 9162720a785..41df09665c3 100644
--- a/ydb/core/kqp/ut/kqp_service_ut.cpp
+++ b/ydb/core/kqp/ut/kqp_service_ut.cpp
@@ -227,7 +227,8 @@ Y_UNIT_TEST_SUITE(KqpService) {
Y_UNIT_TEST_TWIN(PatternCache, UseCache) {
auto settings = TKikimrSettings()
.SetWithSampleTables(false);
- settings.FeatureFlags.SetEnableKqpPatternCacheLiteral(UseCache);
+ settings.AppConfig.MutableTableServiceConfig()->SetEnableKqpPatternCacheLiteral(UseCache);
+ settings.AppConfig.MutableTableServiceConfig()->SetEnableKqpPatternCacheCompute(UseCache);
auto kikimr = TKikimrRunner{settings};
auto driver = kikimr.GetDriver();
diff --git a/ydb/core/protos/config.proto b/ydb/core/protos/config.proto
index 1bf98300fa7..6b968363104 100644
--- a/ydb/core/protos/config.proto
+++ b/ydb/core/protos/config.proto
@@ -723,7 +723,7 @@ message TFeatureFlags {
optional bool EnableKqpScanQueryStreamLookup = 66 [default = false];
optional bool EnableKqpScanQueryMultipleOlapShardsReads = 67 [default = false];
optional bool EnablePredicateExtractForDataQueries = 68 [default = true];
- optional bool EnableKqpPatternCacheLiteral = 69 [default = false];
+ reserved 69; // optional bool EnableKqpPatternCacheLiteral = 69 [default = false];
optional bool EnableMoveIndex = 70 [default = false];
// enable http handle for self termination
optional bool EnableFailureInjectionTermination = 71 [default = false];
@@ -1183,6 +1183,8 @@ message TTableServiceConfig {
optional uint32 CompileQueryCacheTTLSec = 20 [default = 0];
optional TQueryReplayConfig QueryReplayConfig = 21;
reserved 23; // optional bool EnableKqpSessionActor = 23 [default = true];
+ optional bool EnableKqpPatternCacheLiteral = 24 [default = false];
+ optional bool EnableKqpPatternCacheCompute = 25 [default = false];
};
// Config describes immediate controls and allows