aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaksim Kita <kitaetoya@gmail.com>2023-09-15 16:24:20 +0300
committermaksim-kita <maksim-kita@yandex-team.com>2023-09-15 16:42:42 +0300
commit8d552f0e863d044e95f4221da61efe52756beec5 (patch)
tree1310a23b162d884952cb223244ccc840d5fc42c0
parentf08fad547ba421f6693a02af6f34deb0b5ae6e11 (diff)
downloadydb-8d552f0e863d044e95f4221da61efe52756beec5.tar.gz
Async compilation enable by default
Async compilation enable by default Pull Request resolved: 368
-rw-r--r--ydb/core/kqp/ut/service/kqp_service_ut.cpp46
-rw-r--r--ydb/core/protos/config.proto2
-rw-r--r--ydb/library/yql/minikql/computation/mkql_computation_pattern_cache.cpp4
3 files changed, 44 insertions, 8 deletions
diff --git a/ydb/core/kqp/ut/service/kqp_service_ut.cpp b/ydb/core/kqp/ut/service/kqp_service_ut.cpp
index dd462b00e4..7caa82936e 100644
--- a/ydb/core/kqp/ut/service/kqp_service_ut.cpp
+++ b/ydb/core/kqp/ut/service/kqp_service_ut.cpp
@@ -234,7 +234,7 @@ Y_UNIT_TEST_SUITE(KqpService) {
UNIT_ASSERT_VALUES_EQUAL_C(status.GetStatus(), EStatus::SUCCESS, status.GetIssues().ToString());
}
- void ConfigureSettings(TKikimrSettings & settings, bool useCache, bool useAsyncPatternCompilation) {
+ void ConfigureSettings(TKikimrSettings & settings, bool useCache, bool useAsyncPatternCompilation, bool useCompiledCapacityBytesLimit) {
size_t cacheSize = 0;
if (useCache) {
cacheSize = useAsyncPatternCompilation ? 10_MB : 1_MB;
@@ -242,6 +242,10 @@ Y_UNIT_TEST_SUITE(KqpService) {
auto * tableServiceConfig = settings.AppConfig.MutableTableServiceConfig();
tableServiceConfig->MutableResourceManager()->SetKqpPatternCacheCapacityBytes(cacheSize);
+ if (useCompiledCapacityBytesLimit) {
+ tableServiceConfig->MutableResourceManager()->SetKqpPatternCacheCompiledCapacityBytes(1_MB * 0.1);
+ }
+
tableServiceConfig->SetEnableAsyncComputationPatternCompilation(useAsyncPatternCompilation);
if (useAsyncPatternCompilation) {
@@ -250,10 +254,21 @@ Y_UNIT_TEST_SUITE(KqpService) {
}
}
- Y_UNIT_TEST_QUAD(PatternCache, UseCache, UseAsyncPatternCompilation) {
+ enum AsyncPatternCompilationStrategy {
+ Off,
+ On,
+ OnWithLimit,
+ };
+
+ template <bool UseCache, AsyncPatternCompilationStrategy AsyncPatternCompilation>
+ void PatternCacheImpl() {
+ constexpr bool UseAsyncPatternCompilation = AsyncPatternCompilation == AsyncPatternCompilationStrategy::On ||
+ AsyncPatternCompilation == AsyncPatternCompilationStrategy::OnWithLimit;
+ constexpr bool UseCompiledCapacityBytesLimit = AsyncPatternCompilation == AsyncPatternCompilationStrategy::OnWithLimit;
+
auto settings = TKikimrSettings()
.SetWithSampleTables(false);
- ConfigureSettings(settings, UseCache, UseAsyncPatternCompilation);
+ ConfigureSettings(settings, UseCache, UseAsyncPatternCompilation, UseCompiledCapacityBytesLimit);
auto kikimr = TKikimrRunner{settings};
auto driver = kikimr.GetDriver();
@@ -263,8 +278,12 @@ Y_UNIT_TEST_SUITE(KqpService) {
static constexpr i64 AsyncPatternCompilationUniqueRequestsSize = 5;
auto async_compilation_condition = [&]() {
- if constexpr (UseCache && UseAsyncPatternCompilation) {
- return *counters.CompiledComputationPatterns < AsyncPatternCompilationUniqueRequestsSize;
+ if constexpr (UseCache) {
+ if constexpr (AsyncPatternCompilation == AsyncPatternCompilationStrategy::On) {
+ return *counters.CompiledComputationPatterns != AsyncPatternCompilationUniqueRequestsSize;
+ } else if constexpr (AsyncPatternCompilation == AsyncPatternCompilationStrategy::OnWithLimit) {
+ return *counters.CompiledComputationPatterns < AsyncPatternCompilationUniqueRequestsSize * 4;
+ }
}
return false;
@@ -326,11 +345,24 @@ Y_UNIT_TEST_SUITE(KqpService) {
}
}, 0, InFlight, NPar::TLocalExecutor::WAIT_COMPLETE | NPar::TLocalExecutor::MED_PRIORITY);
- if constexpr (UseCache && UseAsyncPatternCompilation) {
- UNIT_ASSERT(*counters.CompiledComputationPatterns >= AsyncPatternCompilationUniqueRequestsSize);
+ if constexpr (UseCache) {
+ if constexpr (AsyncPatternCompilation == AsyncPatternCompilationStrategy::On) {
+ UNIT_ASSERT(*counters.CompiledComputationPatterns == AsyncPatternCompilationUniqueRequestsSize);
+ } else if constexpr (AsyncPatternCompilation == AsyncPatternCompilationStrategy::OnWithLimit) {
+ UNIT_ASSERT(*counters.CompiledComputationPatterns >= AsyncPatternCompilationUniqueRequestsSize);
+ }
}
}
+ Y_UNIT_TEST(PatternCache) {
+ PatternCacheImpl<false, AsyncPatternCompilationStrategy::Off>();
+ PatternCacheImpl<false, AsyncPatternCompilationStrategy::On>();
+ PatternCacheImpl<false, AsyncPatternCompilationStrategy::OnWithLimit>();
+ PatternCacheImpl<true, AsyncPatternCompilationStrategy::Off>();
+ PatternCacheImpl<true, AsyncPatternCompilationStrategy::On>();
+ PatternCacheImpl<true, AsyncPatternCompilationStrategy::OnWithLimit>();
+ }
+
// YQL-15582
Y_UNIT_TEST_TWIN(RangeCache, UseCache) {
auto settings = TKikimrSettings()
diff --git a/ydb/core/protos/config.proto b/ydb/core/protos/config.proto
index 4a31457187..43bf03bbea 100644
--- a/ydb/core/protos/config.proto
+++ b/ydb/core/protos/config.proto
@@ -1360,7 +1360,7 @@ message TTableServiceConfig {
optional bool EnableSequentialReads = 39 [default = true];
optional bool EnablePreparedDdl = 42 [default = false];
optional bool EnableSequences = 43 [default = true];
- optional bool EnableAsyncComputationPatternCompilation = 48 [default = false];
+ optional bool EnableAsyncComputationPatternCompilation = 48 [default = true];
optional TCompileComputationPatternServiceConfig CompileComputationPatternServiceConfig = 47;
enum EBindingsMode {
diff --git a/ydb/library/yql/minikql/computation/mkql_computation_pattern_cache.cpp b/ydb/library/yql/minikql/computation/mkql_computation_pattern_cache.cpp
index 6a0e0b3225..cffa3b73b2 100644
--- a/ydb/library/yql/minikql/computation/mkql_computation_pattern_cache.cpp
+++ b/ydb/library/yql/minikql/computation/mkql_computation_pattern_cache.cpp
@@ -88,6 +88,10 @@ public:
}
void Clear() {
+ CurrentPatternsSizeBytes = 0;
+ CurrentCompiledPatternsSize = 0;
+ CurrentPatternsCompiledCodeSizeInBytes = 0;
+
SerializedProgramToPatternCacheHolder.clear();
for (auto & holder : LRUPatternList) {
holder.Entry->IsInCache.store(false);