1
1
#include " auto_config_initializer.h"
2
+ #include " config_helpers.h"
2
3
#include " config.h"
3
4
#include " kikimr_services_initializers.h"
4
5
#include " service_initializer.h"
@@ -277,42 +278,6 @@ IKikimrServicesInitializer::IKikimrServicesInitializer(const TKikimrRunConfig& r
277
278
278
279
// TBasicServicesInitializer
279
280
280
- template <class TConfig >
281
- static TCpuMask ParseAffinity (const TConfig& cfg) {
282
- TCpuMask result;
283
- if (cfg.GetCpuList ()) {
284
- result = TCpuMask (cfg.GetCpuList ());
285
- } else if (cfg.GetX ().size () > 0 ) {
286
- result = TCpuMask (cfg.GetX ().data (), cfg.GetX ().size ());
287
- } else { // use all processors
288
- TAffinity available;
289
- available.Current ();
290
- result = available;
291
- }
292
- if (cfg.GetExcludeCpuList ()) {
293
- result = result - TCpuMask (cfg.GetExcludeCpuList ());
294
- }
295
- return result;
296
- }
297
-
298
- TDuration GetSelfPingInterval (const NKikimrConfig::TActorSystemConfig& systemConfig) {
299
- return systemConfig.HasSelfPingInterval ()
300
- ? TDuration::MicroSeconds (systemConfig.GetSelfPingInterval ())
301
- : TDuration::MilliSeconds (10 );
302
- }
303
-
304
-
305
- NActors::EASProfile ConvertActorSystemProfile (NKikimrConfig::TActorSystemConfig::EActorSystemProfile profile) {
306
- switch (profile) {
307
- case NKikimrConfig::TActorSystemConfig::DEFAULT:
308
- return NActors::EASProfile::Default;
309
- case NKikimrConfig::TActorSystemConfig::LOW_CPU_CONSUMPTION:
310
- return NActors::EASProfile::LowCpuConsumption;
311
- case NKikimrConfig::TActorSystemConfig::LOW_LATENCY:
312
- return NActors::EASProfile::LowLatency;
313
- }
314
- }
315
-
316
281
void AddExecutorPool (
317
282
TCpuManagerConfig& cpuManager,
318
283
const NKikimrConfig::TActorSystemConfig::TExecutor& poolConfig,
@@ -321,55 +286,7 @@ void AddExecutorPool(
321
286
const NKikimr::TAppData* appData)
322
287
{
323
288
const auto counters = GetServiceCounters (appData->Counters , " utils" );
324
- switch (poolConfig.GetType ()) {
325
- case NKikimrConfig::TActorSystemConfig::TExecutor::BASIC: {
326
- TBasicExecutorPoolConfig basic;
327
- basic.PoolId = poolId;
328
- basic.PoolName = poolConfig.GetName ();
329
- if (poolConfig.HasMaxAvgPingDeviation ()) {
330
- auto poolGroup = counters->GetSubgroup (" execpool" , basic.PoolName );
331
- auto &poolInfo = cpuManager.PingInfoByPool [poolId];
332
- poolInfo.AvgPingCounter = poolGroup->GetCounter (" SelfPingAvgUs" , false );
333
- poolInfo.AvgPingCounterWithSmallWindow = poolGroup->GetCounter (" SelfPingAvgUsIn1s" , false );
334
- TDuration maxAvgPing = GetSelfPingInterval (systemConfig) + TDuration::MicroSeconds (poolConfig.GetMaxAvgPingDeviation ());
335
- poolInfo.MaxAvgPingUs = maxAvgPing.MicroSeconds ();
336
- }
337
- basic.Threads = Max (poolConfig.GetThreads (), poolConfig.GetMaxThreads ());
338
- basic.SpinThreshold = poolConfig.GetSpinThreshold ();
339
- basic.Affinity = ParseAffinity (poolConfig.GetAffinity ());
340
- basic.RealtimePriority = poolConfig.GetRealtimePriority ();
341
- basic.HasSharedThread = poolConfig.GetHasSharedThread ();
342
- if (poolConfig.HasTimePerMailboxMicroSecs ()) {
343
- basic.TimePerMailbox = TDuration::MicroSeconds (poolConfig.GetTimePerMailboxMicroSecs ());
344
- } else if (systemConfig.HasTimePerMailboxMicroSecs ()) {
345
- basic.TimePerMailbox = TDuration::MicroSeconds (systemConfig.GetTimePerMailboxMicroSecs ());
346
- }
347
- if (poolConfig.HasEventsPerMailbox ()) {
348
- basic.EventsPerMailbox = poolConfig.GetEventsPerMailbox ();
349
- } else if (systemConfig.HasEventsPerMailbox ()) {
350
- basic.EventsPerMailbox = systemConfig.GetEventsPerMailbox ();
351
- }
352
- basic.ActorSystemProfile = ConvertActorSystemProfile (systemConfig.GetActorSystemProfile ());
353
- Y_ABORT_UNLESS (basic.EventsPerMailbox != 0 );
354
- basic.MinThreadCount = poolConfig.GetMinThreads ();
355
- basic.MaxThreadCount = poolConfig.GetMaxThreads ();
356
- basic.DefaultThreadCount = poolConfig.GetThreads ();
357
- basic.Priority = poolConfig.GetPriority ();
358
- cpuManager.Basic .emplace_back (std::move (basic));
359
- break ;
360
- }
361
- case NKikimrConfig::TActorSystemConfig::TExecutor::IO: {
362
- TIOExecutorPoolConfig io;
363
- io.PoolId = poolId;
364
- io.PoolName = poolConfig.GetName ();
365
- io.Threads = poolConfig.GetThreads ();
366
- io.Affinity = ParseAffinity (poolConfig.GetAffinity ());
367
- cpuManager.IO .emplace_back (std::move (io));
368
- break ;
369
- }
370
- default :
371
- Y_ABORT ();
372
- }
289
+ NActorSystemConfigHelpers::AddExecutorPool (cpuManager, poolConfig, systemConfig, poolId, counters);
373
290
}
374
291
375
292
static TCpuManagerConfig CreateCpuManagerConfig (const NKikimrConfig::TActorSystemConfig& config,
@@ -383,16 +300,6 @@ static TCpuManagerConfig CreateCpuManagerConfig(const NKikimrConfig::TActorSyste
383
300
return cpuManager;
384
301
}
385
302
386
- static TSchedulerConfig CreateSchedulerConfig (const NKikimrConfig::TActorSystemConfig::TScheduler &config) {
387
- const ui64 resolution = config.HasResolution () ? config.GetResolution () : 1024 ;
388
- Y_DEBUG_ABORT_UNLESS ((resolution & (resolution - 1 )) == 0 ); // resolution must be power of 2
389
- const ui64 spinThreshold = config.HasSpinThreshold () ? config.GetSpinThreshold () : 0 ;
390
- const ui64 progressThreshold = config.HasProgressThreshold () ? config.GetProgressThreshold () : 10000 ;
391
- const bool useSchedulerActor = config.HasUseSchedulerActor () ? config.GetUseSchedulerActor () : false ;
392
-
393
- return TSchedulerConfig (resolution, spinThreshold, progressThreshold, useSchedulerActor);
394
- }
395
-
396
303
static bool IsServiceInitialized (NActors::TActorSystemSetup* setup, TActorId service)
397
304
{
398
305
for (auto &pr : setup->LocalServices )
@@ -601,7 +508,7 @@ void TBasicServicesInitializer::InitializeServices(NActors::TActorSystemSetup* s
601
508
setup->CpuManager = CreateCpuManagerConfig (systemConfig, appData);
602
509
setup->MonitorStuckActors = systemConfig.GetMonitorStuckActors ();
603
510
604
- auto schedulerConfig = CreateSchedulerConfig (systemConfig.GetScheduler ());
511
+ auto schedulerConfig = NActorSystemConfigHelpers:: CreateSchedulerConfig (systemConfig.GetScheduler ());
605
512
schedulerConfig.MonCounters = GetServiceCounters (counters, " utils" );
606
513
setup->Scheduler .Reset (CreateSchedulerThread (schedulerConfig));
607
514
setup->LocalServices .emplace_back (MakeIoDispatcherActorId (), TActorSetupCmd (CreateIoDispatcherActor (
@@ -1265,7 +1172,7 @@ void TSchedulerActorInitializer::InitializeServices(
1265
1172
NActors::TActorSystemSetup* setup,
1266
1173
const NKikimr::TAppData* appData) {
1267
1174
auto & systemConfig = Config.GetActorSystemConfig ();
1268
- NActors::IActor *schedulerActor = CreateSchedulerActor (CreateSchedulerConfig (systemConfig.GetScheduler ()));
1175
+ NActors::IActor *schedulerActor = CreateSchedulerActor (NActorSystemConfigHelpers:: CreateSchedulerConfig (systemConfig.GetScheduler ()));
1269
1176
if (schedulerActor) {
1270
1177
NActors::TActorSetupCmd schedulerActorCmd (schedulerActor, NActors::TMailboxType::ReadAsFilled, appData->SystemPoolId );
1271
1178
setup->LocalServices .emplace_back (MakeSchedulerActorId (), std::move (schedulerActorCmd));
0 commit comments