private OrleansTaskScheduler(int maxActiveThreads, TimeSpan delayWarningThreshold, TimeSpan activationSchedulingQuantum, TimeSpan turnWarningLengthThreshold, bool injectMoreWorkerThreads, LimitValue maxPendingItemsLimit) { Instance = this; DelayWarningThreshold = delayWarningThreshold; WorkItemGroup.ActivationSchedulingQuantum = activationSchedulingQuantum; TurnWarningLengthThreshold = turnWarningLengthThreshold; applicationTurnsStopped = false; MaxPendingItemsLimit = maxPendingItemsLimit; workgroupDirectory = new ConcurrentDictionary <ISchedulingContext, WorkItemGroup>(); RunQueue = new WorkQueue(); logger.Info("Starting OrleansTaskScheduler with {0} Max Active application Threads and 1 system thread.", maxActiveThreads); Pool = new WorkerPool(this, maxActiveThreads, injectMoreWorkerThreads); IntValueStatistic.FindOrCreate(StatisticNames.SCHEDULER_WORKITEMGROUP_COUNT, () => WorkItemGroupCount); IntValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_QUEUE_SIZE_INSTANTANEOUS_PER_QUEUE, "Scheduler.LevelOne"), () => RunQueueLength); if (!StatisticsCollector.CollectShedulerQueuesStats) { return; } FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_QUEUE_SIZE_AVERAGE_PER_QUEUE, "Scheduler.LevelTwo.Average"), () => AverageRunQueueLengthLevelTwo); FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_ENQUEUED_PER_QUEUE, "Scheduler.LevelTwo.Average"), () => AverageEnqueuedLevelTwo); FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_AVERAGE_ARRIVAL_RATE_PER_QUEUE, "Scheduler.LevelTwo.Average"), () => AverageArrivalRateLevelTwo); FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_QUEUE_SIZE_AVERAGE_PER_QUEUE, "Scheduler.LevelTwo.Sum"), () => SumRunQueueLengthLevelTwo); FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_ENQUEUED_PER_QUEUE, "Scheduler.LevelTwo.Sum"), () => SumEnqueuedLevelTwo); FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_AVERAGE_ARRIVAL_RATE_PER_QUEUE, "Scheduler.LevelTwo.Sum"), () => SumArrivalRateLevelTwo); }
private OrleansTaskScheduler(int maxActiveThreads, TimeSpan delayWarningThreshold, TimeSpan activationSchedulingQuantum, TimeSpan turnWarningLengthThreshold, bool injectMoreWorkerThreads, LimitValue maxPendingItemsLimit) { Instance = this; DelayWarningThreshold = delayWarningThreshold; WorkItemGroup.ActivationSchedulingQuantum = activationSchedulingQuantum; TurnWarningLengthThreshold = turnWarningLengthThreshold; applicationTurnsStopped = false; MaxPendingItemsLimit = maxPendingItemsLimit; workgroupDirectory = new ConcurrentDictionary<ISchedulingContext, WorkItemGroup>(); RunQueue = new WorkQueue(); logger.Info("Starting OrleansTaskScheduler with {0} Max Active application Threads and 1 system thread.", maxActiveThreads); Pool = new WorkerPool(this, maxActiveThreads, injectMoreWorkerThreads); IntValueStatistic.FindOrCreate(StatisticNames.SCHEDULER_WORKITEMGROUP_COUNT, () => WorkItemGroupCount); IntValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_QUEUE_SIZE_INSTANTANEOUS_PER_QUEUE, "Scheduler.LevelOne"), () => RunQueueLength); if (!StatisticsCollector.CollectShedulerQueuesStats) return; FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_QUEUE_SIZE_AVERAGE_PER_QUEUE, "Scheduler.LevelTwo.Average"), () => AverageRunQueueLengthLevelTwo); FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_ENQUEUED_PER_QUEUE, "Scheduler.LevelTwo.Average"), () => AverageEnqueuedLevelTwo); FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_AVERAGE_ARRIVAL_RATE_PER_QUEUE, "Scheduler.LevelTwo.Average"), () => AverageArrivalRateLevelTwo); FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_QUEUE_SIZE_AVERAGE_PER_QUEUE, "Scheduler.LevelTwo.Sum"), () => SumRunQueueLengthLevelTwo); FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_ENQUEUED_PER_QUEUE, "Scheduler.LevelTwo.Sum"), () => SumEnqueuedLevelTwo); FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.QUEUES_AVERAGE_ARRIVAL_RATE_PER_QUEUE, "Scheduler.LevelTwo.Sum"), () => SumArrivalRateLevelTwo); }
internal WorkerPoolThread(WorkerPool gtp, OrleansTaskScheduler sched, bool system = false) : base(system ? "System" : null) { pool = gtp; scheduler = sched; ownsSemaphore = false; IsSystem = system; maxWorkQueueWait = IsSystem ? Constants.INFINITE_TIMESPAN : gtp.MaxWorkQueueWait; OnFault = FaultBehavior.IgnoreFault; CurrentStateStarted = DateTime.UtcNow; CurrentWorkItem = null; if (StatisticsCollector.CollectTurnsStats) { WorkerThreadStatisticsNumber = SchedulerStatisticsGroup.RegisterWorkingThread(Name); } }
internal WorkerPoolThread(WorkerPool gtp, OrleansTaskScheduler sched, ICorePerformanceMetrics performanceMetrics, int threadNumber, bool system = false) : base((system ? "System." : "") + threadNumber) { pool = gtp; scheduler = sched; this.performanceMetrics = performanceMetrics; ownsSemaphore = false; IsSystem = system; maxWorkQueueWait = IsSystem ? Constants.INFINITE_TIMESPAN : gtp.MaxWorkQueueWait; OnFault = FaultBehavior.IgnoreFault; currentWorkItemStarted = DateTime.UtcNow; currentTaskStarted = DateTime.UtcNow; CurrentWorkItem = null; if (StatisticsCollector.CollectTurnsStats) { WorkerThreadStatisticsNumber = SchedulerStatisticsGroup.RegisterWorkingThread(Name); } }
internal WorkerPoolThread(WorkerPool gtp, OrleansTaskScheduler sched, ExecutorService executorService, ILoggerFactory loggerFactory, IHostEnvironmentStatistics hostEnvironmentStatistics, int threadNumber, bool system = false) : base((system ? "System." : "") + threadNumber, executorService, loggerFactory) { pool = gtp; scheduler = sched; this.hostEnvironmentStatistics = hostEnvironmentStatistics; ownsSemaphore = false; IsSystem = system; maxWorkQueueWait = IsSystem ? Constants.INFINITE_TIMESPAN : gtp.MaxWorkQueueWait; OnFault = FaultBehavior.IgnoreFault; currentWorkItemStarted = DateTime.UtcNow; currentTaskStarted = DateTime.UtcNow; CurrentWorkItem = null; if (StatisticsCollector.CollectTurnsStats) { WorkerThreadStatisticsNumber = SchedulerStatisticsGroup.RegisterWorkingThread(Name); } }
internal WorkerPoolThread(WorkerPool gtp, OrleansTaskScheduler sched, int threadNumber, bool system = false) : base((system ? "System." : "") + threadNumber) { pool = gtp; scheduler = sched; ownsSemaphore = false; IsSystem = system; maxWorkQueueWait = IsSystem ? Constants.INFINITE_TIMESPAN : gtp.MaxWorkQueueWait; OnFault = FaultBehavior.IgnoreFault; currentWorkItemStarted = DateTime.UtcNow; currentTaskStarted = DateTime.UtcNow; CurrentWorkItem = null; if (StatisticsCollector.CollectTurnsStats) WorkerThreadStatisticsNumber = SchedulerStatisticsGroup.RegisterWorkingThread(Name); }