internal InboundMessageQueue(ILogger <InboundMessageQueue> log, IOptions <StatisticsOptions> statisticsOptions) { this.log = log; int n = Enum.GetValues(typeof(Message.Categories)).Length; this.messageQueues = new Channel <Message> [n]; this.queueTracking = new QueueTrackingStatistic[n]; int i = 0; this.statisticsLevel = statisticsOptions.Value.CollectionLevel; foreach (var category in Enum.GetValues(typeof(Message.Categories))) { this.messageQueues[i] = Channel.CreateUnbounded <Message>(new UnboundedChannelOptions { SingleReader = true, SingleWriter = false, AllowSynchronousContinuations = false }); if (this.statisticsLevel.CollectQueueStats()) { var queueName = "IncomingMessageAgent." + category; this.queueTracking[i] = new QueueTrackingStatistic(queueName, statisticsOptions); this.queueTracking[i].OnStartExecution(); } i++; } }
public ClientMessageCenter( IOptions <GatewayOptions> gatewayOptions, IOptions <ClientMessagingOptions> clientMessagingOptions, IPAddress localAddress, int gen, GrainId clientId, IGatewayListProvider gatewayListProvider, SerializationManager serializationManager, IRuntimeClient runtimeClient, MessageFactory messageFactory, IClusterConnectionStatusListener connectionStatusListener, ExecutorService executorService, ILoggerFactory loggerFactory, IOptions <NetworkingOptions> networkingOptions, IOptions <StatisticsOptions> statisticsOptions) { this.loggerFactory = loggerFactory; this.openConnectionTimeout = networkingOptions.Value.OpenConnectionTimeout; this.SerializationManager = serializationManager; this.executorService = executorService; lockable = new object(); MyAddress = SiloAddress.New(new IPEndPoint(localAddress, 0), gen); ClientId = clientId; this.RuntimeClient = runtimeClient; this.messageFactory = messageFactory; this.connectionStatusListener = connectionStatusListener; Running = false; GatewayManager = new GatewayManager(gatewayOptions.Value, gatewayListProvider, loggerFactory); PendingInboundMessages = new BlockingCollection <Message>(); gatewayConnections = new Dictionary <Uri, GatewayConnection>(); numMessages = 0; grainBuckets = new WeakReference[clientMessagingOptions.Value.ClientSenderBuckets]; logger = loggerFactory.CreateLogger <ClientMessageCenter>(); if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Proxy grain client constructed"); } IntValueStatistic.FindOrCreate( StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT, () => { lock (gatewayConnections) { return(gatewayConnections.Values.Count(conn => conn.IsLive)); } }); statisticsLevel = statisticsOptions.Value.CollectionLevel; if (statisticsLevel.CollectQueueStats()) { queueTracking = new QueueTrackingStatistic("ClientReceiver", statisticsOptions); } }
public ThreadPoolTrackingStatistic(string name, ILoggerFactory loggerFactory, IOptions <StatisticsOptions> statisticsOptions, StageAnalysisStatisticsGroup schedulerStageStatistics) { this.statisticsLevel = statisticsOptions.Value.CollectionLevel; if (statisticsLevel.CollectQueueStats()) { queueTracking = new QueueTrackingStatistic(name, statisticsOptions); } if (this.statisticsLevel.CollectDetailedThreadStatistics()) { threadTracking = new ThreadTrackingStatistic(name, loggerFactory, statisticsOptions, schedulerStageStatistics); } }
public ClientMessageCenter( IOptions <ClientMessagingOptions> clientMessagingOptions, IPAddress localAddress, int gen, GrainId clientId, SerializationManager serializationManager, IRuntimeClient runtimeClient, MessageFactory messageFactory, IClusterConnectionStatusListener connectionStatusListener, ILoggerFactory loggerFactory, IOptions <StatisticsOptions> statisticsOptions, ConnectionManager connectionManager, GatewayManager gatewayManager) { this.messageHandlers = new Action <Message> [Enum.GetValues(typeof(Message.Categories)).Length]; this.connectionManager = connectionManager; this.SerializationManager = serializationManager; MyAddress = SiloAddress.New(new IPEndPoint(localAddress, 0), gen); ClientId = clientId; this.RuntimeClient = runtimeClient; this.messageFactory = messageFactory; this.connectionStatusListener = connectionStatusListener; Running = false; this.gatewayManager = gatewayManager; PendingInboundMessages = Channel.CreateUnbounded <Message>(new UnboundedChannelOptions { SingleReader = true, SingleWriter = false, AllowSynchronousContinuations = false }); numMessages = 0; this.grainBuckets = new WeakReference <Connection> [clientMessagingOptions.Value.ClientSenderBuckets]; logger = loggerFactory.CreateLogger <ClientMessageCenter>(); if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Proxy grain client constructed"); } IntValueStatistic.FindOrCreate( StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT, () => { return(connectionManager.ConnectionCount); }); statisticsLevel = statisticsOptions.Value.CollectionLevel; if (statisticsLevel.CollectQueueStats()) { queueTracking = new QueueTrackingStatistic("ClientReceiver", statisticsOptions); } }
public ThreadPoolThread( string name, CancellationToken cancellationToken, ILoggerFactory loggerFactory, IOptions <StatisticsOptions> statisticsOptions, StageAnalysisStatisticsGroup schedulerStageStatistics) { this.Name = name; this.cancellationToken = cancellationToken; this.log = loggerFactory.CreateLogger <ThreadPoolThread>(); this.statisticsLevel = statisticsOptions.Value.CollectionLevel; if (this.statisticsLevel.CollectDetailedThreadStatistics()) { threadTracking = new ThreadTrackingStatistic(name, loggerFactory, statisticsOptions, schedulerStageStatistics); } }
public SchedulerStatisticsGroup(IOptions <StatisticsOptions> statisticsOptions, ILogger <SchedulerStatisticsGroup> logger) { this.logger = logger; this.collectionLevel = statisticsOptions.Value.CollectionLevel; this.CollectGlobalShedulerStats = collectionLevel.CollectGlobalShedulerStats(); this.CollectTurnsStats = collectionLevel.CollectTurnsStats(); this.CollectPerWorkItemStats = collectionLevel.CollectPerWorkItemStats(); this.CollectShedulerQueuesStats = collectionLevel.CollectShedulerQueuesStats(); workItemGroupStatuses = new StringValueStatistic[1]; workerThreadCounter = 0; workItemGroupCounter = 0; lockable = new object(); if (this.CollectGlobalShedulerStats) { totalPendingWorkItems = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_PENDINGWORKITEMS, false); turnsEnQueuedTotal = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_ITEMS_ENQUEUED_TOTAL); turnsDeQueuedTotal = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_ITEMS_DEQUEUED_TOTAL); turnsDroppedTotal = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_ITEMS_DROPPED_TOTAL); closureWorkItemsCreated = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_CLOSURE_WORK_ITEMS_CREATED); closureWorkItemsExecuted = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_CLOSURE_WORK_ITEMS_EXECUTED); } if (this.CollectTurnsStats) { turnsExecutedByAllWorkerThreadsTotalApplicationTurns = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_TURNSEXECUTED_APPLICATION_BYALLWORKERTHREADS); turnsExecutedByAllWorkerThreadsTotalSystemTurns = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_TURNSEXECUTED_SYSTEM_BYALLWORKERTHREADS); turnsExecutedByAllWorkerThreadsTotalNullTurns = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_TURNSEXECUTED_NULL_BYALLWORKERTHREADS); turnsExecutedByAllWorkItemGroupsTotalApplicationTurns = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_TURNSEXECUTED_APPLICATION_BYALLWORKITEMGROUPS); turnsExecutedByAllWorkItemGroupsTotalSystem = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_TURNSEXECUTED_SYSTEM_BYALLWORKITEMGROUPS); turnLengthHistogram = ExponentialHistogramValueStatistic.Create_ExponentialHistogram_ForTiming(StatisticNames.SCHEDULER_TURN_LENGTH_HISTOGRAM, TURN_LENGTH_HISTOGRAM_SIZE); turnsExecutedStartTotal = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_TURNSEXECUTED_TOTAL_START); turnsExecutedEndTotal = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_TURNSEXECUTED_TOTAL_END); turnsExecutedPerWorkerThreadApplicationTurns ??= new CounterStatistic[1]; turnsExecutedPerWorkerThreadSystemTurns ??= new CounterStatistic[1]; turnsExecutedPerWorkerThreadNull ??= new CounterStatistic[1]; turnsExecutedPerWorkItemGroup ??= new CounterStatistic[1]; } NumLongRunningTurns = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_NUM_LONG_RUNNING_TURNS); NumLongQueueWaitTimes = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_NUM_LONG_QUEUE_WAIT_TIMES); }
public ClientMessageCenter( IOptions <ClientMessagingOptions> clientMessagingOptions, IPAddress localAddress, int gen, ClientGrainId clientId, SerializationManager serializationManager, IRuntimeClient runtimeClient, MessageFactory messageFactory, IClusterConnectionStatusListener connectionStatusListener, ILoggerFactory loggerFactory, IOptions <StatisticsOptions> statisticsOptions, ConnectionManager connectionManager, GatewayManager gatewayManager) { this.connectionManager = connectionManager; this.SerializationManager = serializationManager; MyAddress = SiloAddress.New(new IPEndPoint(localAddress, 0), gen); ClientId = clientId; this.RuntimeClient = runtimeClient; this.messageFactory = messageFactory; this.connectionStatusListener = connectionStatusListener; Running = false; this.gatewayManager = gatewayManager; numMessages = 0; this.grainBuckets = new WeakReference <Connection> [clientMessagingOptions.Value.ClientSenderBuckets]; logger = loggerFactory.CreateLogger <ClientMessageCenter>(); if (logger.IsEnabled(LogLevel.Debug)) { logger.Debug("Proxy grain client constructed"); } IntValueStatistic.FindOrCreate( StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT, () => { return(connectionManager.ConnectionCount); }); statisticsLevel = statisticsOptions.Value.CollectionLevel; if (statisticsLevel.CollectQueueStats()) { queueTracking = new QueueTrackingStatistic("ClientReceiver", statisticsOptions); } }
public SchedulerStatisticsGroup(IOptions <StatisticsOptions> statisticsOptions, ILogger <SchedulerStatisticsGroup> logger) { this.logger = logger; this.collectionLevel = statisticsOptions.Value.CollectionLevel; this.CollectTurnsStats = collectionLevel.CollectTurnsStats(); this.CollectPerWorkItemStats = collectionLevel.CollectPerWorkItemStats(); this.CollectShedulerQueuesStats = collectionLevel.CollectShedulerQueuesStats(); workItemGroupStatuses = new StringValueStatistic[1]; workItemGroupCounter = 0; lockable = new object(); if (this.CollectTurnsStats) { turnsExecutedPerWorkItemGroup ??= new CounterStatistic[1]; } NumLongRunningTurns = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_NUM_LONG_RUNNING_TURNS); NumLongQueueWaitTimes = CounterStatistic.FindOrCreate(StatisticNames.SCHEDULER_NUM_LONG_QUEUE_WAIT_TIMES); }
internal InboundMessageQueue(ILoggerFactory loggerFactory, IOptions <StatisticsOptions> statisticsOptions) { int n = Enum.GetValues(typeof(Message.Categories)).Length; this.messageQueues = new BlockingCollection <Message> [n]; this.queueTracking = new QueueTrackingStatistic[n]; int i = 0; this.statisticsLevel = statisticsOptions.Value.CollectionLevel; foreach (var category in Enum.GetValues(typeof(Message.Categories))) { this.messageQueues[i] = new BlockingCollection <Message>(); if (this.statisticsLevel.CollectQueueStats()) { var queueName = "IncomingMessageAgent." + category; this.queueTracking[i] = new QueueTrackingStatistic(queueName, statisticsOptions); this.queueTracking[i].OnStartExecution(); } i++; } this.log = loggerFactory.CreateLogger <InboundMessageQueue>(); }
public static bool CollectDetailedQueueStatistics(this StatisticsLevel level) => level.CollectQueueStats();
public static bool CollectShedulerQueuesStats(this StatisticsLevel level) => level.IsVerbose2();
public static void Initialize(IStatisticsConfiguration config) { StatisticsCollectionLevel = config.StatisticsCollectionLevel; }
//---------------------------// public static bool CollectGlobalShedulerStats(this StatisticsLevel level) => level.IsVerbose();
public static bool CollectPerWorkItemStats(this StatisticsLevel level) => level.IsVerbose2();
/// <summary> /// Keep track of thread statistics, mainly timing, can be created outside the thread to be tracked. /// </summary> /// <param name="threadName">Name used for logging the collected statistics</param> /// <param name="loggerFactory">LoggerFactory used to create loggers</param> /// <param name="statisticsOptions"></param> /// <param name="schedulerStageStatistics"></param> public ThreadTrackingStatistic( string threadName, ILoggerFactory loggerFactory, IOptions <StatisticsOptions> statisticsOptions, StageAnalysisStatisticsGroup schedulerStageStatistics) { ExecutingCpuCycleTime = new TimeIntervalThreadCycleCounterBased(loggerFactory); ExecutingWallClockTime = TimeIntervalFactory.CreateTimeInterval(true); ProcessingCpuCycleTime = new TimeIntervalThreadCycleCounterBased(loggerFactory); ProcessingWallClockTime = TimeIntervalFactory.CreateTimeInterval(true); NumRequests = 0; firstStart = true; Name = threadName; statisticsLevel = statisticsOptions.Value.CollectionLevel; CounterStorage storage = statisticsLevel.ReportDetailedThreadTimeTrackingStats() ? CounterStorage.LogOnly : CounterStorage.DontStore; CounterStorage aggrCountersStorage = CounterStorage.LogOnly; // 4 direct counters allExecutingCpuCycleTime.Add( FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.THREADS_EXECUTION_TIME_TOTAL_CPU_CYCLES, threadName), () => (float)ExecutingCpuCycleTime.Elapsed.TotalMilliseconds, storage)); allExecutingWallClockTime.Add( FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.THREADS_EXECUTION_TIME_TOTAL_WALL_CLOCK, threadName), () => (float)ExecutingWallClockTime.Elapsed.TotalMilliseconds, storage)); allProcessingCpuCycleTime.Add( FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.THREADS_PROCESSING_TIME_TOTAL_CPU_CYCLES, threadName), () => (float)ProcessingCpuCycleTime.Elapsed.TotalMilliseconds, storage)); allProcessingWallClockTime.Add( FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.THREADS_PROCESSING_TIME_TOTAL_WALL_CLOCK, threadName), () => (float)ProcessingWallClockTime.Elapsed.TotalMilliseconds, storage)); // numRequests allNumProcessedRequests.Add( FloatValueStatistic.FindOrCreate(new StatisticName(StatisticNames.THREADS_PROCESSED_REQUESTS_PER_THREAD, threadName), () => (float)NumRequests, storage)); // aggregate stats if (totalExecutingCpuCycleTime == null) { totalExecutingCpuCycleTime = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.THREADS_EXECUTION_TIME_AVERAGE_CPU_CYCLES, "AllThreads"), () => CalculateTotalAverage(allExecutingCpuCycleTime, totalNumProcessedRequests), aggrCountersStorage); } if (totalExecutingWallClockTime == null) { totalExecutingWallClockTime = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.THREADS_EXECUTION_TIME_AVERAGE_WALL_CLOCK, "AllThreads"), () => CalculateTotalAverage(allExecutingWallClockTime, totalNumProcessedRequests), aggrCountersStorage); } if (totalProcessingCpuCycleTime == null) { totalProcessingCpuCycleTime = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.THREADS_PROCESSING_TIME_AVERAGE_CPU_CYCLES, "AllThreads"), () => CalculateTotalAverage(allProcessingCpuCycleTime, totalNumProcessedRequests), aggrCountersStorage); } if (totalProcessingWallClockTime == null) { totalProcessingWallClockTime = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.THREADS_PROCESSING_TIME_AVERAGE_WALL_CLOCK, "AllThreads"), () => CalculateTotalAverage(allProcessingWallClockTime, totalNumProcessedRequests), aggrCountersStorage); } if (totalNumProcessedRequests == null) { totalNumProcessedRequests = FloatValueStatistic.FindOrCreate( new StatisticName(StatisticNames.THREADS_PROCESSED_REQUESTS_PER_THREAD, "AllThreads"), () => (float)allNumProcessedRequests.Select(cs => cs.GetCurrentValue()).Sum(), aggrCountersStorage); } if (schedulerStageStatistics.PerformStageAnalysis) { schedulerStageStatistics.AddTracking(this); } }
public static void Initialize(StatisticsLevel statisticsLevel) { StatisticsCollectionLevel = statisticsLevel; }
//--------------------------------------// public static bool CollectQueueStats(this StatisticsLevel level) => level.IsVerbose2();
public static bool CollectDetailedThreadStatistics(this StatisticsLevel level) => TRACK_DETAILED_STATS && level.CollectThreadTimeTrackingStats();
public static bool CollectDetailedThreadStatistics(this StatisticsLevel level) => level.CollectThreadTimeTrackingStats();
public static bool CollectDetailedQueueStatistics(this StatisticsLevel level) => TRACK_DETAILED_STATS && level.CollectQueueStats();
public static bool CollectThreadTimeTrackingStats(this StatisticsLevel level) => level.IsVerbose2();
public static bool PerformStageAnalysis(this StatisticsLevel level) => level.IsVerbose2();
public static bool CollectContextSwitchesStats(this StatisticsLevel level) => level.IsVerbose2();
public static bool ReportDetailedThreadTimeTrackingStats(this StatisticsLevel level) => level.IsVerbose2();
/// <summary> /// A row that contains the Statistics Levels and names /// </summary> /// <param name="id">Statistics Level enumeration.</param> /// <returns>Statistics Levels Row</returns> public AppDataSet.StatisticsLevelsRow GetStatisticsLevelById(StatisticsLevel id) { foreach (AppDataSet.StatisticsLevelsRow row in this.StatisticsLevelsDataTable.Rows) { if (row.Id == (short) id) { return row; } } throw new System.ApplicationException("Invalid Statistics Level Id"); }
public static bool CollectApplicationRequestsStats(this StatisticsLevel level) => level.IsInfo();
private static bool IsInfo(this StatisticsLevel level) => level >= StatisticsLevel.Info;
private static bool IsVerbose(this StatisticsLevel level) => level >= StatisticsLevel.Verbose;
/// <summary> /// Builds the command text /// </summary> protected override void GenerateCommand() { Configuration config = Configuration.GetNewInstance(); KeyValuePairCollection kvPairs = new KeyValuePairCollection(); kvPairs.Delimiter = CharLiterals.SPACE; if ((cmbYesAs.Text != config.Settings.RepresentationOfYes) || (hasYesAsChanged)) { kvPairs.Add(new KeyValuePair(ShortHands.YES, Util.InsertInDoubleQuotes(cmbYesAs.Text))); } if ((cmbNoAs.Text != config.Settings.RepresentationOfNo) || (hasNoAsChanged)) { kvPairs.Add(new KeyValuePair(ShortHands.NO, Util.InsertInDoubleQuotes(cmbNoAs.Text))); } if ((cmbMissingAs.Text != config.Settings.RepresentationOfMissing) || (hasMissingAsChanged)) { kvPairs.Add(new KeyValuePair(ShortHands.MISSING, Util.InsertInDoubleQuotes(cmbMissingAs.Text))); } if ((cbxGraphics.Checked != config.Settings.ShowGraphics) || (hasShowGraphicChanged)) { kvPairs.Add(new KeyValuePair(CommandNames.FREQGRAPH, Epi.Util.GetShortHand(cbxGraphics.Checked))); } if ((cbxHyperlinks.Checked != config.Settings.ShowHyperlinks) || (hasShowHyperlinkChanged)) { kvPairs.Add(new KeyValuePair(CommandNames.HYPERLINKS, Epi.Util.GetShortHand(cbxHyperlinks.Checked))); } if ((cbxPercents.Checked != config.Settings.ShowPercents) || (hasShowPercentsChanged)) { kvPairs.Add(new KeyValuePair(CommandNames.PERCENTS, Epi.Util.GetShortHand(cbxPercents.Checked))); } if ((cbxSelectCriteria.Checked != config.Settings.ShowSelection) || (hasShowSelectChanged)) { kvPairs.Add(new KeyValuePair(CommandNames.SELECT, Epi.Util.GetShortHand(cbxSelectCriteria.Checked))); } if ((cbxShowPrompt.Checked != config.Settings.ShowCompletePrompt) || (hasShowPromptChanged)) { kvPairs.Add(new KeyValuePair(CommandNames.SHOWPROMPTS, Epi.Util.GetShortHand(cbxShowPrompt.Checked))); } if ((cbxTablesOutput.Checked != config.Settings.ShowTables) || (hasShowTablesChanged)) { kvPairs.Add(new KeyValuePair(CommandNames.TABLES, Epi.Util.GetShortHand(cbxTablesOutput.Checked))); } if ((cbxIncludeMissing.Checked != config.Settings.IncludeMissingValues) || (hasIncludeMissingChanged)) { kvPairs.Add(new KeyValuePair(CommandNames.MISSING, Epi.Util.GetShortHand(cbxIncludeMissing.Checked))); } if (hasStatisticsLevelChanged) { StatisticsLevel levelIdSelected = (StatisticsLevel)short.Parse(WinUtil.GetSelectedRadioButton(gbxStatistics).Tag.ToString()); string levelTagSelected = AppData.Instance.GetStatisticsLevelById(levelIdSelected).Tag; kvPairs.Add(new KeyValuePair(CommandNames.STATISTICS, levelTagSelected)); } if (hasProcessRecordsChanged) { RecordProcessingScope scopeIdSelected = (RecordProcessingScope)short.Parse(WinUtil.GetSelectedRadioButton(gbxProcessRecords).Tag.ToString()); string scopeTagSelected = AppData.Instance.GetRecordProcessessingScopeById(scopeIdSelected).Tag; kvPairs.Add(new KeyValuePair(CommandNames.PROCESS, scopeTagSelected)); } WordBuilder command = new WordBuilder(); //Generate command only if there are key value pairs if (kvPairs.Count > 0) { if (!this.isDialogMode) { command.Append(CommandNames.SET); } command.Append(kvPairs.ToString()); if (!this.isDialogMode) { command.Append(" END-SET\n"); } this.CommandText = command.ToString(); } else { this.CommandText = string.Empty; } }