summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorivanmorozov <[email protected]>2023-02-15 15:47:45 +0300
committerivanmorozov <[email protected]>2023-02-15 15:47:45 +0300
commit27e22c30b9098051f1440a1e840d29b11147a57e (patch)
treeaf4fea558b2c4a5314d661397e1bd34c6fff3382
parent72165825d588d7a1fc445120db8d7f6dba02e7b3 (diff)
fix threads count determination for kqp tasks calculation
fix threads count
-rw-r--r--library/cpp/actors/core/actorsystem.cpp3
-rw-r--r--library/cpp/actors/core/actorsystem.h22
-rw-r--r--library/cpp/actors/core/config.h10
-rw-r--r--ydb/core/kqp/executer_actor/kqp_scan_executer.cpp2
4 files changed, 23 insertions, 14 deletions
diff --git a/library/cpp/actors/core/actorsystem.cpp b/library/cpp/actors/core/actorsystem.cpp
index b8896acb34b..1ba4852f538 100644
--- a/library/cpp/actors/core/actorsystem.cpp
+++ b/library/cpp/actors/core/actorsystem.cpp
@@ -253,9 +253,6 @@ namespace NActors {
}
}
- // ok, setup complete, we could destroy setup config
- SystemSetup.Destroy();
-
Scheduler->PrepareStart();
CpuManager->Start();
Send(MakeSchedulerActorId(), new TEvSchedulerInitialize(scheduleReaders, &CurrentTimestamp, &CurrentMonotonic));
diff --git a/library/cpp/actors/core/actorsystem.h b/library/cpp/actors/core/actorsystem.h
index 591eaf96b7b..7002a9f44e8 100644
--- a/library/cpp/actors/core/actorsystem.h
+++ b/library/cpp/actors/core/actorsystem.h
@@ -122,16 +122,21 @@ namespace NActors {
}
ui32 GetThreads(ui32 poolId) const {
- return Executors ? Executors[poolId]->GetThreads() : CpuManager.GetThreads(poolId);
+ auto result = GetThreadsOptional(poolId);
+ Y_VERIFY(result, "undefined pool id: %" PRIu32, (ui32)poolId);
+ return *result;
}
- std::optional<ui32> GetThreads(const TString& poolName) const {
- for (ui32 i = 0; i < GetExecutorsCount(); ++i) {
- if (GetPoolName(i) == poolName) {
- return GetThreads(i);
+ std::optional<ui32> GetThreadsOptional(const ui32 poolId) const {
+ if (Y_LIKELY(Executors)) {
+ if (Y_LIKELY(poolId < ExecutorsCount)) {
+ return Executors[poolId]->GetThreads();
+ } else {
+ return {};
}
+ } else {
+ return CpuManager.GetThreadsOptional(poolId);
}
- return {};
}
};
@@ -293,11 +298,12 @@ namespace NActors {
}
void GetPoolStats(ui32 poolId, TExecutorPoolStats& poolStats, TVector<TExecutorThreadStats>& statsCopy) const;
- std::optional<ui32> GetPoolThreadsCount(const TString& poolName) const {
+
+ std::optional<ui32> GetPoolThreadsCount(const ui32 poolId) const {
if (!SystemSetup) {
return {};
}
- return SystemSetup->GetThreads(poolName);
+ return SystemSetup->GetThreadsOptional(poolId);
}
void DeferPreStop(std::function<void()> fn) {
diff --git a/library/cpp/actors/core/config.h b/library/cpp/actors/core/config.h
index 0bf4b871d72..30a5050197f 100644
--- a/library/cpp/actors/core/config.h
+++ b/library/cpp/actors/core/config.h
@@ -128,7 +128,7 @@ namespace NActors {
Y_FAIL("undefined pool id: %" PRIu32, (ui32)poolId);
}
- ui32 GetThreads(ui32 poolId) const {
+ std::optional<ui32> GetThreadsOptional(ui32 poolId) const {
for (const auto& p : Basic) {
if (p.PoolId == poolId) {
return p.Threads;
@@ -144,7 +144,13 @@ namespace NActors {
return p.Concurrency ? p.Concurrency : UnitedWorkers.CpuCount;
}
}
- Y_FAIL("undefined pool id: %" PRIu32, (ui32)poolId);
+ return {};
+ }
+
+ ui32 GetThreads(ui32 poolId) const {
+ auto result = GetThreadsOptional(poolId);
+ Y_VERIFY(result, "undefined pool id: %" PRIu32, (ui32)poolId);
+ return *result;
}
};
diff --git a/ydb/core/kqp/executer_actor/kqp_scan_executer.cpp b/ydb/core/kqp/executer_actor/kqp_scan_executer.cpp
index e20216160c4..200a53a8a2a 100644
--- a/ydb/core/kqp/executer_actor/kqp_scan_executer.cpp
+++ b/ydb/core/kqp/executer_actor/kqp_scan_executer.cpp
@@ -217,7 +217,7 @@ private:
} else {
std::optional<ui32> userPoolSize;
if (TlsActivationContext && TlsActivationContext->ActorSystem()) {
- userPoolSize = TlsActivationContext->ActorSystem()->GetPoolThreadsCount("user");
+ userPoolSize = TlsActivationContext->ActorSystem()->GetPoolThreadsCount(AppData()->UserPoolId);
}
if (!userPoolSize) {
ALS_ERROR(NKikimrServices::KQP_EXECUTER) << "user pool is undefined for executer tasks construction";