diff options
author | ivanmorozov <ivanmorozov@yandex-team.com> | 2023-02-15 15:47:45 +0300 |
---|---|---|
committer | ivanmorozov <ivanmorozov@yandex-team.com> | 2023-02-15 15:47:45 +0300 |
commit | 27e22c30b9098051f1440a1e840d29b11147a57e (patch) | |
tree | af4fea558b2c4a5314d661397e1bd34c6fff3382 /library/cpp | |
parent | 72165825d588d7a1fc445120db8d7f6dba02e7b3 (diff) | |
download | ydb-27e22c30b9098051f1440a1e840d29b11147a57e.tar.gz |
fix threads count determination for kqp tasks calculation
fix threads count
Diffstat (limited to 'library/cpp')
-rw-r--r-- | library/cpp/actors/core/actorsystem.cpp | 3 | ||||
-rw-r--r-- | library/cpp/actors/core/actorsystem.h | 22 | ||||
-rw-r--r-- | library/cpp/actors/core/config.h | 10 |
3 files changed, 22 insertions, 13 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; } }; |