diff options
author | serxa <serxa@yandex-team.ru> | 2022-02-10 16:49:08 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:08 +0300 |
commit | e5d4696304c6689379ac7ce334512404d4b7836c (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/actors/core/cpu_manager.cpp | |
parent | d6d7db348c2cc64e71243cab9940ee6778f4317d (diff) | |
download | ydb-e5d4696304c6689379ac7ce334512404d4b7836c.tar.gz |
Restoring authorship annotation for <serxa@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/actors/core/cpu_manager.cpp')
-rw-r--r-- | library/cpp/actors/core/cpu_manager.cpp | 216 |
1 files changed, 108 insertions, 108 deletions
diff --git a/library/cpp/actors/core/cpu_manager.cpp b/library/cpp/actors/core/cpu_manager.cpp index 26aca975e9..39089b5d83 100644 --- a/library/cpp/actors/core/cpu_manager.cpp +++ b/library/cpp/actors/core/cpu_manager.cpp @@ -1,108 +1,108 @@ -#include "cpu_manager.h" -#include "probes.h" - -namespace NActors { - LWTRACE_USING(ACTORLIB_PROVIDER); - - void TCpuManager::Setup() { - TAffinity available; - available.Current(); - TCpuAllocationConfig allocation(available, Config); - - if (allocation) { - if (!Balancer) { - Balancer.Reset(MakeBalancer(Config.UnitedWorkers.Balancer, Config.United, GetCycleCountFast())); - } - UnitedWorkers.Reset(new TUnitedWorkers(Config.UnitedWorkers, Config.United, allocation, Balancer.Get())); - } - - Executors.Reset(new TAutoPtr<IExecutorPool>[ExecutorPoolCount]); - - for (ui32 excIdx = 0; excIdx != ExecutorPoolCount; ++excIdx) { - Executors[excIdx].Reset(CreateExecutorPool(excIdx)); - } - } - - void TCpuManager::PrepareStart(TVector<NSchedulerQueue::TReader*>& scheduleReaders, TActorSystem* actorSystem) { - if (UnitedWorkers) { - UnitedWorkers->Prepare(actorSystem, scheduleReaders); - } - for (ui32 excIdx = 0; excIdx != ExecutorPoolCount; ++excIdx) { - NSchedulerQueue::TReader* readers; - ui32 readersCount = 0; - Executors[excIdx]->Prepare(actorSystem, &readers, &readersCount); - for (ui32 i = 0; i != readersCount; ++i, ++readers) { - scheduleReaders.push_back(readers); - } - } - } - - void TCpuManager::Start() { - if (UnitedWorkers) { - UnitedWorkers->Start(); - } - for (ui32 excIdx = 0; excIdx != ExecutorPoolCount; ++excIdx) { - Executors[excIdx]->Start(); - } - } - - void TCpuManager::PrepareStop() { - for (ui32 excIdx = 0; excIdx != ExecutorPoolCount; ++excIdx) { - Executors[excIdx]->PrepareStop(); - } - if (UnitedWorkers) { - UnitedWorkers->PrepareStop(); - } - } - - void TCpuManager::Shutdown() { - for (ui32 excIdx = 0; excIdx != ExecutorPoolCount; ++excIdx) { - Executors[excIdx]->Shutdown(); - } - if (UnitedWorkers) { - UnitedWorkers->Shutdown(); - } - for (ui32 round = 0, done = 0; done < ExecutorPoolCount && round < 3; ++round) { - done = 0; - for (ui32 excIdx = 0; excIdx != ExecutorPoolCount; ++excIdx) { - if (Executors[excIdx]->Cleanup()) { - ++done; - } - } - } - } - - void TCpuManager::Cleanup() { - for (ui32 round = 0, done = 0; done < ExecutorPoolCount; ++round) { - Y_VERIFY(round < 10, "actorsystem cleanup could not be completed in 10 rounds"); - done = 0; - for (ui32 excIdx = 0; excIdx != ExecutorPoolCount; ++excIdx) { - if (Executors[excIdx]->Cleanup()) { - ++done; - } - } - } - Executors.Destroy(); - UnitedWorkers.Destroy(); - } - - IExecutorPool* TCpuManager::CreateExecutorPool(ui32 poolId) { - for (TBasicExecutorPoolConfig& cfg : Config.Basic) { - if (cfg.PoolId == poolId) { - return new TBasicExecutorPool(cfg); - } - } - for (TIOExecutorPoolConfig& cfg : Config.IO) { - if (cfg.PoolId == poolId) { - return new TIOExecutorPool(cfg); - } - } - for (TUnitedExecutorPoolConfig& cfg : Config.United) { - if (cfg.PoolId == poolId) { - IExecutorPool* result = new TUnitedExecutorPool(cfg, UnitedWorkers.Get()); - return result; - } - } - Y_FAIL("missing PoolId: %d", int(poolId)); - } -} +#include "cpu_manager.h" +#include "probes.h" + +namespace NActors { + LWTRACE_USING(ACTORLIB_PROVIDER); + + void TCpuManager::Setup() { + TAffinity available; + available.Current(); + TCpuAllocationConfig allocation(available, Config); + + if (allocation) { + if (!Balancer) { + Balancer.Reset(MakeBalancer(Config.UnitedWorkers.Balancer, Config.United, GetCycleCountFast())); + } + UnitedWorkers.Reset(new TUnitedWorkers(Config.UnitedWorkers, Config.United, allocation, Balancer.Get())); + } + + Executors.Reset(new TAutoPtr<IExecutorPool>[ExecutorPoolCount]); + + for (ui32 excIdx = 0; excIdx != ExecutorPoolCount; ++excIdx) { + Executors[excIdx].Reset(CreateExecutorPool(excIdx)); + } + } + + void TCpuManager::PrepareStart(TVector<NSchedulerQueue::TReader*>& scheduleReaders, TActorSystem* actorSystem) { + if (UnitedWorkers) { + UnitedWorkers->Prepare(actorSystem, scheduleReaders); + } + for (ui32 excIdx = 0; excIdx != ExecutorPoolCount; ++excIdx) { + NSchedulerQueue::TReader* readers; + ui32 readersCount = 0; + Executors[excIdx]->Prepare(actorSystem, &readers, &readersCount); + for (ui32 i = 0; i != readersCount; ++i, ++readers) { + scheduleReaders.push_back(readers); + } + } + } + + void TCpuManager::Start() { + if (UnitedWorkers) { + UnitedWorkers->Start(); + } + for (ui32 excIdx = 0; excIdx != ExecutorPoolCount; ++excIdx) { + Executors[excIdx]->Start(); + } + } + + void TCpuManager::PrepareStop() { + for (ui32 excIdx = 0; excIdx != ExecutorPoolCount; ++excIdx) { + Executors[excIdx]->PrepareStop(); + } + if (UnitedWorkers) { + UnitedWorkers->PrepareStop(); + } + } + + void TCpuManager::Shutdown() { + for (ui32 excIdx = 0; excIdx != ExecutorPoolCount; ++excIdx) { + Executors[excIdx]->Shutdown(); + } + if (UnitedWorkers) { + UnitedWorkers->Shutdown(); + } + for (ui32 round = 0, done = 0; done < ExecutorPoolCount && round < 3; ++round) { + done = 0; + for (ui32 excIdx = 0; excIdx != ExecutorPoolCount; ++excIdx) { + if (Executors[excIdx]->Cleanup()) { + ++done; + } + } + } + } + + void TCpuManager::Cleanup() { + for (ui32 round = 0, done = 0; done < ExecutorPoolCount; ++round) { + Y_VERIFY(round < 10, "actorsystem cleanup could not be completed in 10 rounds"); + done = 0; + for (ui32 excIdx = 0; excIdx != ExecutorPoolCount; ++excIdx) { + if (Executors[excIdx]->Cleanup()) { + ++done; + } + } + } + Executors.Destroy(); + UnitedWorkers.Destroy(); + } + + IExecutorPool* TCpuManager::CreateExecutorPool(ui32 poolId) { + for (TBasicExecutorPoolConfig& cfg : Config.Basic) { + if (cfg.PoolId == poolId) { + return new TBasicExecutorPool(cfg); + } + } + for (TIOExecutorPoolConfig& cfg : Config.IO) { + if (cfg.PoolId == poolId) { + return new TIOExecutorPool(cfg); + } + } + for (TUnitedExecutorPoolConfig& cfg : Config.United) { + if (cfg.PoolId == poolId) { + IExecutorPool* result = new TUnitedExecutorPool(cfg, UnitedWorkers.Get()); + return result; + } + } + Y_FAIL("missing PoolId: %d", int(poolId)); + } +} |